-
Notifications
You must be signed in to change notification settings - Fork 172
/
CMakeLists.txt
49 lines (40 loc) · 1.4 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4 FATAL_ERROR)
PROJECT(unittest)
INCLUDE(ExternalProject)
# Set default ExternalProject root directory
SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX .)
# Add gtest
ExternalProject_Add(
googletest
URL https://github.com/google/googletest/archive/release-1.7.0.zip
TIMEOUT 30
CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=Release
# Disable install step
INSTALL_COMMAND ""
# Wrap download, configure and build steps in a script to log output
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON)
# Disable dynamic memory allocation in Eigen
ADD_DEFINITIONS(-DEIGEN_NO_MALLOC -DUKF_DOUBLE_PRECISION)
# Specify include dir
ExternalProject_Get_Property(googletest source_dir)
SET(googletest_dir ${source_dir})
INCLUDE_DIRECTORIES(${googletest_dir}/include ../include ${eigen_dir})
# Add test executable target
ADD_EXECUTABLE(unittest
TestStateVector.cpp
TestFixedMeasurementVector.cpp
TestDynamicMeasurementVector.cpp
TestCore.cpp
TestSquareRootCore.cpp)
# Create dependency of test on googletest
ADD_DEPENDENCIES(unittest googletest eigen3)
# Specify test's link libraries
ExternalProject_Get_Property(googletest binary_dir)
TARGET_LINK_LIBRARIES(unittest
${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a
${binary_dir}/${CMAKE_FIND_LIBRARY_PREFIXES}gtest_main.a
pthread)
ADD_TEST(unittest unittest)
ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS unittest)