-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
58 lines (45 loc) · 2.58 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
ADD_DEFINITIONS(-D_GNU_SOURCE)
list(APPEND CMAKE_REQUIRED_DEFINITIONS '-D_GNU_SOURCE')
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${SNAPCAST_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND COMMON_DEPS util.c taskqueue.c timespec.c vector.c syscallwrappers.c intercom.c pcmchunk.c opuscodec.c)
list(APPEND CLIENT_DEPS intercom_client.c alsaplayer.c pqueue.c)
list(APPEND SERVER_DEPS intercom_srv.c clientmgr.c inputpipe.c socket.c jsonrpc.c stream.c)
add_library(common_libs OBJECT ${COMMON_DEPS})
add_library(client_deps OBJECT ${CLIENT_DEPS})
add_library(server_deps OBJECT ${SERVER_DEPS})
add_executable(snapcast-server server.c $<TARGET_OBJECTS:server_deps> $<TARGET_OBJECTS:common_libs>)
add_executable(snapcast-client client.c $<TARGET_OBJECTS:client_deps> $<TARGET_OBJECTS:common_libs>)
add_executable(snapcast-test-srv server-test.c $<TARGET_OBJECTS:server_deps> $<TARGET_OBJECTS:common_libs>)
add_executable(snapcast-test-client client-test.c $<TARGET_OBJECTS:client_deps> $<TARGET_OBJECTS:common_libs>)
target_link_libraries(snapcast-server ${JSON_C_LIBRARIES})
target_link_libraries(snapcast-server ${ALSA_LIBRARIES})
target_link_libraries(snapcast-test-srv ${JSON_C_LIBRARIES})
target_link_libraries(snapcast-test-srv ${ALSA_LIBRARIES})
target_link_libraries(snapcast-test-client ${JSON_C_LIBRARIES})
target_link_libraries(snapcast-test-client ${ALSA_LIBRARIES})
target_link_libraries(snapcast-client ${JSON_C_LIBRARIES})
target_link_libraries(snapcast-client ${ALSA_LIBRARIES})
set_target_properties(snapcast-client PROPERTIES COMPILE_FLAGS "-std=gnu11 -fno-omit-frame-pointer -Wall" LINK_FLAGS "-lm")
set_target_properties(snapcast-server PROPERTIES COMPILE_FLAGS "-std=gnu11 -fno-omit-frame-pointer -Wall" LINK_FLAGS "-lm")
set_target_properties(snapcast-test-srv PROPERTIES COMPILE_FLAGS "-std=gnu11 -fno-omit-frame-pointer -Wall" LINK_FLAGS "-lm")
set_target_properties(snapcast-test-client PROPERTIES COMPILE_FLAGS "-std=gnu11 -fno-omit-frame-pointer -Wall" LINK_FLAGS "-lm")
install(TARGETS snapcast-client RUNTIME DESTINATION bin)
install(TARGETS snapcast-server RUNTIME DESTINATION bin)
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file(
${CMAKE_SOURCE_DIR}/src/version.h.in
${CMAKE_BINARY_DIR}/src/version.h
)