-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
146 lines (116 loc) · 4.15 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 3.13)
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE DAMC_GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(REGEX REPLACE "^v?([0-9]+\\.[0-9]+(\\.[0-9]+)?).*\$" "\\1" DAMC_GIT_VERSION_TRIMMED ${DAMC_GIT_VERSION})
else()
set(DAMC_GIT_VERSION "unknown-rev")
set(DAMC_GIT_VERSION_TRIMMED "0.0.0")
endif()
project(damc VERSION "${DAMC_GIT_VERSION_TRIMMED}" LANGUAGES C CXX)
# option() honors normal variables
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
# Honor visibility properties for all target types.
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
get_filename_component(BUILD_DIR_NAME ${CMAKE_BINARY_DIR} NAME)
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin/lib")
set(CMAKE_POSITION_INDEPENDENT_CODE True)
set(CMAKE_CXX_STANDARD 17)
option(BUILD_TESTING "Build tests" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type")
find_package(JACK REQUIRED)
if(MINGW)
set(COMPILER_FLAGS "-msse -mfpmath=sse -ffast-math -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS}")
get_filename_component( MINGW_PATH ${CMAKE_CXX_COMPILER} PATH )
macro(list_append_if_exists LIST_NAME FILE_NAME)
if(EXISTS ${FILE_NAME})
list(APPEND ${LIST_NAME} ${FILE_NAME})
endif()
endmacro()
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS)
list_append_if_exists(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${MINGW_PATH}/libgcc_s_dw2-1.dll)
list_append_if_exists(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${MINGW_PATH}/libgcc_s_seh-1.dll)
list_append_if_exists(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${MINGW_PATH}/libgcc_s_sjlj-1.dll)
list_append_if_exists(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${MINGW_PATH}/libstdc++-6.dll)
list_append_if_exists(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS ${MINGW_PATH}/libwinpthread-1.dll)
message( STATUS "Installing system-libraries: ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}" )
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ./)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(COMPILER_FLAGS "-ffast-math -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS}")
endif()
if(UNIX AND NOT APPLE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
endif()
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "deps")
add_subdirectory(deps)
set(CMAKE_C_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "damc")
set(LOG_LEVEL_TRACE 0)
set(LOG_LEVEL_DEBUG 1)
set(LOG_LEVEL_INFO 2)
set(LOG_LEVEL_WARN 3)
set(LOG_LEVEL_ERROR 4)
set(LOG_LEVEL_CRITICAL 5)
set(LOG_LEVEL_OFF 6)
add_compile_definitions(SPDLOG_ACTIVE_LEVEL=${LOG_LEVEL_TRACE})
add_subdirectory(damc_common)
add_subdirectory(damc_audio_processing)
add_subdirectory(damc_server)
add_subdirectory(damc_gui)
install(FILES README.md DESTINATION ./)
# Only install damc_config.json if it is not there already
if(UNIX)
install(
FILES
dist/damc_gui.desktop
dist/damc_server.desktop
DESTINATION ./
)
install(
DIRECTORY dist/systemd
DESTINATION ./
)
elseif(WIN32)
install(
FILES
dist/damc_gui_serial.bat
DESTINATION ./
)
endif()
install(CODE "
if(NOT EXISTS \${CMAKE_INSTALL_PREFIX}/damc_config.json)
file(INSTALL \"${CMAKE_CURRENT_SOURCE_DIR}/dist/damc_config.json\" DESTINATION \"\${CMAKE_INSTALL_PREFIX}/\")
else()
message(STATUS \"Already exists: \${CMAKE_INSTALL_PREFIX}/damc_config.json\")
endif()
")
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "tools")
add_subdirectory(delayControl)
add_subdirectory(binauralSynthesis)
add_subdirectory(osctools)
if(WIN32)
set(CPACK_GENERATOR ZIP)
else()
set(CPACK_GENERATOR TGZ)
endif()
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_STRIP_FILES ON)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_PACKAGE_VERSION ${DAMC_GIT_VERSION})
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
list(REMOVE_ITEM CPACK_COMPONENTS_ALL "deps")
include(CPack)