blob: b64a299700dca571012d6be69abf16abdcd9324f (
plain)
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
|
cmake_minimum_required(VERSION 3.22)
project(libac C)
set(CMAKE_C_STANDARD 11)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
add_definitions(-D_POSIX_C_SOURCE=200809L)
IF(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DDEBUG)
ENDIF(CMAKE_BUILD_TYPE MATCHES Debug)
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} -g3 -O0 -fsanitize=address")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -fvisibility=hidden")
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
# TODO: MSVC ASAN
set(CMAKE_C_FLAGS_DEBUG
"${CMAKE_C_FLAGS_DEBUG} /DEBUG /Z7 /Od")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG
"${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
endif()
set(LIBAC_PUBLIC_HEADERS
include/incl.h
include/libac.h
include/events.h
include/requests.h
include/common.h
include/net.h
include/ids.h
)
set(LIBAC_PRIVATE
private/win32.h
private/config.h
private/serializer.h
private/helpers.c
private/serializer.h
private/log.h
private/connection.h
wic/include/http_parser.h
wic/include/wic.h
private/serializer.c
private/helpers.c
private/log.c
wic/src/http_parser.c
wic/src/wic.c
net.c
ids.c
library.c
)
add_library(ac SHARED
${LIBAC_PUBLIC_HEADERS}
${LIBAC_PRIVATE}
)
add_library(ac-static STATIC
${LIBAC_PUBLIC_HEADERS}
${LIBAC_PRIVATE}
)
set(LIBAC_INCLUDES "${PROJECT_BINARY_DIR}" include/ private/ wic/include/)
if (EXISTS ${CMAKE_SOURCE_DIR}/json-c/build/install)
message("Using in-tree JSON-C")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/json-c/build/install/lib/cmake/")
else()
message("Using system-wide JSON-C")
endif()
if(WIN32)
set(LIBAC_DEPS ws2_32)
else()
set(LIBAC_DEPS m)
endif()
find_package(json-c CONFIG)
set(LIBAC_DEPS ${LIBAC_DEPS} json-c::json-c)
target_include_directories(ac PUBLIC ${LIBAC_INCLUDES})
target_link_libraries(ac ${LIBAC_DEPS})
target_include_directories(ac-static PUBLIC ${LIBAC_INCLUDES})
target_link_libraries(ac-static ${LIBAC_DEPS})
add_executable(helloworld
apps/helloworld/main.c
apps/helloworld/net.c
apps/helloworld/net.h
)
if(WIN32)
set(ACRONC_DEPS ws2_32)
endif()
set(ACRONC_DEPS ${ACRON_DEPS} ac)
target_link_libraries(helloworld ${ACRONC_DEPS})
target_include_directories(helloworld PUBLIC "${PROJECT_BINARY_DIR}" include/)
install(TARGETS ac ac-static helloworld
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ${CMAKE_INSTALL_INCLUDEDIR}/libac
)
install(FILES ${LIBAC_PUBLIC_HEADERS} DESTINATION include/libac)
|