-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
82 lines (70 loc) · 3.02 KB
/
CMakeLists.txt
File metadata and controls
82 lines (70 loc) · 3.02 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
cmake_minimum_required(VERSION 3.2)
project(prot-3)
# Build environment setup (for GNU G++): -----------------------------------------------------------
set(CMAKE_CXX_STANDARD 11) # C++11 Standard.
set(CMAKE_CXX_STANDARD_REQUIRED ON) # Force required standard.
set(CMAKE_CXX_EXTENSIONS ON) # Enable compiler extensions (gnu++11).
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-reorder -O2 -pthread -fopenmp")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
# Package dependencies: ----------------------------------------------------------------------------
find_package(SFML 2.3 REQUIRED graphics window system)
if(SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
link_libraries(${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
endif()
# -- Matlab:
# find_package(Matlab REQUIRED)
# include_directories(SYSTEM ${Matlab_INCLUDE_DIRS})
# link_libraries(${Matlab_LIBRARIES})
# -- GNU Scientific Library:
find_package(GSL REQUIRED)
include_directories(SYSTEM ${GSL_INCLUDE_DIRS})
link_libraries(${GSL_LIBRARIES})
# -- YAML C++:
find_package(yaml-cpp 0.5.2 REQUIRED)
# NOTE: The line below causes error in compilation (headers not found) and may not be necessary
# if YAML-CPP has been installed from packages (libyaml-cpp-dev).
# include_directories(SYSTEM ${YAML_CPP_INCLUDE_DIR})
link_libraries(${YAML_CPP_LIBRARIES})
# -- GoogleTest
find_package(GTest)
if(GTEST_FOUND)
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
link_libraries(${GTEST_BOTH_LIBRARIES})
enable_testing()
set(COVERAGE_CFLAGS "-ftest-coverage -fprofile-arcs -fno-inline -fno-inline-small-functions -fno-default-inline")
set(COVERAGE_LDFLAGS "-lgcov --coverage")
else()
message(STATUS "(!) GoogleTest has not been found, tests can not be run.")
endif()
# Project's header locations: ----------------------------------------------------------------------
file(GLOB_RECURSE headers_list "*.hpp")
set(global_include_dirs "")
foreach(hfile ${headers_list})
get_filename_component(hdir ${hfile} DIRECTORY)
list(APPEND global_include_dirs ${hdir})
endforeach()
list(REMOVE_DUPLICATES global_include_dirs)
include_directories(${global_include_dirs}) # Adds all the folders with headers insdide.)
# Project's source files to compile: ---------------------------------------------------------------
add_subdirectory(src)
# Add all GoogleTest tests: ------------------------------------------------------------------------
if(GTEST_FOUND)
add_subdirectory(test)
endif()
# Project's executable (and main file): ------------------------------------------------------------
add_executable(prot-3 main.cpp)
target_link_libraries(prot-3
model
graphics
common
scheduler
)
set_target_properties(prot-3
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/../bin"
COMPILE_FLAGS "${COVERAGE_CFLAGS}"
LINK_FLAGS "${COVERAGE_LDFLAGS}"
)