-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
56 lines (43 loc) · 1.8 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
cmake_minimum_required(VERSION 2.6)
project(ghttp2)
include(GNUInstallDirs)
include(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
glib-2.0
openssl
libnghttp2
#for test app
alsa
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -g -Wall -Wextra -fvisibility=hidden -fPIC -fdata-sections -ffunction-sections")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wswitch-default -Wunreachable-code -Wpointer-arith -Waggregate-return -Wconversion")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wcast-align")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-as-needed -pie")
set(CMAKE_INSTALL_RPATH "${CMAKE_BINARY_DIR}")
foreach(flag ${pkgs_CFLAGS})
set(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
endforeach(flag)
set(pkgs_LDFLAGS "${pkgs_LDFLAGS} -lhttp_parser")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -O2 -fPIE")
add_definitions("-DEXPORT_API=__attribute__((visibility(\"default\")))")
add_definitions("-DCONFIG_VERBOSE")
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include)
set(SRCS
src/verbose.c
src/ghttp2.c
src/request.c
src/uri.c
src/connection.c
src/fdsource.c
)
add_library(${PROJECT_NAME} SHARED ${SRCS})
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME} ${pkgs_LDFLAGS})
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION 0.1.0 SOVERSION 0 OUTPUT_NAME ${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
add_executable(ghttp2client main.c)
add_dependencies(ghttp2client ${PROJECT_NAME})
target_link_libraries(ghttp2client ${pkgs_LDFLAGS} "-L${CMAKE_BINARY_DIR} -l${PROJECT_NAME}")
install(TARGETS ghttp2client RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
enable_testing()
add_subdirectory(avs)