File: CMakeLists.txt

package info (click to toggle)
o2 1.0~repack-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,156 kB
  • sloc: ansic: 9,132; python: 137; sh: 111; makefile: 10
file content (285 lines) | stat: -rw-r--r-- 11,401 bytes parent folder | download
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
cmake_minimum_required(VERSION 2.8.0)

project(o2)

set(BUILD_TESTS ON CACHE BOOL "Compile regression and other tests")

set(BUILD_TESTS_WITH_LIBLO OFF CACHE BOOL "Compile tests that use liblo,
requiring liblo library (only enabled if BUILD_TESTS is ON)")

set(BUILD_MIDI_EXAMPLE OFF CACHE BOOL "Compile midiclient & midiserver,
requiring portmidi library")

# O2 intentionally writes outside of declared array bounds (and
#  carefully insures that space is allocated beyond array bounds,
#  especially for message data, which is declared char[4], but can
#  be arbitrariily long -- well, at least up to O2_MAX_MSG_SIZE)
# Newer compilers will try to enforce char[4] in memcpy and strcpy
#  unless we turn off this behavior with the following macro definition:
add_definitions("-D_FORTIFY_SOURCE=0")

if(WIN32)
  add_definitions("-D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -DIS_BIG_ENDIAN=0")
  include(static.cmake)
  set(EXTRA_LIBS winmm.lib ws2_32.lib Iphlpapi.lib)
endif(WIN32)

if(APPLE)
  set(FRAMEWORK_PATH ${CMAKE_OSX_SYSROOT}/System/Library/Frameworks) 
  set(EXTRA_LIBS "${FRAMEWORK_PATH}/CoreAudio.framework") 
endif(APPLE)

#set(CMAKE_CXX_FLAGS "-stdlib=libc++")
#set(CMAKE_EXE_LINKER_FLAGS "-stdlib=libc++")

# o2
 
set(O2_SRC  
  src/o2_dynamic.c src/o2_dynamic.h
  src/o2.c src/o2.h src/o2_internal.h 
  src/o2_discovery.c src/o2_discovery.h
  src/o2_message.c src/o2_message.h 
  src/o2_sched.c src/o2_sched.h
  src/o2_search.c src/o2_search.h 
  src/o2_send.c src/o2_send.h 
  src/o2_socket.c src/o2_socket.h 
  src/o2_clock.c src/o2_clock.h
  # src/o2_debug.c src/o2_debug.h
  src/o2_interoperation.c src/o2_interoperation.h
  )  
 
add_library(o2_static STATIC ${O2_SRC})
add_library(o2 SHARED ${O2_SRC})
 
#target_include_directories(o2_static PRIVATE ${no include directories})

#######################
# BUILD CONFIGURATION #
#######################

set(LIBRARIES o2_static ${EXTRA_LIBS} CACHE INTERNAL "") 

if(BUILD_TESTS)
message(STATUS "Building test programs")

set(BUILD_STATIC_LIB TRUE CACHE BOOL "Build a static lib -- currently the only thing supported, turning OFF probably gives you a static library without a static runtime library option.")

# DEAL WITH WINDOWS OPTIONS: DEATH BY A THOUSAND CUTS
if(WIN32)
  if(USE_STATIC_LIBS)
    # release will use static runtime library
    foreach(flag_var CMAKE_CXX_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE
        CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_MINSIZEREL
        CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_CFLAGS CMAKE_C_FLAGS_MINSIZEREL
        CMAKE_C_FLAGS_RELWITHDEBINFO)
      if(${flag_var} MATCHES "/MD")
        string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
      endif(${flag_var} MATCHES "/MD")
    endforeach(flag_var)
    message(STATUS 
      "Note: overriding CMAKE_*_FLAGS_* to use Visual C static multithread library")
    set(VERBOSE_WARNINGS 0 CACHE BOOL "Do not use _CRT_SECURE_NO_WARNINGS to disable suggestions to use 'secure' versions of strcpy, etc.")
  endif(USE_STATIC_LIBS)
endif(WIN32)


# EXECUTABLE
# Create executables 
add_executable(dispatchtest test/dispatchtest.c)  
target_include_directories(dispatchtest PRIVATE ${CMAKE_SOURCE_DIR}/src)  
target_link_libraries(dispatchtest ${LIBRARIES}) 
 
add_executable(typestest test/typestest.c)   
target_include_directories(typestest PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(typestest ${LIBRARIES}) 
  
add_executable(coercetest test/coercetest.c)    
target_include_directories(coercetest PRIVATE ${CMAKE_SOURCE_DIR}/src)    
target_link_libraries(coercetest ${LIBRARIES}) 
   
add_executable(longtest test/longtest.c)     
target_include_directories(longtest PRIVATE ${CMAKE_SOURCE_DIR}/src)     
target_link_libraries(longtest ${LIBRARIES}) 
    
add_executable(arraytest test/arraytest.c)     
target_include_directories(arraytest PRIVATE ${CMAKE_SOURCE_DIR}/src)     
target_link_libraries(arraytest ${LIBRARIES}) 
    
add_executable(o2client test/o2client.c) 
target_include_directories(o2client PRIVATE ${CMAKE_SOURCE_DIR}/src) 
target_link_libraries(o2client ${LIBRARIES}) 

add_executable(o2server test/o2server.c) 
target_include_directories(o2server PRIVATE ${CMAKE_SOURCE_DIR}/src) 
target_link_libraries(o2server ${LIBRARIES}) 

add_executable(statusclient test/statusclient.c)
target_include_directories(statusclient PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(statusclient ${LIBRARIES}) 
  
add_executable(statusserver test/statusserver.c)   
target_include_directories(statusserver PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(statusserver ${LIBRARIES}) 
 
add_executable(tcpclient test/tcpclient.c)   
target_include_directories(tcpclient PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(tcpclient ${LIBRARIES}) 
  
add_executable(tcpserver test/tcpserver.c)   
target_include_directories(tcpserver PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(tcpserver ${LIBRARIES}) 
 
add_executable(clockslave test/clockslave.c) 
target_include_directories(clockslave PRIVATE ${CMAKE_SOURCE_DIR}/src) 
target_link_libraries(clockslave ${LIBRARIES}) 

add_executable(clockmaster test/clockmaster.c)  
target_include_directories(clockmaster PRIVATE ${CMAKE_SOURCE_DIR}/src)  
target_link_libraries(clockmaster ${LIBRARIES}) 

add_executable(oscsendtest test/oscsendtest.c)  
target_include_directories(oscsendtest PRIVATE ${CMAKE_SOURCE_DIR}/src)  
target_link_libraries(oscsendtest ${LIBRARIES}) 
 
add_executable(oscrecvtest test/oscrecvtest.c)   
target_include_directories(oscrecvtest PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(oscrecvtest ${LIBRARIES}) 
  
add_executable(oscanytest test/oscanytest.c)   
target_include_directories(oscanytest PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(oscanytest ${LIBRARIES}) 
  
add_executable(bundletest test/bundletest.c)   
target_include_directories(bundletest PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(bundletest ${LIBRARIES}) 
  
add_executable(oscbndlsend test/oscbndlsend.c)   
target_include_directories(oscbndlsend PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(oscbndlsend ${LIBRARIES}) 

add_executable(oscbndlrecv test/oscbndlrecv.c)   
target_include_directories(oscbndlrecv PRIVATE ${CMAKE_SOURCE_DIR}/src)   
target_link_libraries(oscbndlrecv ${LIBRARIES}) 
endif(BUILD_TESTS)

if(UNIX)
  if(APPLE)
  else(APPLE)
    # linux
    set(CMAKE_C_FLAGS "-std=gnu99")
  endif(APPLE)
  if(BUILD_MIDI_EXAMPLE)
    # Use PortMidi Library
    set(PORTMIDI_DBG_LIB PORTMIDI_DBG_LIB-NOTFOUND)
    set(PORTMIDI_OPT_LIB PORTMIDI_OPT_LIB-NOTFOUND)

    if(APPLE)
      set(COREMIDI_LIB "${FRAMEWORK_PATH}/CoreMIDI.framework")
      set(EXTRA_NEEDED_LIBS ${COREAUDIO_LIB} ${COREFOUNDATION_LIB}
                            ${COREMIDI_LIB} ${CORESERVICES_LIB})
    else(APPLE)
      # LINUX
      set(PTHREAD_LIB pthread)
      set(EXTRA_NEEDED_LIBS asound ${PTHREAD_LIB})
    endif(APPLE)

    set(PORTMIDI_BASE_PATH ../portmedia/portmidi 
        CACHE STRING "Where is portmidi?")
    set(PORTMIDI_PATH ${PORTMIDI_BASE_PATH}/pm_common CACHE INTERNAL 
                      "Where is portmidi.h?" FORCE)
    message(STATUS "PORTMIDI_BASE_PATH is " ${PORTMIDI_BASE_PATH})
  
    if(USE_STATIC_LIBS)
      if(UNIX)
        find_library(PORTMIDI_DBG_LIB portmidi_s ${PORTMIDI_BASE_PATH}
                     ${PORTMIDI_BASE_PATH}/Debug
                     ${PORTMIDI_PATH} ${PORTMIDI_PATH}/Debug)
      else(UNIX) # always use dll for windows debug
        find_library(PORTMIDI_DBG_LIB portmidi HINTS
                     ${PORTMIDI_BASE_PATH} ${PORTMIDI_BASE_PATH}/Debug
                     ${PORTMIDI_PATH} ${PORTMIDI_PATH}/Debug)
      endif(UNIX)

      message(STATUS "*** in USE_STATIC_LIBS, USE_MIDI ${USE_MIDI} PORTMIDI_DBG_LIB ${PORTMIDI_DBG_LIB}")

    else(USE_STATIC_LIBS)
      find_library(PORTMIDI_DBG_LIB portmidi HINTS
                   ${PORTMIDI_BASE_PATH} ${PORTMIDI_BASE_PATH}/Debug
	           ${PORTMIDI_BASE_PATH}/x64/Debug
                   ${PORTMIDI_PATH} ${PORTMIDI_PATH}/Debug
                   ${PORTMIDI_PATH}/x64/Debug)
    endif(USE_STATIC_LIBS)

    add_executable(midiclient test/midiclient.c test/cmtio.c test/cmtio.h) 
    target_include_directories(midiclient PRIVATE ${CMAKE_SOURCE_DIR}/src) 
    target_link_libraries(midiclient ${LIBRARIES})

    add_executable(midiserver test/midiserver.c)
    target_include_directories(midiserver PRIVATE ${CMAKE_SOURCE_DIR}/src
          ${PORTMIDI_PATH} ${PORTMIDI_PATH}/../porttime)
    target_link_libraries(midiserver ${LIBRARIES} ${PORTMIDI_DBG_LIB}) 
  endif(BUILD_MIDI_EXAMPLE) 
endif(UNIX)

message(STATUS LIBRARIES=${LIBRARIES}) 

# this is some networking test code, not part of O2
#add_executable(broadcastclient test/broadcastclient.c) 
#add_executable(broadcastserver test/broadcastserver.c) 
#add_executable(tcppollclient test/tcppollclient.c) 
#add_executable(tcppollserver test/tcppollserver.c) 



# I don't know if this is necessary. If it is, it should be duplicated
# for o2client and o2server:
#if(WIN32)
  #set_target_properties(o2test PROPERTIES 
                               #LINK_FLAGS "/SUBSYSTEM:WINDOWS")
  #set_property(TARGET o2test PROPERTY WIN32_EXECUTABLE TRUE)
#endif(WIN32)

##########################################################
# liblo was used for some performance comparisons, but it 
# is disabled/commented out to remove the liblo path and 
# library dependencies from this CMakeLists.txt file 
##########################################################

if(BUILD_TESTS)
if(BUILD_TESTS_WITH_LIBLO)
  set(LIBLO_PATH "${CMAKE_SOURCE_DIR}/../liblo-0.28" CACHE PATH
                 "Where to find liblo_64s.a, the liblo library.") 
  set(LIBLO_LIB LIBLO_LIB-NOTFOUND CACHE FILEPATH
             "The liblo library; should be set automatically if LIBLO_PATH is correct and liblo_64s.a exists.") 
  find_library(LIBLO_LIB lo_s64 ${LIBLO_PATH})
  # where to find liblo include files:
  set(LIBLO_INCLUDE_PATH ${LIBLO_PATH} CACHE PATH "where to find liblo include files") 

  message(STATUS "LIBLO_LIB is ${LIBLO_LIB}") 

  # Create executables 
  add_executable(lo_benchmk_server  test/lo_benchmk_server.c) 
  target_include_directories(lo_benchmk_server PRIVATE ${LIBLO_INCLUDE_PATH})
  target_link_libraries(lo_benchmk_server ${LIBLO_LIB} ${EXTRA_NEEDED_LIBS}) 

  add_executable(lo_benchmk_client  test/lo_benchmk_client.c) 
  target_include_directories(lo_benchmk_client PRIVATE ${LIBLO_INCLUDE_PATH})  
  target_link_libraries(lo_benchmk_client ${LIBLO_LIB}  ${EXTRA_NEEDED_LIBS})  

  add_executable(lo_oscrecv test/lo_oscrecv.c) 
  target_include_directories(lo_oscrecv PRIVATE ${LIBLO_INCLUDE_PATH})  
  target_link_libraries(lo_oscrecv ${LIBLO_LIB}  ${EXTRA_NEEDED_LIBS})   

  add_executable(lo_oscsend test/lo_oscsend.c) 
  target_include_directories(lo_oscsend PRIVATE ${LIBLO_INCLUDE_PATH})  
  target_link_libraries(lo_oscsend ${LIBLO_LIB}  ${EXTRA_NEEDED_LIBS})    

  add_executable(lo_bndlsend test/lo_bndlsend.c) 
  target_include_directories(lo_bndlsend PRIVATE ${LIBLO_INCLUDE_PATH})  
  target_link_libraries(lo_bndlsend ${LIBLO_LIB}  ${EXTRA_NEEDED_LIBS})     

  add_executable(lo_bndlrecv test/lo_bndlrecv.c) 
  target_include_directories(lo_bndlrecv PRIVATE ${LIBLO_INCLUDE_PATH})  
  target_link_libraries(lo_bndlrecv ${LIBLO_LIB}  ${EXTRA_NEEDED_LIBS})     
endif(BUILD_TESTS_WITH_LIBLO)
endif(BUILD_TESTS)