1 find_package(Sanitizers)
3 if(NOT COMMAND add_sanitizers)
4 message(WARNING "Sanitizers CMake module not found, sanitizer support is not available")
5 # defining a no-op function to avoid CMake errors
6 function(add_sanitizers ...)
11 # include XDG basedir library
12 add_subdirectory(xdg-basedir)
15 # allow setting different path for mksquashfs after installation
16 set(AUXILIARY_FILES_DESTINATION "lib/appimagekit" CACHE STRING "Target install directory for mksquashfs")
19 add_library(libappimage SHARED
20 ${PROJECT_SOURCE_DIR}/include/appimage/appimage.h
28 set_target_properties(libappimage PROPERTIES PREFIX "")
29 set_target_properties(libappimage PROPERTIES PUBLIC_HEADER "${PROJECT_SOURCE_DIR}/include/appimage/appimage.h")
31 target_compile_definitions(libappimage
32 PRIVATE -D_FILE_OFFSET_BITS=64
33 PRIVATE -DGIT_COMMIT="${GIT_COMMIT}"
34 PRIVATE -DENABLE_BINRELOC
37 target_include_directories(libappimage
38 PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
39 INTERFACE $<INSTALL_INTERFACE:include/>
42 target_link_libraries(libappimage
59 add_library(libappimage_static STATIC
60 ${PROJECT_SOURCE_DIR}/include/appimage/appimage.h
68 set_target_properties(libappimage_static PROPERTIES PREFIX "")
69 set_target_properties(libappimage_static PROPERTIES LIBRARY_OUTPUT_NAME libappimage)
70 set_target_properties(libappimage_static PROPERTIES PUBLIC_HEADER "${PROJECT_SOURCE_DIR}/include/appimage/appimage.h")
72 target_compile_definitions(libappimage_static
73 PRIVATE -D_FILE_OFFSET_BITS=64
74 PRIVATE -DGIT_COMMIT="${GIT_COMMIT}"
75 PRIVATE -DENABLE_BINRELOC
78 target_include_directories(libappimage_static
79 PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
80 INTERFACE $<INSTALL_INTERFACE:include/>
83 target_link_libraries(libappimage_static
100 include(build-runtime.cmake)
103 add_executable(appimagetool
104 ${PROJECT_SOURCE_DIR}/include/appimage/appimage.h
110 appimagetool_shared.c
113 target_include_directories(appimagetool
114 PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
115 INTERFACE $<INSTALL_INTERFACE:include/>
118 # trick: list libraries on which imported static ones depend on in the PUBLIC section
119 # CMake then adds them after the PRIVATE ones in the linker command
120 target_link_libraries(appimagetool
133 target_compile_definitions(appimagetool
134 PRIVATE -D_FILE_OFFSET_BITS=64
135 PRIVATE -DGIT_COMMIT="${GIT_COMMIT}"
136 PRIVATE -DBUILD_NUMBER="${BUILD_NUMBER}"
137 PRIVATE -DBUILD_DATE="${DATE}"
138 PRIVATE -DENABLE_BINRELOC
141 target_include_directories(appimagetool
142 PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
143 INTERFACE $<INSTALL_INTERFACE:include/>
146 if(AUXILIARY_FILES_DESTINATION)
147 message(STATUS "Installing auxiliary files in path: ${AUXILIARY_FILES_DESTINATION}")
148 target_compile_definitions(appimagetool
149 PRIVATE -DAUXILIARY_FILES_DESTINATION="${AUXILIARY_FILES_DESTINATION}"
153 add_sanitizers(appimagetool)
156 add_executable(AppRun AppRun.c)
158 target_compile_definitions(AppRun
159 PRIVATE -D_FILE_OFFSET_BITS=64
160 PRIVATE -DGIT_COMMIT="${GIT_COMMIT}"
161 PRIVATE -DENABLE_BINRELOC
164 add_sanitizers(AppRun)
167 add_executable(validate validate.c getsection.c)
169 target_link_libraries(validate
174 target_include_directories(validate
175 PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
176 INTERFACE $<INSTALL_INTERFACE:include/
180 add_executable(digest digest.c getsection.c)
182 target_link_libraries(digest
186 add_sanitizers(digest)
189 # digest_md5 demo application
190 # can be used to verify AppImages' MD5 digest
191 add_executable(digest_md5 EXCLUDE_FROM_ALL digest_md5.c getsection.c appimagetool_shared.c)
193 target_include_directories(digest_md5
194 PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/>
195 INTERFACE $<INSTALL_INTERFACE:include/>
198 target_link_libraries(digest_md5
205 if(AUXILIARY_FILES_DESTINATION)
207 PROGRAMS ${mksquashfs_INSTALL_DIR}/mksquashfs ${CMAKE_CURRENT_BINARY_DIR}/runtime
208 DESTINATION ${AUXILIARY_FILES_DESTINATION}
209 COMPONENT applications
213 PROGRAMS ${mksquashfs_INSTALL_DIR}/mksquashfs ${CMAKE_CURRENT_BINARY_DIR}/runtime
215 COMPONENT applications
220 TARGETS AppRun appimagetool digest validate
221 RUNTIME DESTINATION bin COMPONENT applications
222 LIBRARY DESTINATION lib COMPONENT applications
223 ARCHIVE DESTINATION lib/static COMPONENT applications
224 INCLUDES DESTINATION include COMPONENT applications
228 # install libappimage
229 install(TARGETS libappimage
230 EXPORT AppImageKitTargets
231 LIBRARY DESTINATION lib COMPONENT libappimage
232 ARCHIVE DESTINATION lib/static COMPONENT libappimage
233 PUBLIC_HEADER DESTINATION include/appimage COMPONENT libappimage-dev
236 # Add all targets to the build-tree export set
239 FILE "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/AppImageKitTargets.cmake"
242 # Export the package for use from the build-tree
243 # (this registers the build-tree with a global CMake-registry)
244 export(PACKAGE AppImageKit)
246 # Create the AppImageConfig.cmake and AppImageConfigVersion files
248 "${PROJECT_SOURCE_DIR}/cmake/AppImageKitConfig.cmake.in"
249 "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/AppImageKitConfig.cmake"
254 "${PROJECT_SOURCE_DIR}/cmake/AppImageKitConfigVersion.cmake.in"
255 "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/AppImageKitConfigVersion.cmake"
259 # Install the AppImageConfig.cmake and AppImageConfigVersion.cmake
261 "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/AppImageKitConfig.cmake"
262 "${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/AppImageKitConfigVersion.cmake"
263 DESTINATION "lib/cmake/AppImageKit"
264 COMPONENT libappimage-dev
267 # Install the export set for use with the install-tree
268 install(EXPORT AppImageKitTargets
269 DESTINATION "lib/cmake/AppImageKit"
270 COMPONENT libappimage-dev