Commit 5cf9a211 authored by Philip Quinn's avatar Philip Quinn

Use CMake's ExternalProject to fetch and build googletest.

parent 568d8e2c
......@@ -7,13 +7,4 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-parameter -std=c++11")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gtest" AND IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/gtest")
add_subdirectory(gtest)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/gtest/include)
else()
message(FATAL_ERROR "Please use setup-cmake.sh to download gtest before running the cmake build")
endif()
include(CTest)
add_subdirectory(src)
#! /usr/bin/env bash
set -euo pipefail
if [ ! -e gtest ]; then
echo "================================================================================"
echo "Fetching Google Test code..."
echo "================================================================================"
svn checkout http://googletest.googlecode.com/svn/tags/release-1.7.0 gtest
fi
echo "================================================================================"
echo "Done"
echo "================================================================================"
echo
echo "Ready to run cmake (no support for installing yet). For example:"
echo " mkdir build && cd build && cmake .. -G 'Unix Makefiles' && make -j6 check"
......@@ -82,6 +82,34 @@ add_executable(capnpc_cpp
target_link_libraries(capnpc_cpp capnp kj)
set_target_properties(capnpc_cpp PROPERTIES OUTPUT_NAME capnpc-c++)
# Tests ==============================================================
# Setup googletest build and library targets (gtest and gtest_main)
include(ExternalProject)
ExternalProject_Add(gtest_build
URL http://googletest.googlecode.com/files/gtest-1.7.0.zip
URL_HASH SHA1=f85f6d2481e2c6c4a18539e391aa4ea8ab0394af
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
INSTALL_COMMAND "" # Disable install
)
ExternalProject_Get_Property(gtest_build binary_dir)
add_library(gtest UNKNOWN IMPORTED)
set_property(TARGET gtest
PROPERTY IMPORTED_LOCATION ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a
)
add_dependencies(gtest gtest_build)
add_library(gtest_main UNKNOWN IMPORTED)
set_property(TARGET gtest_main
PROPERTY IMPORTED_LOCATION ${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a
)
add_dependencies(gtest_main gtest)
ExternalProject_Get_Property(gtest_build source_dir)
include_directories(${source_dir}/include)
set(test_capnp_files
capnp/test.capnp
capnp/test-import.capnp
......@@ -186,6 +214,7 @@ target_link_libraries(capnp-evolution-tests
gtest_main
)
include(CTest)
add_test(NAME capnp-tests-run COMMAND capnp-tests)
add_test(NAME capnp-evolution-tests-run COMMAND capnp-evolution-tests)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment