forked from litespeedtech/ls-hpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
77 lines (63 loc) · 2.09 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
# The following variable can be defined on the command line:
#
# SHARED
# NDEBUG
# XXH_HEADER_NAME
# XXH_INCLUDE_DIR
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(ls-hpack C)
IF (SHARED EQUAL 1)
ADD_LIBRARY(ls-hpack SHARED src/lshpack.c)
ELSE()
ADD_LIBRARY(ls-hpack STATIC src/lshpack.c)
ENDIF()
INCLUDE_DIRECTORIES(include)
IF (NOT DEFINED XXH_HEADER_NAME)
SET(XXH_HEADER_NAME "xxhash.h")
ENDIF()
IF (DEFINED XXH_INCLUDE_DIR)
INCLUDE_DIRECTORIES("${XXH_INCLUDE_DIR}")
ELSE()
INCLUDE_DIRECTORIES(deps/xxhash)
ENDIF()
IF (MSVC)
INCLUDE_DIRECTORIES(wincompat)
ENDIF()
IF (CMAKE_C_COMPILER_ID STREQUAL GNU
OR CMAKE_C_COMPILER_ID STREQUAL Clang)
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wall -Wextra -Wno-unused-parameter")
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -fno-omit-frame-pointer")
INCLUDE(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG(-Wno-implicit-fallthrough HAS_NO_IMPLICIT_FALLTHROUGH)
IF (HAS_NO_IMPLICIT_FALLTHROUGH)
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -Wno-implicit-fallthrough")
ENDIF()
IF (PROFILE EQUAL 1)
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -g -pg")
ENDIF()
IF (CMAKE_BUILD_TYPE STREQUAL Release)
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -g0 -O3")
ELSE()
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -g3 -O0")
ENDIF()
ENDIF()
IF (NOT CMAKE_BUILD_TYPE STREQUAL Release)
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLS_HPACK_EMIT_TEST_CODE=1")
ENDIF()
IF (CMAKE_BUILD_TYPE STREQUAL MinSizeRel)
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DLS_HPACK_USE_LARGE_TABLES=0")
ENDIF()
IF (NDEBUG EQUAL 1)
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DNDEBUG")
ENDIF()
SET(MY_CMAKE_FLAGS "${MY_CMAKE_FLAGS} -DXXH_HEADER_NAME=\\\"${XXH_HEADER_NAME}\\\"")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_CMAKE_FLAGS} $ENV{EXTRA_CFLAGS}")
MESSAGE(STATUS "Compiler flags: ${CMAKE_C_FLAGS}")
IF (NOT CMAKE_BUILD_TYPE STREQUAL Release)
ENABLE_TESTING()
INCLUDE_DIRECTORIES("test")
ADD_SUBDIRECTORY("test")
ENDIF()
IF (CMAKE_SYSTEM_NAME STREQUAL Linux)
ADD_SUBDIRECTORY(bin)
ENDIF()