Skip to content

Commit b65cefc

Browse files
committed
Allow shared gtest library.
1 parent bdeaf6c commit b65cefc

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

vm/vm/test/CMakeLists.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ if(MINGW)
1111
endif()
1212

1313
# GTest libraries
14-
15-
add_library(custom_gtest STATIC IMPORTED)
16-
set_property(TARGET custom_gtest PROPERTY
17-
IMPORTED_LOCATION "${GTEST_BUILD_DIR}/libgtest.a")
18-
19-
add_library(custom_gtest_main STATIC IMPORTED)
20-
set_property(TARGET custom_gtest_main PROPERTY
21-
IMPORTED_LOCATION "${GTEST_BUILD_DIR}/libgtest_main.a")
14+
# Allow to use shared libraries, but prefer static ones when possible
15+
# to avoid missing libraries at execution time.
16+
find_library(GTEST_LIBRARY NAME gtest.a gtest.lib gtest PATHS "${GTEST_BUILD_DIR}")
17+
find_library(GTEST_MAIN_LIBRARY NAME gtest_main.a gtest_main.lib gtest_main PATHS "${GTEST_BUILD_DIR}")
18+
if("${GTEST_LIBRARY}" MATCHES "GTEST_LIBRARY-NOTFOUND")
19+
message(FATAL_ERROR "Could not find gtest library in ${GTEST_BUILD_DIR}")
20+
endif()
21+
if("${GTEST_MAIN_LIBRARY}" MATCHES "GTEST_MAIN_LIBRARY-NOTFOUND")
22+
message(FATAL_ERROR "Could not find gtest_main library in ${GTEST_BUILD_DIR}")
23+
endif()
2224

2325
include_directories("${GTEST_SRC_DIR}" "${GTEST_SRC_DIR}/include")
2426

@@ -27,7 +29,7 @@ include_directories("${GTEST_SRC_DIR}" "${GTEST_SRC_DIR}/include")
2729
add_executable(vmtest testutils.cc sanitytest.cc smallinttest.cc floattest.cc
2830
atomtest.cc gctest.cc coderstest.cc utftest.cc stringtest.cc
2931
virtualstringtest.cc bytestringtest.cc)
30-
target_link_libraries(vmtest mozartvm custom_gtest custom_gtest_main)
32+
target_link_libraries(vmtest mozartvm "${GTEST_LIBRARY}" "${GTEST_MAIN_LIBRARY}")
3133

3234
if(NOT MINGW)
3335
target_link_libraries(vmtest pthread)

0 commit comments

Comments
 (0)