Exclude CMake CXX standard from MSVC

This commit is contained in:
Jack Andersen 2020-04-10 18:59:16 -10:00
parent 9c75aeccbe
commit 92f44407c6
2 changed files with 34 additions and 18 deletions

View File

@ -2,8 +2,10 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
project(amuse)
set(CMAKE_CXX_STANDARD 17)
if (NOT MSVC)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if(NOT MSVC)
add_compile_options(-Wno-narrowing)
@ -98,20 +100,27 @@ endif()
if (MSVC)
target_compile_options(amuse PRIVATE
# Enforce various standards compliant behavior.
/permissive-
$<$<COMPILE_LANGUAGE:CXX>:/permissive->
# Enable standard volatile semantics.
/volatile:iso
$<$<COMPILE_LANGUAGE:CXX>:/volatile:iso>
# Reports the proper value for the __cplusplus preprocessor macro.
/Zc:__cplusplus
$<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>
# Use latest C++ standard.
$<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>
)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Flags for MSVC (not clang-cl)
target_compile_options(amuse PRIVATE
# Allow constexpr variables to have explicit external linkage.
/Zc:externConstexpr
$<$<COMPILE_LANGUAGE:CXX>:/Zc:externConstexpr>
# Assume that new throws exceptions, allowing better code generation.
/Zc:throwingNew
$<$<COMPILE_LANGUAGE:CXX>:/Zc:throwingNew>
)
endif()
else()
target_compile_options(amuse PRIVATE -Wno-unknown-pragmas)
endif()

View File

@ -84,21 +84,28 @@ target_compile_definitions(amuse-gui PRIVATE
if (MSVC)
target_compile_options(amuse-gui PRIVATE
# Enforce various standards compliant behavior.
/permissive-
$<$<COMPILE_LANGUAGE:CXX>:/permissive->
# Enable standard volatile semantics.
/volatile:iso
$<$<COMPILE_LANGUAGE:CXX>:/volatile:iso>
# Reports the proper value for the __cplusplus preprocessor macro.
/Zc:__cplusplus
$<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>
# Use latest C++ standard.
$<$<COMPILE_LANGUAGE:CXX>:/std:c++latest>
)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Flags for MSVC (not clang-cl)
target_compile_options(amuse-gui PRIVATE
# Allow constexpr variables to have explicit external linkage.
/Zc:externConstexpr
$<$<COMPILE_LANGUAGE:CXX>:/Zc:externConstexpr>
# Assume that new throws exceptions, allowing better code generation.
/Zc:throwingNew
$<$<COMPILE_LANGUAGE:CXX>:/Zc:throwingNew>
)
endif()
endif()
if(WIN32)
target_sources(amuse-gui PRIVATE