-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
181 lines (156 loc) · 5.19 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
cmake_minimum_required(VERSION 3.6)
project(pd-visualization VERSION 0.1 LANGUAGES C CXX)
set(STATIC_LINK_DEFAULT OFF)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(STATIC_LINK_DEFAULT ON)
endif()
option(USE_FFTW "Use FFTW" ON)
option(USE_STATIC_FLTK "Use static FLTK" "${STATIC_LINK_DEFAULT}")
option(USE_STATIC_FFTW "Use static FFTW" "${STATIC_LINK_DEFAULT}")
option(LINK_STATICALLY "Use static linking" "${STATIC_LINK_DEFAULT}")
option(USE_LIBCXX "Use libc++" OFF)
if(USE_LIBCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
include(FindPkgConfig)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(GNUWarnings)
include(PdExternal)
include(Require)
include(StaticLinking)
set_gnu_warning("all")
set_gnu_warning("no-unused-local-typedefs")
set(FLTK_SKIP_OPENGL TRUE)
set(FLTK_SKIP_FORMS TRUE)
set(FLTK_SKIP_IMAGES TRUE)
set(FLTK_SKIP_FLUID TRUE)
find_package(Threads REQUIRED)
find_package(FLTK REQUIRED)
if(USE_STATIC_FLTK OR LINK_STATICALLY)
find_package(StaticFLTK REQUIRED)
set(PROJECT_FLTK_LIBRARIES "${StaticFLTK_LIBRARIES}")
else()
set(PROJECT_FLTK_LIBRARIES "${FLTK_LIBRARIES}")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(X11 REQUIRED)
require_library(FONTCONFIG_LIBRARY "fontconfig")
set(PROJECT_FLTK_LIBRARIES "${PROJECT_FLTK_LIBRARIES}"
${X11_Xrender_LIB} ${X11_Xcursor_LIB} ${X11_Xfixes_LIB} ${X11_Xext_LIB} ${X11_Xft_LIB} ${X11_Xinerama_LIB}
${FONTCONFIG_LIBRARY}
dl)
endif()
link_directories(${FLTK_LIBRARY_DIRS})
if(USE_FFTW)
require_path(FFTW3F_INCLUDE_DIR "fftw3.h")
require_library(FFTW3F_LIBRARY "fftw3f")
if(USE_STATIC_FFTW OR LINK_STATICALLY)
require_static_library(StaticFFTW3F_LIBRARY "fftw3f")
set(PROJECT_FFTW3F_LIBRARIES "${StaticFFTW3F_LIBRARY}")
else()
set(PROJECT_FFTW3F_LIBRARIES "${FFTW3F_LIBRARY}")
endif()
endif()
set(CMAKE_CXX_STANDARD "14")
add_definitions("-D__STDC_FORMAT_MACROS=1")
set(visu_names "wfvisu~" "ogvisu~" "sgvisu~" "tfvisu~")
set(visu_common_SOURCES
src/visu~.cc
src/visu~-remote.cc
src/util/self_path.cc)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(visu_common_SOURCES ${visu_common_SOURCES}
src/util/win32_argv.cc
src/util/win32_socketpair.cc)
endif()
add_library(visu_common STATIC ${visu_common_SOURCES})
target_include_directories(visu_common
PUBLIC src
PUBLIC "${PD_INCLUDE_DIR}")
target_link_libraries(visu_common
PUBLIC ${PD_LIBRARIES} PUBLIC ${CMAKE_THREAD_LIBS_INIT})
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
target_link_libraries(visu_common
PUBLIC dl)
endif()
set_target_properties(visu_common PROPERTIES
POSITION_INDEPENDENT_CODE TRUE)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
target_link_libraries(visu_common PUBLIC ws2_32 shlwapi)
endif()
add_pd_external(wfvisu_tilde "wfvisu~" src/wfvisu~.cc)
target_link_libraries(wfvisu_tilde visu_common)
add_pd_external(ogvisu_tilde "ogvisu~" src/ogvisu~.cc)
target_link_libraries(ogvisu_tilde visu_common)
add_pd_external(sgvisu_tilde "sgvisu~" src/sgvisu~.cc)
target_link_libraries(sgvisu_tilde visu_common)
add_pd_external(tfvisu_tilde "tfvisu~" src/tfvisu~.cc)
target_link_libraries(tfvisu_tilde visu_common)
###
add_library(Fl_Knob STATIC
thirdparty/Fl_Knob/Fl_Knob/Fl_Knob.cxx)
target_include_directories(Fl_Knob
PUBLIC thirdparty/Fl_Knob
PUBLIC "${FLTK_INCLUDE_DIR}")
target_link_libraries(Fl_Knob ${PROJECT_FLTK_LIBRARIES})
set(visu_gui_SOURCES
src/visu~-gui.cc
src/gui/w_dft_spectrogram.cc
src/gui/w_dft_waterfall.cc
src/gui/w_dft_transfer.cc
src/gui/w_ts_oscillogram.cc
src/gui/fl_widgets_ex.cc
src/util/unit_format.cc)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(visu_gui_SOURCES ${visu_gui_SOURCES}
src/util/win32_argv.cc
src/util/win32_socketpair.cc)
endif()
add_executable(visu_gui ${visu_gui_SOURCES})
set_target_properties(visu_gui PROPERTIES
OUTPUT_NAME "visu~-gui"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}")
target_compile_definitions(visu_gui
PRIVATE COLOR_USE_PP2FILE=1)
target_include_directories(visu_gui
PRIVATE src
PRIVATE thirdparty/color/src
PRIVATE "${FLTK_INCLUDE_DIR}")
target_link_libraries(visu_gui Fl_Knob ${PROJECT_FLTK_LIBRARIES})
if(LINK_STATICALLY)
target_static_link(visu_gui)
endif()
if(USE_FFTW)
target_compile_definitions(visu_gui
PRIVATE "USE_FFTW=1")
target_include_directories(visu_gui
PRIVATE "${FFTW3F_INCLUDE_DIR}")
target_link_libraries(visu_gui
"${PROJECT_FFTW3F_LIBRARIES}")
else()
target_include_directories(visu_gui
PRIVATE thirdparty/kfr/include)
endif()
pkg_check_modules(JACK jack)
if(JACK_FOUND)
link_directories(${JACK_LIBRARY_DIRS})
include_directories(${JACK_INCLUDE_DIRS})
add_executable(visu_jack
src/jack-main.cc)
target_link_libraries(visu_jack
PRIVATE visu_common PRIVATE ${JACK_LIBRARIES})
set_target_properties(visu_jack PROPERTIES
OUTPUT_NAME "visu~-jack"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}")
install(TARGETS visu_jack DESTINATION bin)
install(TARGETS visu_gui DESTINATION bin)
foreach(visu_name ${visu_names})
install(FILES "scripts/run-jack-visu~.sh"
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
DESTINATION bin
RENAME "${visu_name}")
endforeach()
endif()