Skip to content

Commit

Permalink
Force shared CRT on Windows if building tests and Shaderc
Browse files Browse the repository at this point in the history
Change-Id: I7a34d4409466fe3a823c69bb240784687d2a678a
  • Loading branch information
dneto0 committed Dec 23, 2024
1 parent c5140f5 commit b06a337
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b06a337

Please sign in to comment.