Update .travis.yml
[appimagekit/gsi.git] / CMakeLists.txt
blob2674a9b343e9a586d9ece1fe6a3e206fe3eefea8
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
3 PROJECT(AppImageKit C)
5 # Set required libraries.
6 set(LIBFUSE "fuse")
7 set(LIBPTHREAD "pthread")
8 set(LIBGLIB2 "glib-2.0")
9 set(LIBZ "z")
11 SET(REQUIRED_LIBRARIES ${LIBFUSE} ${LIBPTHREAD})
12 foreach(LIB ${REQUIRED_LIBRARIES})
13   find_library(FOUND${LIB} ${LIB} PATHS "/lib64" "/usr/lib64")
14   if (NOT FOUND${LIB})
15     message(FATAL_ERROR "The required library '${LIB}' was not found. Please install it on your system first.")
16   endif(NOT FOUND${LIB})
17 endforeach(LIB)
19 ADD_DEFINITIONS(-g -O2 -D_FILE_OFFSET_BITS=64)
21 # Begin find glib
23 if (GLIB_PKG_FOUND)
24     find_path(GLIB_INCLUDE_DIR  NAMES glib.h PATH_SUFFIXES glib-2.0
25        PATHS
26        ${GLIB_PKG_INCLUDE_DIRS}
27        /usr/include/glib-2.0
28        /usr/include
29        /usr/local/include
30     )
31     find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_PKG_LIBDIR} PATH_SUFFIXES glib-2.0/include)
33     find_library(GLIB_LIBRARIES NAMES glib-2.0
34        PATHS
35        ${GLIB_PKG_LIBRARY_DIRS}
36        /usr/lib
37        /usr/local/lib
38     )
40 else (GLIB_PKG_FOUND)
41     # Find Glib even if pkg-config is not working (eg. cross compiling to Windows)
42     find_library(GLIB_LIBRARIES NAMES glib-2.0)
43     string (REGEX REPLACE "/[^/]*$" "" GLIB_LIBRARIES_DIR ${GLIB_LIBRARIES})
45     find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0)
46     find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_LIBRARIES_DIR} PATH_SUFFIXES glib-2.0/include)
48 endif (GLIB_PKG_FOUND)
50 if (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES)
51     set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIB_CONFIG_INCLUDE_DIR})
52 endif (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES)
54 if(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
55    set(GLIB_FOUND TRUE CACHE INTERNAL "glib-2.0 found")
56    message(STATUS "Found glib-2.0: ${GLIB_INCLUDE_DIR}, ${GLIB_LIBRARIES}")
57 else(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
58    set(GLIB_FOUND FALSE CACHE INTERNAL "glib-2.0 found")
59    message(STATUS "glib-2.0 not found.")
60 endif(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
62 mark_as_advanced(GLIB_INCLUDE_DIR GLIB_CONFIG_INCLUDE_DIR GLIB_INCLUDE_DIRS GLIB_LIBRARIES)
64 # End find glib
66 INCLUDE_DIRECTORIES(. ${GLIB_INCLUDE_DIRS})
68 ADD_EXECUTABLE(AppRun AppRun.c)
69 add_custom_command(TARGET AppRun POST_BUILD COMMAND ${CMAKE_STRIP} AppRun)
71 ADD_LIBRARY(fuseiso fuseiso.c)
72 ADD_LIBRARY(isofs isofs.c)
74 ADD_EXECUTABLE(runtime runtime.c)
75 TARGET_LINK_LIBRARIES(runtime fuseiso isofs ${LIBFUSE} ${LIBPTHREAD} ${LIBGLIB2} ${LIBZ})
76 add_custom_command(TARGET runtime POST_BUILD COMMAND ${CMAKE_STRIP} runtime)
78 ADD_CUSTOM_TARGET(AppImageAssistant ALL DEPENDS runtime)
79 ADD_CUSTOM_COMMAND(TARGET AppImageAssistant
80   COMMAND cp runtime AppImageAssistant.AppDir/
81   COMMAND ./binary-dependencies/bundle
82   COMMAND ./AppImageAssistant.AppDir/package ./AppImageAssistant.AppDir ./AppImageAssistant
83   VERBATIM
86 ADD_CUSTOM_TARGET(AppImageExtract ALL DEPENDS AppRun AppImageAssistant)
87 ADD_CUSTOM_COMMAND(TARGET AppImageExtract
88   COMMAND cp AppRun ./AppImageExtract.AppDir
89   COMMAND ./binary-dependencies/bundle
90   COMMAND ./AppImageAssistant.AppDir/package ./AppImageExtract.AppDir ./AppImageExtract
91   VERBATIM
94 SET_DIRECTORY_PROPERTIES(PROPERTIES   
95  ADDITIONAL_MAKE_CLEAN_FILES "AppImageAssistant;AppImageExtract;./AppImageAssistant.AppDir/runtime;./AppImageAssistant.AppDir/usr/share/pyshared/vte.so;./AppImageAssistant.AppDir/usr/lib/;./AppImageExtract.AppDir/AppRun;./AppImageExtract.AppDir/usr/lib/;./AppImageAssistant.AppDir/usr/bin/xorriso;./AppImageExtract.AppDir/usr/bin/xorriso")