forked from compAIR/libcreate
Remove external cmake project for gtest
Now only build tests if a gtest installation already exists on the system. This should expedite time to build for users that do not care about building/running unit tests and also eliminates the need for internet access when building.
This commit is contained in:
parent
ec61febe20
commit
08da39e16e
3 changed files with 10 additions and 50 deletions
|
@ -157,40 +157,15 @@ install(
|
||||||
###########
|
###########
|
||||||
|
|
||||||
if(LIBCREATE_BUILD_TESTS)
|
if(LIBCREATE_BUILD_TESTS)
|
||||||
|
find_package(GTest)
|
||||||
|
include_directories(${GTEST_INCLUDE_DIRS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LIBCREATE_BUILD_TESTS AND ${GTEST_FOUND})
|
||||||
|
message("GTest installation found. Building tests.")
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
# Download and unpack googletest at configure time
|
|
||||||
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
|
||||||
RESULT_VARIABLE GTEST_DOWNLOAD_RESULT
|
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download
|
|
||||||
)
|
|
||||||
|
|
||||||
if(GTEST_DOWNLOAD_RESULT)
|
|
||||||
message(FATAL_ERROR "CMake step for googletest failed: ${GTEST_DOWNLOAD_RESULT}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Build googletest
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
|
||||||
RESULT_VARIABLE GTEST_BUILD_RESULT
|
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download
|
|
||||||
)
|
|
||||||
|
|
||||||
if(GTEST_BUILD_RESULT)
|
|
||||||
message(FATAL_ERROR "Build step for googletest failed: ${GTEST_BUILD_RESULT}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Add googletest directly to our build. This defines the gtest and gtest_main targets.
|
|
||||||
add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
|
|
||||||
${CMAKE_BINARY_DIR}/googletest-build)
|
|
||||||
|
|
||||||
# The gtest/gtest_main targets carry header search path
|
|
||||||
# dependencies automatically when using CMake 2.8.11 or
|
|
||||||
# later. Otherwise we have to add them here ourselves.
|
|
||||||
if (CMAKE_VERSION VERSION_LESS 2.8.11)
|
|
||||||
include_directories("${gtest_SOURCE_DIR}/include")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Add tests
|
# Add tests
|
||||||
set(LIBCREATE_TESTS
|
set(LIBCREATE_TESTS
|
||||||
test_create
|
test_create
|
||||||
|
@ -205,8 +180,8 @@ if(LIBCREATE_BUILD_TESTS)
|
||||||
add_executable(${LIBCREATE_TEST} tests/${LIBCREATE_TEST}.cpp)
|
add_executable(${LIBCREATE_TEST} tests/${LIBCREATE_TEST}.cpp)
|
||||||
|
|
||||||
target_link_libraries(${LIBCREATE_TEST}
|
target_link_libraries(${LIBCREATE_TEST}
|
||||||
# ${Boost_LIBRARIES}
|
|
||||||
${LIBRARY_NAME}
|
${LIBRARY_NAME}
|
||||||
|
${GTEST_LIBRARIES}
|
||||||
gtest_main
|
gtest_main
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -215,4 +190,6 @@ if(LIBCREATE_BUILD_TESTS)
|
||||||
COMMAND ${LIBCREATE_TEST}
|
COMMAND ${LIBCREATE_TEST}
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
else()
|
||||||
|
message("No GTest installation found. Skipping tests.")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
cmake_minimum_required(VERSION 2.8.2)
|
|
||||||
|
|
||||||
project(googletest-download NONE)
|
|
||||||
|
|
||||||
include(ExternalProject)
|
|
||||||
ExternalProject_Add(googletest
|
|
||||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
|
||||||
GIT_TAG master
|
|
||||||
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src"
|
|
||||||
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build"
|
|
||||||
CONFIGURE_COMMAND ""
|
|
||||||
BUILD_COMMAND ""
|
|
||||||
INSTALL_COMMAND ""
|
|
||||||
TEST_COMMAND ""
|
|
||||||
)
|
|
|
@ -16,8 +16,6 @@
|
||||||
|
|
||||||
<buildtool_depend>cmake</buildtool_depend>
|
<buildtool_depend>cmake</buildtool_depend>
|
||||||
|
|
||||||
<build_depend>git</build_depend>
|
|
||||||
|
|
||||||
<depend>boost</depend>
|
<depend>boost</depend>
|
||||||
|
|
||||||
<exec_depend>catkin</exec_depend>
|
<exec_depend>catkin</exec_depend>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue