File: CMakeLists.txt

package info (click to toggle)
tini 0.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 212 kB
  • sloc: ansic: 619; python: 379; sh: 287; makefile: 5
file content (113 lines) | stat: -rw-r--r-- 3,427 bytes parent folder | download
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
113
cmake_minimum_required (VERSION 2.8.0)
project (tini C)

# Config
set (tini_VERSION_MAJOR 0)
set (tini_VERSION_MINOR 18)
set (tini_VERSION_PATCH 0)

# Build options
option(MINIMAL "Disable argument parsing and verbose output" OFF)

if(MINIMAL)
	add_definitions(-DTINI_MINIMAL=1)
endif()

# Extract git version and dirty-ness
execute_process (
  COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" log -n 1 --date=local --pretty=format:%h
  WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  RESULT_VARIABLE git_version_check_ret
  OUTPUT_VARIABLE tini_VERSION_GIT
)

execute_process(
  COMMAND git --git-dir "${PROJECT_SOURCE_DIR}/.git" --work-tree "${PROJECT_SOURCE_DIR}" status --porcelain --untracked-files=no
  WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
  OUTPUT_VARIABLE git_dirty_check_out
)

if("${git_version_check_ret}" EQUAL 0)
  set(tini_VERSION_GIT " - git.${tini_VERSION_GIT}")
  if(NOT "${git_dirty_check_out}" STREQUAL "")
    set(tini_VERSION_GIT "${tini_VERSION_GIT}-dirty")
  endif()
else()
  set(tini_VERSION_GIT "")
endif()

# Flags
include(CheckCSourceCompiles)

check_c_source_compiles("
#ifndef _FORTIFY_SOURCE
#error \"Not defined: _FORTIFY_SOURCE\"
#endif
int main(void)                                                                                                              {
  return 0;
}
" HAS_BUILTIN_FORTIFY)

# Flags
if(NOT HAS_BUILTIN_FORTIFY)
	add_definitions(-D_FORTIFY_SOURCE=2)
endif()

set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -Werror -Wextra -Wall -pedantic-errors -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-s")

# Build

configure_file (
	"${PROJECT_SOURCE_DIR}/src/tiniConfig.h.in"
	"${PROJECT_BINARY_DIR}/tiniConfig.h"
	@ONLY
)

configure_file (
	"${PROJECT_SOURCE_DIR}/tpl/README.md.in"
	"${PROJECT_SOURCE_DIR}/README.md"
	@ONLY
)

configure_file (
	"${PROJECT_SOURCE_DIR}/tpl/VERSION.in"
	"${PROJECT_BINARY_DIR}/VERSION"
	@ONLY
)


include_directories ("${PROJECT_BINARY_DIR}")

add_executable (tini src/tini.c)

add_executable (tini-static src/tini.c)
set_target_properties (tini-static PROPERTIES LINK_FLAGS "-Wl,--no-export-dynamic -static")

# Installation
install (TARGETS tini DESTINATION bin)
install (TARGETS tini-static DESTINATION bin)

# Packaging
include (InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "A tiny but valid init process for containers")
set (CPACK_PACKAGE_VENDOR "Thomas Orozco")
set (CPACK_PACKAGE_CONTACT "thomas@orozco.fr")
set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VERSION_MAJOR "${tini_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${tini_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${tini_VERSION_PATCH}")
set (CPACK_PACKAGE_EXECUTABLES "${CMAKE_PROJECT_NAME}")
set (CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set (CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${tini_VERSION_MAJOR}.${tini_VERSION_MINOR}.${tini_VERSION_PATCH}")
set (CPACK_PACKAGE_VERSION "${tini_VERSION_MAJOR}.${tini_VERSION_MINOR}.${tini_VERSION_PATCH}")

set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")  # TODO
set (CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.4)")

set (CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")

set (CPACK_GENERATOR "DEB" "RPM")

include (CPack)