Skip to content

Commit 0e324ae

Browse files
mrexodiakyle-elliott-tob
authored andcommitted
Do not propagate empty CMAKE_MSVC_RUNTIME_LIBRARY
1 parent 71b1915 commit 0e324ae

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

dependencies/superbuild.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,19 @@ list(APPEND CMAKE_ARGS
124124
"-DCMAKE_POSITION_INDEPENDENT_CODE:STRING=ON"
125125
"-DCMAKE_ERROR_DEPRECATED:STRING=OFF"
126126
"-DCMAKE_ERROR_DEVELOPER_WARNINGS:STRING=OFF"
127-
"-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=${CMAKE_MSVC_RUNTIME_LIBRARY}"
128127
"-DCMAKE_POLICY_DEFAULT_CMP0091:STRING=NEW" # Needed to make sure gflags respects CMAKE_MSVC_RUNTIME_LIBRARY as their minimum CMake version is older than 3.15.
129128
)
130129

130+
# Only propagate the MSVC runtime selection if the parent project explicitly set
131+
# one. Passing an empty CMAKE_MSVC_RUNTIME_LIBRARY to external projects on
132+
# Windows suppresses the CRT selection and breaks clang's compiler checks.
133+
if(DEFINED CMAKE_MSVC_RUNTIME_LIBRARY
134+
AND NOT CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "")
135+
list(APPEND CMAKE_ARGS
136+
"-DCMAKE_MSVC_RUNTIME_LIBRARY:STRING=${CMAKE_MSVC_RUNTIME_LIBRARY}"
137+
)
138+
endif()
139+
131140
if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.0")
132141
list(APPEND CMAKE_ARGS
133142
"-DCMAKE_POLICY_VERSION_MINIMUM:STRING=${CMAKE_MINIMUM_REQUIRED_VERSION}"

0 commit comments

Comments
 (0)