-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
118 lines (93 loc) · 3.04 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#
# Initial CMake and project setup
#
# Required CMake version (ExternalProject)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
set(PROJECT_NAME Khronos)
project(${PROJECT_NAME})
include(ExternalProject)
# Set software version
set(APPLICATION_VERSION_MAJOR "0")
set(APPLICATION_VERSION_MINOR "5")
set(APPLICATION_VERSION_PATCH "0")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set_directory_properties(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/build-data)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#
# Options
#
option(BUILD_TESTS "Build tests" OFF)
option(DEBUG "Debug program" OFF)
#
# Setup compiler flags
#
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE CACHE Release FORCE)
endif()
if (DEBUG)
add_definitions(-DDEBUG=1)
endif()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0 --coverage -pedantic -Wall -Wextra -Wconversion -Wfloat-equal -Wformat=2 -Winit-self -Winline -Winvalid-pch -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wstack-protector -Wstrict-null-sentinel -Wswitch-default -Wswitch-enum -Wno-unused-parameter -Wctor-dtor-privacy"
)
#
# Find Doxygen for documentation
#
# add a target to generate API documentation with Doxygen
find_package(Doxygen)
if (DOXYGEN_FOUND)
add_custom_target(DOC
${DOXYGEN_EXECUTABLE} ${CMAKE_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
endif ()
#
# Find/install dependencies
#
if (WIN32)
include(${CMAKE_MODULE_PATH}/Win32-ExternalProjects.txt)
else (UNIX)
include(${CMAKE_MODULE_PATH}/Unix-ExternalProjects.txt)
endif ()
#
# Final project settings
#
include_directories(include)
add_subdirectory(src)
add_executable(${PROJECT_NAME}
$<TARGET_OBJECTS:audio>
$<TARGET_OBJECTS:util>
$<TARGET_OBJECTS:main>
)
target_compile_features(${PROJECT_NAME} PRIVATE c_restrict)
target_link_libraries(${PROJECT_NAME} ${LIBS})
if (DEPENDENCIES)
message(STATUS "Any missing dependencies will be downloaded upon running \"make\"")
add_dependencies(${PROJECT_NAME} ${DEPENDENCIES})
endif ()
#
# Testing
#
if(BUILD_TESTS)
include(CTest)
enable_testing()
set(util_test_SOURCES test/test_util)
add_executable(util_test ${util_test_SOURCES}
$<TARGET_OBJECTS:util>
)
target_compile_features(util_test PRIVATE c_restrict)
add_test (util_test util_test)
set(audio_test_SOURCES test/test_audio)
add_executable(audio_test ${audio_test_SOURCES}
$<TARGET_OBJECTS:audio>
)
target_compile_features(audio_test PRIVATE c_restrict)
target_link_libraries(audio_test ${LIBS})
add_test (audio_test audio_test)
endif()