CMakeLists.txt: fixes for Visual Studio's built-in CMake

This commit is contained in:
Iliyas Jorio 2021-03-15 23:46:57 +01:00
parent 498b27e895
commit b3393c89f6
2 changed files with 10 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/out

View File

@ -88,19 +88,26 @@ target_include_directories(${PROJECT_NAME} PRIVATE
) )
if(MSVC) if(MSVC)
# By default, MSVC may add /EHsc to CMAKE_CXX_FLAGS, which we don't want (we use /EHs below)
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# By default, MSVC may add /W3 to CMAKE_CXX_FLAGS, which we don't want (we use /W4 below)
# Note that this is not required with "cmake_minimum_required(VERSION 3.15)" or later
string(REPLACE "/W3" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# On Win32, we need NOGDI and NOUSER to be able to define some Mac functions # On Win32, we need NOGDI and NOUSER to be able to define some Mac functions
# whose names are otherwise taken by Windows APIs. # whose names are otherwise taken by Windows APIs.
target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN NOGDI NOUSER) target_compile_definitions(${PROJECT_NAME} PRIVATE WIN32_LEAN_AND_MEAN NOGDI NOUSER)
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE
/EHa /EHs # synchronous exceptions; also, extern "C" functions may throw exceptions
/W4 /W4
/wd4068 # ignore unrecognized pragmas /wd4068 # ignore unrecognized pragmas
/wd4100 # unreferenced formal parameter /wd4100 # unreferenced formal parameter
/wd4201 # nonstandard extension /wd4201 # nonstandard extension
/wd4244 # conversion from double to float /wd4244 # conversion from double to float
/wd4458 # declaration of variable hides class member /wd4458 # declaration of variable hides class member
/MP /MP # multiprocessor compilation
) )
else() else()
target_compile_options(${PROJECT_NAME} PRIVATE target_compile_options(${PROJECT_NAME} PRIVATE