-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
65 lines (54 loc) · 2.07 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
61
62
63
64
cmake_minimum_required(VERSION 2.8)
project(turtle)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
#include(GetGitRevisionDescription)
#git_describe(GIT_VERSION "--dirty")
# build output directory for binaries
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# setup install directory paths
set(OUTPUT_BIN_DIR ${PROJECT_SOURCE_DIR}/output/bin)
set(OUTPUT_LIB_DIR ${PROJECT_SOURCE_DIR}/output/lib)
set(OUTPUT_INC_DIR ${PROJECT_SOURCE_DIR}/output/include/${CMAKE_PROJECT_NAME})
# setup compiler flags
set(C_COMMON_FLAGS "-mtune=native -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wno-missing-braces")
set(C_DEBUG_FLAGS "-g -std=gnu99 -O0 ${C_COMMON_FLAGS}")
set(C_RELEASE_FLAGS "-g -std=gnu99 -O3 -ffast-math ${C_COMMON_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${C_DEBUG_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${C_RELEASE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS_DEBUG}")
#add_definitions("-DGIT_VERSION=${GIT_VERSION}")
# run tests but also show terminal output
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
macro(add_sources)
file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}")
foreach (_src ${ARGN})
if (_relPath)
list (APPEND SRCS "${_relPath}/${_src}")
else()
list (APPEND SRCS "${_src}")
endif()
endforeach()
if (_relPath)
# propagate SRCS to parent directory
set (SRCS ${SRCS} PARENT_SCOPE)
endif()
endmacro()
macro(add_includes)
file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}")
foreach (_src ${ARGN})
if (_relPath)
list (APPEND INCLUDES "${_relPath}/${_src}")
else()
list (APPEND INCLUDES "${_src}")
endif()
endforeach()
if (_relPath)
# propagate INCLUDES to parent directory
set (INCLUDES ${INCLUDES} PARENT_SCOPE)
endif()
endmacro()
enable_testing()
add_subdirectory(deps)
add_subdirectory(src)
add_subdirectory(tests)