@@ -11,14 +11,16 @@ if(MINGW)
11
11
endif ()
12
12
13
13
# 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 ()
22
24
23
25
include_directories ("${GTEST_SRC_DIR} " "${GTEST_SRC_DIR} /include" )
24
26
@@ -27,7 +29,7 @@ include_directories("${GTEST_SRC_DIR}" "${GTEST_SRC_DIR}/include")
27
29
add_executable (vmtest testutils.cc sanitytest.cc smallinttest.cc floattest.cc
28
30
atomtest.cc gctest.cc coderstest.cc utftest.cc stringtest.cc
29
31
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} " )
31
33
32
34
if (NOT MINGW)
33
35
target_link_libraries (vmtest pthread)
0 commit comments