diff --git a/cmake/OpenSimMacros.cmake b/cmake/OpenSimMacros.cmake index f24eacd046..e1b9e537e9 100644 --- a/cmake/OpenSimMacros.cmake +++ b/cmake/OpenSimMacros.cmake @@ -221,10 +221,9 @@ function(OpenSimAddLibrary) # This target links to the libraries provided as arguments to this func. target_link_libraries(${OSIMADDLIB_LIBRARY_NAME} ${OSIMADDLIB_LINKLIBS}) - target_compile_options(${OSIMADDLIB_LIBRARY_NAME} PUBLIC - # disable warning 4996 on Windows: `spdlog` transitively - # uses a deprecated `stdext::checked_array_iterator` - $<$:/wd4996> + target_compile_definitions(${OSIMADDLIB_LIBRARY_NAME} PUBLIC + # `spdlog` transitively uses a deprecated `stdext::checked_array_iterator` + $<$:_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING> ) # This is for exporting classes on Windows. diff --git a/dependencies/CMakeLists.txt b/dependencies/CMakeLists.txt index 7ecea1ffa0..0b68f0bff7 100644 --- a/dependencies/CMakeLists.txt +++ b/dependencies/CMakeLists.txt @@ -105,7 +105,6 @@ function(AddDependency) list(APPEND CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}) endif() - list(APPEND CMAKE_ARGS ${DEP_CMAKE_ARGS}) # Forward cmake arguments to dependencies. list(APPEND CMAKE_ARGS @@ -140,6 +139,9 @@ function(AddDependency) list(APPEND CMAKE_ARGS -DSWIG_EXECUTABLE:FILEPATH=${SWIG_EXECUTABLE}) endif() + # Append the dependency-specific CMake arguments. + list(APPEND CMAKE_ARGS ${DEP_CMAKE_ARGS}) + if(DEP_GIT_URL) ExternalProject_Add(${DEP_NAME} DEPENDS ${DEP_DEPENDS} @@ -193,6 +195,11 @@ AddDependency(NAME docopt GIT_URL https://github.com/docopt/docopt.cpp.git GIT_TAG 3dd23e3280f213bacefdf5fcb04857bf52e90917) +set(SPDLOG_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +if(MSVC) + # `spdlog` transitively uses a deprecated `stdext::checked_array_iterator` + set(SPDLOG_CXX_FLAGS "${SPDLOG_CXX_FLAGS} /D_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING") +endif() AddDependency(NAME spdlog DEFAULT ON @@ -201,7 +208,8 @@ AddDependency(NAME spdlog CMAKE_ARGS -DSPDLOG_BUILD_BENCH:BOOL=OFF -DSPDLOG_BUILD_TESTS:BOOL=OFF -DSPDLOG_BUILD_EXAMPLE:BOOL=OFF - -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON) + -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON + -DCMAKE_CXX_FLAGS:STRING=${SPDLOG_CXX_FLAGS}) AddDependency(NAME catch2 DEFAULT ON