-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
82 lines (58 loc) · 1.89 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
# cmake version
cmake_minimum_required(VERSION 3.5)
#cmake policy
cmake_policy(SET CMP0015 NEW)
# Project name.
project(docker)
# Setting options.
option(EXAMPLE_BUILD "Build using examples" ON)
set( CMAKE_INSTALL_LIBDIR /usr/lib )
set( CMAKE_INSTALL_BINDIR /usr/bin )
find_package(CURL REQUIRED)
# Install docker.h to the /usr/include directory
install(FILES inc/docker.h PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION /usr/include)
# Including the headers to be used for building the SDK.
include_directories(${CMAKE_CURRENT_LIST_DIR}/inc)
# The source files.
SET(SRC_FILES
${CMAKE_CURRENT_LIST_DIR}/src/docker.c
)
# The cdocker will be created as a .so
add_library( docker SHARED ${SRC_FILES})
# Linking with dependencies.
target_link_libraries(
docker
-lcurl
)
# Installing in the target file as a library.
INSTALL(
TARGETS docker
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT library
)
# If example build is enabled.
if(EXAMPLE_BUILD)
include_directories(${CMAKE_SOURCE_DIR}/inc)
SET( SRC_FILES
${CMAKE_CURRENT_LIST_DIR}/example/example.c
)
add_executable(docker_example ${SRC_FILES})
target_link_libraries(
docker_example
docker
)
install(TARGETS docker_example RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif(EXAMPLE_BUILD)
# Adding deb package build options.
set(CPACK_PACKAGE_NAME "docker_c_sdk")
set(CDOCKER_VERSION_MAJOR 1)
set(CDOCKER_VERSION_MINOR 1)
set(CDOCKER_VERSION_PATCH 0)
set(CPACK_PACKAGE_VERSION_MAJOR "${CDOCKER_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${CDOCKER_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${CDOCKER_VERSION_PATCH}")
set(CPACK_DEBIAN_PACKAGE_SHIPBUILDS ON)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "schaffung")
include(CPack)