CMakeLists.txt requires Gtest while testing

use debug postfix like boost does
This commit is contained in:
Claus Klein 2018-03-11 15:07:08 +01:00
parent 0170a45f40
commit b3ee613ad2
1 changed files with 30 additions and 40 deletions

View File

@ -50,17 +50,6 @@ check_symbol_exists("sysconf" "unistd.h" HAVE_FUNC_SYSCONF)
# set debug postfix a la boost
set(CMAKE_DEBUG_POSTFIX "-d")
if(SNAPPY_BUILD_TESTS)
find_package(GTest)
if(GTEST_FOUND)
set(HAVE_GTEST 1)
endif(GTEST_FOUND)
find_package(Gflags)
if(GFLAGS_FOUND)
set(HAVE_GFLAGS 1)
endif(GFLAGS_FOUND)
endif(SNAPPY_BUILD_TESTS)
configure_file(
"${PROJECT_SOURCE_DIR}/cmake/config.h.in"
@ -123,8 +112,11 @@ if(BUILD_SHARED_LIBS)
set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif(BUILD_SHARED_LIBS)
if(GTEST_FOUND OR GFLAGS_FOUND)
if(SNAPPY_BUILD_TESTS)
if(SNAPPY_BUILD_TESTS)
find_package(GTest REQUIRED)
find_package(Gflags)
find_package(Threads)
enable_testing()
add_executable(snappy_unittest "")
@ -134,13 +126,13 @@ if(GTEST_FOUND OR GFLAGS_FOUND)
"${PROJECT_SOURCE_DIR}/snappy-test.cc"
)
target_compile_definitions(snappy_unittest PRIVATE -DHAVE_CONFIG_H)
target_link_libraries(snappy_unittest snappy ${GFLAGS_LIBRARIES} ${GTEST_LIBRARIES})
target_link_libraries(snappy_unittest snappy ${GFLAGS_LIBRARIES} ${GTEST_LIBRARIES} ${THREADS_LIBRARIES})
if(HAVE_LIBZ)
target_link_libraries(snappy_unittest z)
endif(HAVE_LIBZ)
if(HAVE_LIBLZO2)
target_link_libraries(snappy_unittest lzo2.a)
target_link_libraries(snappy_unittest lzo2)
endif(HAVE_LIBLZO2)
target_include_directories(snappy_unittest
@ -154,9 +146,7 @@ if(GTEST_FOUND OR GFLAGS_FOUND)
NAME snappy_unittest
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest")
endif(SNAPPY_BUILD_TESTS)
endif(GTEST_FOUND OR GFLAGS_FOUND)
endif(SNAPPY_BUILD_TESTS)
include(GNUInstallDirs)
install(TARGETS snappy