-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
49 lines (35 loc) · 1.14 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 FATAL_ERROR)
# Call cmake with -D TESTS=ON to set this flag to true.
option(TESTS "build tests" OFF)
project(sample_project CXX C)
# Core and main are split. This allows us to link core to main and tests.
# Core library. *.cpp should be added here.
add_library(core
./src/core.cpp)
# Main entry point.
add_executable(main
./src/main.cpp)
# Link core to main.
target_link_libraries(main
core)
# Add flags.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
if(TESTS)
enable_testing()
# Process the CMakeLists.txt in third-party/googletest, sets project(gtest) and
# project(gmock), gives access to ${gtest_SOURCE_DIR} and ${gmock_SOURCE_DIR}.
add_subdirectory(third-party/googletest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include_directories(${gmock_SOURCE_DIR}/include ${gmock_SOURCE_DIR})
# Tests. *-test.cpp should be added here.
add_executable(tests
./test/main-test.cpp
./test/function-test.cpp
./test/class-test.cpp)
# Link core, pthread and gtest to tests.
target_link_libraries(tests
pthread
gtest
gtest_main
core)
endif()