Skip to content

Commit

Permalink
Merge pull request #3907 from opensim-org/silence_checked_array_itera…
Browse files Browse the repository at this point in the history
…tor_warning

Ignore warnings related to deprecated `stdext::checked_array_iterator` on MSVC (again)
  • Loading branch information
adamkewley authored Sep 17, 2024
2 parents bd17674 + 597b30e commit 292147c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
7 changes: 3 additions & 4 deletions cmake/OpenSimMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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`
$<$<CXX_COMPILER_ID:MSVC>:/wd4996>
target_compile_definitions(${OSIMADDLIB_LIBRARY_NAME} PUBLIC
# `spdlog` transitively uses a deprecated `stdext::checked_array_iterator`
$<$<CXX_COMPILER_ID:MSVC>:_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING>
)

# This is for exporting classes on Windows.
Expand Down
12 changes: 10 additions & 2 deletions dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 292147c

Please sign in to comment.