-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
126 lines (107 loc) · 3.64 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
#
# rpi0-cross-compile
#
CMAKE_MINIMUM_REQUIRED(VERSION 3.21)
PROJECT(rpi0-cross-compile
HOMEPAGE_URL http://github.com/RoEdAl/rpi0-cross-compile
DESCRIPTION "Demo application for Raspberry Pi Zero/1B/1B+"
VERSION 1
LANGUAGES C
)
INCLUDE(CheckIncludeFile)
INCLUDE(CTest)
INCLUDE(CheckPIESupported)
SET(GREETING_MSG "Hello, World!" CACHE STRING "Greeting message")
OPTION(USE_SHARED_LIBGCC "Use shared libgcc library" ON)
CHECK_PIE_SUPPORTED(OUTPUT_VARIABLE PIE_DETAILS LANGUAGES C)
IF(NOT CMAKE_C_LINK_PIE_SUPPORTED)
MESSAGE(WARNING "PIE is not supported at link time: ${PIE_DETAILS}")
ENDIF()
FIND_PACKAGE(SQLite3 3.5.9)
CHECK_INCLUDE_FILE(stdio.h HAVE_STDIO_H)
CONFIGURE_FILE(config.h.in include/config.h ESCAPE_QUOTES)
ADD_EXECUTABLE(rpi01 main.c)
ADD_EXECUTABLE(hello-world ALIAS rpi01)
TARGET_INCLUDE_DIRECTORIES(rpi01 PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include)
IF(TARGET SQLite::SQLite3)
TARGET_LINK_LIBRARIES(rpi01 PRIVATE SQLite::SQLite3)
ENDIF()
TARGET_LINK_OPTIONS(rpi01 PRIVATE
-Wl,--trace
-$<IF:$<BOOL:${USE_SHARED_LIBGCC}>,shared,static>-libgcc
)
SET_TARGET_PROPERTIES(rpi01 PROPERTIES POSITION_INDEPENDENT_CODE ON)
INCLUDE(GNUInstallDirs)
INSTALL(
TARGETS rpi01
DESTINATION ${CMAKE_INSTALL_BINDIR}
)
INSTALL(
FILES LICENSE.deb
DESTINATION ${CMAKE_INSTALL_DOCDIR}
RENAME copyright
)
IF(CMAKE_CROSSCOMPILING)
ADD_CUSTOM_COMMAND(TARGET rpi01 POST_BUILD
COMMAND ${CMAKE_COMMAND}
-DCMAKE_READELF=${CMAKE_READELF}
-P ${CMAKE_SOURCE_DIR}/cmake/arch-specific.cmake
$<TARGET_OBJECTS:rpi01>
$<TARGET_FILE:rpi01>
)
ENDIF()
IF(BUILD_TESTING)
ADD_TEST(NAME rpi01.execute COMMAND rpi01)
SET_TESTS_PROPERTIES(rpi01.execute PROPERTIES
PASS_REGULAR_EXPRESSION Hello
TIMEOUT 15
LABELS EXE
)
ENDIF()
# Binary package
IF(NOT CPACK_GENERATOR)
SET(CPACK_GENERATOR TGZ DEB)
ENDIF()
# Package description (multiline)
SET(CPACK_PACKAGE_DESCRIPTION_EX)
LIST(APPEND CPACK_PACKAGE_DESCRIPTION_EX "Toolchain: ${triple}")
LIST(APPEND CPACK_PACKAGE_DESCRIPTION_EX "CMake version: ${CMAKE_VERSION}")
IF(USE_SHARED_LIBGCC)
LIST(APPEND CPACK_PACKAGE_DESCRIPTION_EX "libgcc: shared")
ELSE()
LIST(APPEND CPACK_PACKAGE_DESCRIPTION_EX "libgcc: static")
ENDIF()
LIST(JOIN CPACK_PACKAGE_DESCRIPTION_EX "\n" CPACK_PACKAGE_DESCRIPTION)
SET(CPACK_PACKAGE_CHECKSUM SHA256)
SET(CPACK_STRIP_FILES ON)
SET(CPACK_THREADS 0)
SET(CPACK_ARCHIVE_THREADS 0)
LIST(APPEND CPACK_POST_BUILD_SCRIPTS "${CMAKE_CURRENT_SOURCE_DIR}/cpack/post-build-deb-info.cmake")
LIST(APPEND CPACK_POST_BUILD_SCRIPTS "${CMAKE_CURRENT_SOURCE_DIR}/cpack/post-build-lintian.cmake")
# Debian package
SET(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
SET(CPACK_DEBIAN_PACKAGE_SECTION misc)
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CPACK_PACKAGE_ARCHITECTURE})
SET(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION ON)
IF(CPACK_PACKAGE_MAINTAINER)
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_MAINTAINER} <${CPACK_PACKAGE_CONTACT}>")
ELSE()
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR} <${CPACK_PACKAGE_CONTACT}>")
ENDIF()
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
SET(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=")
# Source package
IF(NOT CPACK_SOURCE_GENERATOR)
SET(CPACK_SOURCE_GENERATOR TGZ)
ENDIF()
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${CHAN_VER_FSTR}_src")
SET(CPACK_SOURCE_IGNORE_FILES
"/build/" "/devcontainer-build"
"/install/" "/test/" "/tools/"
"/package/" "/devcontainer-package/"
"/\.vscode/" "/\.git/" "/\.gitignore" "/\.gitattributes"
"/hello-world.o" "/hello-world"
"Taskfile.yml" "Taskfile.yaml"
"/CMakeUserPresets.json"
)
INCLUDE(CPack)