CMakeLists: Add MSVC standards conformance flags

Applies flags to make MSVC's compiler be more standards compliant.
This commit is contained in:
Lioncash 2019-09-10 20:40:24 -04:00
parent 6c07ec907a
commit 60dad60448
2 changed files with 50 additions and 6 deletions

View File

@ -75,22 +75,47 @@ add_library(amuse
include/amuse/VolumeTable.hpp 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) if(NX)
target_sources(amuse PRIVATE include/switch_math.hpp) target_sources(amuse PRIVATE include/switch_math.hpp)
endif() 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) if(TARGET boo)
target_sources(amuse PRIVATE lib/BooBackend.cpp include/amuse/BooBackend.hpp) target_sources(amuse PRIVATE lib/BooBackend.cpp include/amuse/BooBackend.hpp)
target_link_libraries(amuse boo) target_link_libraries(amuse boo)
endif() 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) target_compile_options(amuse PRIVATE -Wno-unknown-pragmas)
endif() endif()
if(COMMAND add_sanitizers) if(COMMAND add_sanitizers)
add_sanitizers(amuse) add_sanitizers(amuse)
endif() endif()

View File

@ -81,6 +81,25 @@ target_compile_definitions(amuse-gui PRIVATE
-DQT_USE_QSTRINGBUILDER -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) if(WIN32)
target_sources(amuse-gui PRIVATE target_sources(amuse-gui PRIVATE
platforms/win/amuse-gui.rc platforms/win/amuse-gui.rc