443d79bd4e8be136b478e7026620db90a2935140
[project/ucert.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(ucert C)
4
5 ADD_DEFINITIONS(-Wall -Werror)
6 IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
7 ADD_DEFINITIONS(-Wextra -Werror=implicit-function-declaration)
8 ADD_DEFINITIONS(-Wformat -Werror=format-security -Werror=format-nonliteral)
9 ENDIF()
10 ADD_DEFINITIONS(-Os -std=gnu99 -ggdb -Wmissing-declarations -Wno-unused-parameter)
11
12 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
13
14 FIND_PATH(ubox_include_dir NAMES libubox/usock.h)
15 FIND_PATH(jsonc_include_dir NAMES json-c/json.h)
16 INCLUDE_DIRECTORIES(${ubox_include_dir} ${jsonc_include_dir})
17
18 FIND_LIBRARY(ubox NAMES ubox)
19 FIND_LIBRARY(blobmsg_json NAMES blobmsg_json)
20 FIND_LIBRARY(json NAMES json-c json)
21
22 IF(UCERT_HOST_BUILD)
23 ADD_DEFINITIONS(-DUCERT_HOST_BUILD)
24 ENDIF()
25
26 IF(USE_RPATH)
27 SET(CMAKE_INSTALL_RPATH "${USE_RPATH}")
28 SET(CMAKE_MACOSX_RPATH 1)
29 ENDIF()
30
31 ADD_LIBRARY(ucert_lib STATIC usign-exec.c)
32 ADD_EXECUTABLE(ucert ucert.c)
33
34 IF(UCERT_FULL)
35 ADD_DEFINITIONS(-DUCERT_FULL)
36 TARGET_LINK_LIBRARIES(ucert ucert_lib ${ubox} ${blobmsg_json} ${json})
37 ELSE()
38 ADD_DEFINITIONS(-DUCERT_STRIP_MESSAGES)
39 TARGET_LINK_LIBRARIES(ucert ucert_lib ${ubox})
40 ENDIF()
41
42 INSTALL(TARGETS ucert RUNTIME DESTINATION bin)