Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cmake and MSVC Compiler issues #170

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)

# Generated by `boostdep --cmake parser`

cmake_minimum_required(VERSION 3.8...3.20)
cmake_minimum_required(VERSION 3.14...3.20)

project(boost_parser VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

Expand All @@ -30,7 +30,7 @@ endif()

else()

cmake_minimum_required(VERSION 3.8...3.20)
cmake_minimum_required(VERSION 3.14...3.20)
project(parse)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

Expand All @@ -40,14 +40,26 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CXX_STD 17 CACHE STRING "Set to 14, 17, etc., to enable C++14, C++17, etc.")
message("-- Using -std=c++${CXX_STD}")

if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
add_definitions(-Wall)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
add_definitions(-Wall)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL MSVC)
# to just check the different frontend flavours we could use the following code
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
get_filename_component(CNAME "${CMAKE_CXX_COMPILER}" NAME)
message(STATUS "Detected MSVC style compiler frontend '" ${CNAME} "'")
add_definitions(/W3)
add_compile_options(/Zc:__cplusplus) # not sure, if it necessary for clang-cl
elseif (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
get_filename_component(CNAME "${CMAKE_CXX_COMPILER}" NAME)
message(STATUS "Detected GNU style compiler frontend '" ${CNAME} "'")
add_definitions(-Wall)
endif ()

# alternatively the boolean variable 'MSVC' is equivalent to 'if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")'
# summary for a more detailed analysis (https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html#variables-that-provide-information):
# CMAKE_CXX_COMPILER_ID: Clang, GNU, MSVC
# CMAKE_CXX_COMPILER_FRONTEND_VARIANT: GNU, MSVC
# CMAKE_CXX_SIMULATE_ID: MSVC (for Microsoft clang and clang-cl as they use the MSVC runtime)
# CMAKE_CXX_PLATFORM_ID: Windows, Darwin, MinGW, MSYS, Linux, UNIX, ...
# Variables that describe the system (https://cmake.org/cmake/help/latest/manual/cmake-variables.7.html#variables-that-describe-the-system)


##################################################
# Build config
Expand Down
Loading