-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCMakeLists.txt
56 lines (48 loc) · 2 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
50
51
52
53
54
55
56
cmake_minimum_required(VERSION 2.8)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
# Enable ExternalProject CMake module
include(ExternalProject)
# Download and install GoogleTest
ExternalProject_Add(
gtest
GIT_REPOSITORY https://github.com/google/googletest.git
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/googletest
# Disable install step
INSTALL_COMMAND ""
)
# Create a libgtest target to be used as a dependency by test programs
add_library(libgtest IMPORTED STATIC GLOBAL)
add_dependencies(libgtest gtest)
# Set gtest properties
ExternalProject_Get_Property(gtest source_dir binary_dir)
set_target_properties(libgtest PROPERTIES
"IMPORTED_LOCATION" "${binary_dir}/libgtest.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
# "INTERFACE_INCLUDE_DIRECTORIES" "${source_dir}/include"
)
# I couldn't make it work with INTERFACE_INCLUDE_DIRECTORIES
#include_directories("${source_dir}/include")
include_directories(SYSTEM
${CMAKE_CURRENT_BINARY_DIR}/googletest/src/gtest/googletest/include)
include_directories(SYSTEM
${CMAKE_CURRENT_BINARY_DIR}/googletest/src/gtest/googlemock/include)
# Set gmock properties
# I couldn't make it work with INTERFACE_INCLUDE_DIRECTORIES
include_directories("${source_dir}/include")
add_library(libgmock IMPORTED STATIC GLOBAL)
file(GLOB SRCS *.cpp *.h)
add_executable(bletest ${SRCS} unit_tests/tst_BLEParser.cpp)
set_property(TARGET bletest PROPERTY CXX_STANDARD 11)
set_target_properties(libgmock PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_BINARY_DIR}/googletest/src/gtest-build/googlemock/libgmock.a)
set_target_properties(libgtest PROPERTIES IMPORTED_LOCATION
${CMAKE_CURRENT_BINARY_DIR}/googletest/src/gtest-build/googlemock/gtest/libgtest.a)
target_link_libraries(bletest
libgtest
libgmock
)
IF(CMAKE_SYSTEM_NAME STREQUAL Linux)
set_target_properties(bletest PROPERTIES COMPILE_FLAGS -pthread LINK_FLAGS -pthread)
ENDIF(CMAKE_SYSTEM_NAME STREQUAL Linux)
install(TARGETS bletest DESTINATION bin)