From 60dad604485e86dfa20ccb6d1afcd1fd84d771ad Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 10 Sep 2019 20:40:24 -0400 Subject: [PATCH] CMakeLists: Add MSVC standards conformance flags Applies flags to make MSVC's compiler be more standards compliant. --- CMakeLists.txt | 37 +++++++++++++++++++++++++++++++------ Editor/CMakeLists.txt | 19 +++++++++++++++++++ 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2b427f..3341e53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,22 +75,47 @@ add_library(amuse include/amuse/VolumeTable.hpp ) +target_atdna(amuse atdna_AudioGroupPool.cpp include/amuse/AudioGroupPool.hpp) +target_atdna(amuse atdna_AudioGroupProject.cpp include/amuse/AudioGroupProject.hpp) +target_atdna(amuse atdna_AudioGroupSampleDirectory.cpp include/amuse/AudioGroupSampleDirectory.hpp) + +target_include_directories(amuse PUBLIC include) +target_link_libraries(amuse + athena-core + lzokay + ${ZLIB_LIBRARIES} +) + if(NX) target_sources(amuse PRIVATE include/switch_math.hpp) endif() -target_atdna(amuse atdna_AudioGroupPool.cpp include/amuse/AudioGroupPool.hpp) -target_atdna(amuse atdna_AudioGroupProject.cpp include/amuse/AudioGroupProject.hpp) -target_atdna(amuse atdna_AudioGroupSampleDirectory.cpp include/amuse/AudioGroupSampleDirectory.hpp) -target_include_directories(amuse PUBLIC include) -target_link_libraries(amuse athena-core ${ZLIB_LIBRARIES} lzokay) if(TARGET boo) target_sources(amuse PRIVATE lib/BooBackend.cpp include/amuse/BooBackend.hpp) target_link_libraries(amuse boo) endif() -if (NOT MSVC) + +if (MSVC) + target_compile_options(amuse PRIVATE + # Enforce various standards compliant behavior. + /permissive- + + # Enable standard volatile semantics. + /volatile:iso + + # Reports the proper value for the __cplusplus preprocessor macro. + /Zc:__cplusplus + + # Allow constexpr variables to have explicit external linkage. + /Zc:externConstexpr + + # Assume that new throws exceptions, allowing better code generation. + /Zc:throwingNew + ) +else() target_compile_options(amuse PRIVATE -Wno-unknown-pragmas) endif() + if(COMMAND add_sanitizers) add_sanitizers(amuse) endif() diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index f8d0595..9d9b344 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -81,6 +81,25 @@ target_compile_definitions(amuse-gui PRIVATE -DQT_USE_QSTRINGBUILDER ) +if (MSVC) + target_compile_options(amuse-gui PRIVATE + # Enforce various standards compliant behavior. + /permissive- + + # Enable standard volatile semantics. + /volatile:iso + + # Reports the proper value for the __cplusplus preprocessor macro. + /Zc:__cplusplus + + # Allow constexpr variables to have explicit external linkage. + /Zc:externConstexpr + + # Assume that new throws exceptions, allowing better code generation. + /Zc:throwingNew + ) +endif() + if(WIN32) target_sources(amuse-gui PRIVATE platforms/win/amuse-gui.rc