Skip to content

Commit 5928872

Browse files
committed
build: enhance CMakeLists for MSVC and test linking
- Updated MSVC runtime library setting to support both Debug and Release configurations. - Added specific compiler flags for Release and Debug builds. - Included gmock and gmock_main in the test executable linking to ensure comprehensive testing capabilities.
1 parent 9f7e37c commit 5928872

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/unittest/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
message(STATUS "MSVC value: ${MSVC}")
22
if (MSVC)
3-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
3+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
44
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
55
add_compile_options(/utf-8)
6+
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
7+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
68
endif()
79

810
include(FetchContent)
@@ -40,7 +42,7 @@ ADD_EXECUTABLE(test.run
4042
textrank_test.cpp
4143
)
4244

43-
TARGET_LINK_LIBRARIES(test.run gtest gtest_main)
45+
TARGET_LINK_LIBRARIES(test.run gtest gtest_main gmock gmock_main)
4446

4547
enable_testing()
4648
ADD_TEST(NAME test.run COMMAND test.run)

0 commit comments

Comments
 (0)