From b06a3375b83b3d13ed53851d1be0789cea4bab8a Mon Sep 17 00:00:00 2001 From: David Neto Date: Mon, 23 Dec 2024 16:54:27 -0500 Subject: [PATCH] Force shared CRT on Windows if building tests and Shaderc Change-Id: I7a34d4409466fe3a823c69bb240784687d2a678a --- CMakeLists.txt | 23 +++++++++++++++-------- third_party/CMakeLists.txt | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03df2429..cd83ee4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,14 +59,6 @@ endif() set(CMAKE_CXX_STANDARD 17) -if(WIN32) - # On Windows, CMake by default compiles with the shared CRT. - # Default it to the static CRT. - option(AMBER_ENABLE_SHARED_CRT - "Amber: Use the shared CRT with MSVC instead of the static CRT" - ${AMBER_ENABLE_SHARED_CRT}) -endif(WIN32) - if (${AMBER_SKIP_SPIRV_TOOLS}) set(AMBER_ENABLE_SPIRV_TOOLS FALSE) set(AMBER_ENABLE_SHADERC FALSE) @@ -120,6 +112,21 @@ if (${AMBER_USE_CLSPV} OR ${AMBER_ENABLE_SWIFTSHADER}) enable_language(ASM) endif() +if(WIN32 AND ${AMBER_ENABLE_SHADERC} AND ${AMBER_ENABLE_TESTS}) + set(__enable_shared_crt_default ON) +else() + set(__enable_shared_crt_default ${AMBER_ENABLE_SHARED_CRT}) +endif() + +if(WIN32) + # On Windows, CMake by default compiles with the shared CRT. + # Default it to the static CRT. + option(AMBER_ENABLE_SHARED_CRT + "Amber: Use the shared CRT with MSVC instead of the static CRT" + ${AMBER_ENABLE_SHARED_CRT}) +endif(WIN32) + + message(STATUS "Using python3") find_package(Python3 REQUIRED) diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index eb951008..4b8af769 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -14,7 +14,7 @@ if (${AMBER_ENABLE_TESTS}) if (${AMBER_ENABLE_SHARED_CRT}) - set(gtest_force_shared_crt ON) + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) endif() add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/googletest EXCLUDE_FROM_ALL) endif()