-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
83 lines (70 loc) · 2.63 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
cmake_minimum_required(VERSION 3.11)
project(rtc_handler)
# Generate compile_commands.json
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Default options
option(BUILD_STATIC_LIBS "Build example executables" ON)
set(STATIC ${BUILD_STATIC_LIBS})
option(BUILD_EXAMPLES "Build example executables" ON)
set(EXAMPLES ${BUILD_EXAMPLES})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Dependencies
include(FetchContent)
find_package(libdatachannel)
if (NOT libdatachannel_FOUND)
FetchContent_Declare(
libdatachannel
GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git
GIT_TAG 0f7985f4662a9664d7567eea2500ef9c190d1cbc
GIT_PROGRESS TRUE
GIT_SHALLOW false
)
FetchContent_GetProperties(libdatachannel)
if (NOT libdatachannel_POPULATED)
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(libdatachannel)
set(PREFER_SYSTEM_LIB OFF CACHE BOOL "" FORCE)
set(NO_EXAMPLES ON CACHE BOOL "" FORCE)
set(USE_GNUTLS OFF CACHE BOOL "" FORCE)
set(USE_NICE OFF CACHE BOOL "" FORCE)
set(CMAKE_BUILD_TYPE "Release")
add_subdirectory(${libdatachannel_SOURCE_DIR} ${libdatachannel_BINARY_DIR})
endif()
endif()
find_package(json-c QUIET)
if (NOT json-C_FOUND)
FetchContent_Declare(
json-c
GIT_REPOSITORY https://github.com/json-c/json-c.git
GIT_TAG 6e481aa06166c2b31e391005c6e50f0adef5e4d4
GIT_PROGRESS TRUE
GIT_SHALLOW false
)
FetchContent_GetProperties(json-c)
if (NOT json-c_POPULATED)
set(FETCHCONTENT_QUIET NO)
FetchContent_Populate(json-c)
set(BUILD_STATIC_LIBS ON CACHE BOOL "" FORCE)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(${json-c_SOURCE_DIR} ${json-c_BINARY_DIR})
endif()
endif()
file(GLOB SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c")
if (STATIC)
add_library(${PROJECT_NAME} STATIC ${SOURCES})
else()
add_library(${PROJECT_NAME} SHARED ${SOURCES})
endif()
target_link_libraries(${PROJECT_NAME} datachannel json-c uuid)
file(GLOB SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/examples/*.c")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
file(GLOB_RECURSE CONTAINERS "${CMAKE_CURRENT_SOURCE_DIR}/examples/containers/*/*.c")
# Build examples
if (EXAMPLES)
foreach(SOURCE_FILE ${SRC_FILES})
get_filename_component(EXE_NAME ${SOURCE_FILE} NAME_WE)
add_executable(${EXE_NAME} ${CONTAINERS} ${SOURCE_FILE})
target_include_directories(${EXE_NAME} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_link_libraries(${EXE_NAME} ${PROJECT_NAME} ncurses m X11 GL png)
endforeach()
endif()