-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
89 lines (79 loc) · 2.59 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
# Project definition
cmake_minimum_required(VERSION 3.8)
project(Kontroller VERSION 1.4.0 LANGUAGES CXX)
set(LINUX FALSE)
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
endif ()
set(KONTROLLER_PROJECT_NAME "${PROJECT_NAME}")
# Build options
option(KONTROLLER_BUILD_SERVICE "Build the Kontroller service" OFF)
option(KONTROLLER_BUILD_EXAMPLES "Build the Kontroller example programs" OFF)
# Library definition and features
add_library(${PROJECT_NAME})
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
# Source files
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Source")
set(INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Include")
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Libraries")
set(QUEUE_DIR "${LIB_DIR}/readerwriterqueue")
target_sources(${PROJECT_NAME} PRIVATE
"${INC_DIR}/Kontroller/Client.h"
"${INC_DIR}/Kontroller/Device.h"
"${INC_DIR}/Kontroller/Packet.h"
"${INC_DIR}/Kontroller/Server.h"
"${INC_DIR}/Kontroller/State.h"
"${QUEUE_DIR}/atomicops.h"
"${QUEUE_DIR}/readerwriterqueue.h"
)
target_sources(${PROJECT_NAME} PRIVATE
"${SRC_DIR}/Client.cpp"
"${SRC_DIR}/Communicator.h"
"${SRC_DIR}/Device.cpp"
"${SRC_DIR}/Server.cpp"
"${SRC_DIR}/Sock.cpp"
"${SRC_DIR}/Sock.h"
"${SRC_DIR}/State.cpp"
)
if (APPLE)
target_sources(${PROJECT_NAME} PRIVATE
"${SRC_DIR}/Communicator_macOS.cpp"
)
elseif (WIN32)
target_sources(${PROJECT_NAME} PRIVATE
"${SRC_DIR}/Communicator_Windows.cpp"
)
elseif (LINUX)
target_sources(${PROJECT_NAME} PRIVATE
"${SRC_DIR}/Communicator_Linux.cpp"
)
endif ()
target_include_directories(${PROJECT_NAME}
PUBLIC "${INC_DIR}" "${QUEUE_DIR}"
PRIVATE "${SRC_DIR}"
)
get_target_property(SOURCE_FILES ${PROJECT_NAME} SOURCES)
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCE_FILES})
# PlatformUtils
add_subdirectory("${LIB_DIR}/PlatformUtils")
target_link_libraries(${PROJECT_NAME} PUBLIC PlatformUtils)
# Platform-specific dependencies
if (APPLE)
find_library(COREMIDI_LIBRARY CoreMidi)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
target_link_libraries(${PROJECT_NAME} PUBLIC ${COREMIDI_LIBRARY} ${COREFOUNDATION_LIBRARY})
elseif (WIN32)
target_link_libraries(${PROJECT_NAME} PUBLIC "winmm")
elseif (LINUX)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC Threads::Threads)
find_package(ALSA REQUIRED)
target_link_libraries(${PROJECT_NAME} PUBLIC ${ALSA_LIBRARIES})
endif ()
if (KONTROLLER_BUILD_SERVICE)
add_subdirectory("Service")
endif ()
if (KONTROLLER_BUILD_EXAMPLES)
add_subdirectory("Examples")
endif()