Skip to content

Commit d5d0cde

Browse files
authored
[CI] Various build improvements (#605)
* [CI] Upgrade GoogleTest * Set MSVC_RUNTIME_LIBRARY per target * Set MSVC_RUNTIME_LIBRARY only for MSVC * Fix
1 parent bf28a14 commit d5d0cde

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ SET(ENABLED_SANITIZERS "address" "leak" "undefined" CACHE STRING
4949
if(MSVC)
5050
if(Treelite_USE_DYNAMIC_MSVC_RUNTIME)
5151
message(STATUS "Using dynamically linked MSVC runtime...")
52-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
52+
set(Treelite_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
5353
else()
5454
message(STATUS "Using statically linked MSVC runtime...")
55-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
55+
set(Treelite_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
5656
endif()
57+
set(CMAKE_MSVC_RUNTIME_LIBRARY "${Treelite_MSVC_RUNTIME_LIBRARY}")
5758
endif()
5859

5960
if(USE_SANITIZER)
@@ -111,6 +112,10 @@ endif()
111112

112113
foreach(lib ${TREELITE_TARGETS})
113114
set_output_directory(${lib} ${PROJECT_BINARY_DIR})
115+
if(MSVC)
116+
set_target_properties(${lib} PROPERTIES
117+
MSVC_RUNTIME_LIBRARY "${Treelite_MSVC_RUNTIME_LIBRARY}")
118+
endif()
114119
endforeach()
115120

116121
# Export install targets

cmake/ExternalLibs.cmake

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,27 @@ endif()
6060

6161
# Google C++ tests
6262
if(BUILD_CPP_TEST)
63-
find_package(GTest 1.11.0)
63+
find_package(GTest 1.14.0)
6464
if(NOT GTest_FOUND)
6565
message(STATUS "Did not find Google Test in the system root. Fetching Google Test now...")
6666
FetchContent_Declare(
6767
googletest
68-
GIT_REPOSITORY https://github.com/google/googletest.git
69-
GIT_TAG release-1.11.0
68+
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
7069
)
70+
set(gtest_force_shared_crt ${DMLC_FORCE_SHARED_CRT} CACHE BOOL "" FORCE)
7171
FetchContent_MakeAvailable(googletest)
72+
7273
add_library(GTest::gtest ALIAS gtest)
7374
add_library(GTest::gmock ALIAS gmock)
75+
target_compile_definitions(gtest PRIVATE ${ENABLE_GNU_EXTENSION_FLAGS})
76+
target_compile_definitions(gmock PRIVATE ${ENABLE_GNU_EXTENSION_FLAGS})
77+
foreach(target gtest gmock)
78+
target_compile_features(${target} PUBLIC cxx_std_14)
79+
if(MSVC)
80+
set_target_properties(${target} PROPERTIES
81+
MSVC_RUNTIME_LIBRARY "${Treelite_MSVC_RUNTIME_LIBRARY}")
82+
endif()
83+
endforeach()
7484
if(IS_DIRECTORY "${googletest_SOURCE_DIR}")
7585
# Do not install gtest
7686
set_property(DIRECTORY ${googletest_SOURCE_DIR} PROPERTY EXCLUDE_FROM_ALL YES)

0 commit comments

Comments
 (0)