Skip to content

Commit cab7cea

Browse files
committed
build: Propagate CMAKE_MSVC_RUNTIME_LIBRARY (#4842)
* Allow CMAKE_MSVC_RUNTIME_LIBRARY to be initialized from an environment variable of the same name. (CMake doesn't do that on its own.) * If set, propagate CMAKE_MSVC_RUNTIME_LIBRARY to any packages we auto-build within our build system. Signed-off-by: Larry Gritz <[email protected]>
1 parent 87b5458 commit cab7cea

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/cmake/compiler.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,17 @@ if (LINKSTATIC)
662662
endif ()
663663

664664

665+
###########################################################################
666+
# Windows: which MSVC runtime library should we use (to override default)?
667+
# Note that all dependencies need the same choice. We leave this as the
668+
# default, but allow it to be set by the environment if not explicit, which
669+
# the built-in CMAKE_MSVC_RUNTIME_LIBRARY does not do on its own.
670+
#
671+
if (WIN32)
672+
set_from_env (CMAKE_MSVC_RUNTIME_LIBRARY)
673+
endif ()
674+
675+
665676
###########################################################################
666677
# Any extra logic to be run only for CI builds goes here.
667678
# We expect our own CI runs to define env variable ${PROJECT_NAME}_CI

src/cmake/dependency_utils.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,11 @@ macro (build_dependency_with_cmake pkgname)
626626
list(APPEND _pkg_CMAKE_ARGS "-DCMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH_ESCAPED}")
627627
endif()
628628

629+
# Pass along any CMAKE_MSVC_RUNTIME_LIBRARY
630+
if (WIN32 AND CMAKE_MSVC_RUNTIME_LIBRARY)
631+
list (APPEND _pkg_CMAKE_ARGS -DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY})
632+
endif ()
633+
629634
execute_process (COMMAND
630635
${CMAKE_COMMAND}
631636
# Put things in our special local build areas

0 commit comments

Comments
 (0)