-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
60 lines (47 loc) · 1.75 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
57
58
59
60
cmake_minimum_required(VERSION 3.5.2)
project(poincare)
# The version number.
set (poincare_VERSION_MAJOR 0)
set (poincare_VERSION_MINOR 1)
include_directories(src)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()
set(CMAKE_CXX_FLAGS_RELEASE " -pthread -std=c++11 -funroll-loops -Ofast")
set(CMAKE_CXX_FLAGS_DEBUG " -pthread -std=c++11 -g -O0 -fno-inline -Wfatal-errors")
set(HEADER_FILES
src/args.h
src/digraph.h
src/sampler.h
src/poincare.h
src/model.h
src/real.h
src/vector.h)
set(SOURCE_FILES
src/args.cc
src/digraph.cc
src/sampler.cc
src/poincare.cc
src/main.cc
src/model.cc
src/vector.cc)
# Compile static library from source files
add_library(poincare-static STATIC ${SOURCE_FILES} ${HEADER_FILES})
set_target_properties(poincare-static PROPERTIES OUTPUT_NAME poincare)
# Make executable
add_executable(poincare-bin src/main.cc)
target_link_libraries(poincare-bin pthread poincare-static)
set_target_properties(poincare-bin PROPERTIES PUBLIC_HEADER "${HEADER_FILES}" OUTPUT_NAME poincare)
# ----------
# Unit tests
# ----------
# Add the GoogleTest repository as a subproject
add_subdirectory(googletest)
# Get all files from the /test directory that match *_test.cc
FILE(GLOB TEST_FILES test/*_test.cc)
# Add a build project 'unit-tests' built from all the test files
add_executable(unit-tests googletest/src/gtest_main.cc ${TEST_FILES})
# Link with library and add header files
target_link_libraries(unit-tests pthread gtest poincare-static)
set_target_properties(unit-tests PROPERTIES PUBLIC_HEADER "${HEADER_FILES}" OUTPUT_NAME run_tests)