Skip to content

Commit

Permalink
Also check if gtest exists before calling add_library()
Browse files Browse the repository at this point in the history
  • Loading branch information
ojura authored Mar 21, 2018
1 parent d6793e9 commit 54fdf04
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmake/test/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,14 @@ if(NOT GMOCK_FOUND)
endif()
else()
message(STATUS "Found gtest: gtests will be built")
add_library(gtest SHARED IMPORTED)
set_target_properties(gtest PROPERTIES IMPORTED_LOCATION "${GTEST_LIBRARIES}")
add_library(gtest_main SHARED IMPORTED)
set_target_properties(gtest_main PROPERTIES IMPORTED_LOCATION "${GTEST_MAIN_LIBRARIES}")
if(NOT TARGET gtest)
add_library(gtest SHARED IMPORTED)
set_target_properties(gtest PROPERTIES IMPORTED_LOCATION "${GTEST_LIBRARIES}")
endif()
if(NOT TARGET gtest_main)
add_library(gtest_main SHARED IMPORTED)
set_target_properties(gtest_main PROPERTIES IMPORTED_LOCATION "${GTEST_MAIN_LIBRARIES}")
endif()
set(GTEST_FOUND ${GTEST_FOUND} CACHE INTERNAL "")
set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS} CACHE INTERNAL "")
set(GTEST_LIBRARIES ${GTEST_LIBRARIES} CACHE INTERNAL "")
Expand Down

0 comments on commit 54fdf04

Please sign in to comment.