@@ -30,49 +30,54 @@ set(CFLAGS ${DEPENDENCIES_CFLAGS})
3030set (CPPFLAGS ${DEPENDENCIES_CPPFLAGS} )
3131set (LDFLAGS ${DEPENDENCIES_LDFLAGS} )
3232
33+ set (USE_SYSTEM_MKSQUASHFS OFF CACHE BOOL "Use system mksquashfs instead of downloading and building our own. Warning: you need a recent version otherwise it might not work as intended." )
3334
34- # TODO: allow using system wide mksquashfs
35- set (mksquashfs_cflags "-DXZ_SUPPORT ${CFLAGS} " )
35+ if ( NOT USE_SYSTEM_MKSQUASHFS)
36+ set (mksquashfs_cflags "-DXZ_SUPPORT ${CFLAGS} " )
3637
37- if (NOT xz_LIBRARIES OR xz_LIBRARIES STREQUAL "" )
38- message (FATAL_ERROR "xz_LIBRARIES not set" )
39- elseif (xz_LIBRARIES MATCHES "\\ .a$" )
40- set (mksquashfs_ldflags "${xz_LIBRARIES} " )
41- else ()
42- set (mksquashfs_ldflags "-l${xz_LIBRARIES} " )
43- endif ()
38+ if (NOT xz_LIBRARIES OR xz_LIBRARIES STREQUAL "" )
39+ message (FATAL_ERROR "xz_LIBRARIES not set" )
40+ elseif (xz_LIBRARIES MATCHES "\\ .a$" )
41+ set (mksquashfs_ldflags "${xz_LIBRARIES} " )
42+ else ()
43+ set (mksquashfs_ldflags "-l${xz_LIBRARIES} " )
44+ endif ()
4445
45- if (xz_INCLUDE_DIRS)
46- set (mksquashfs_cflags "${mksquashfs_cflags} -I${xz_INCLUDE_DIRS} " )
47- endif ()
48- if (xz_LIBRARY_DIRS)
49- set (mksquashfs_ldflags "${mksquashfs_ldflags} -L${xz_LIBRARY_DIRS} " )
50- endif ()
46+ if (xz_INCLUDE_DIRS)
47+ set (mksquashfs_cflags "${mksquashfs_cflags} -I${xz_INCLUDE_DIRS} " )
48+ endif ()
49+ if (xz_LIBRARY_DIRS)
50+ set (mksquashfs_ldflags "${mksquashfs_ldflags} -L${xz_LIBRARY_DIRS} " )
51+ endif ()
5152
52- ExternalProject_Add(mksquashfs
53- GIT_REPOSITORY https://github.com/plougher/squashfs-tools/
54- GIT_TAG 4.4
55- UPDATE_COMMAND "" # Make sure CMake won't try to fetch updates unnecessarily and hence rebuild the dependency every time
56- CONFIGURE_COMMAND ${SED} -i "s|CFLAGS += -DXZ_SUPPORT|CFLAGS += ${mksquashfs_cflags} |g" <SOURCE_DIR>/squashfs-tools/Makefile
57- COMMAND ${SED} -i "s|LIBS += -llzma|LIBS += -Bstatic ${mksquashfs_ldflags} |g" <SOURCE_DIR>/squashfs-tools/Makefile
58- COMMAND ${SED} -i "s|install: mksquashfs unsquashfs|install: mksquashfs|g" squashfs-tools/Makefile
59- COMMAND ${SED} -i "/cp unsquashfs/d" squashfs-tools/Makefile
60- BUILD_COMMAND env CC=${CC} CXX=${CXX} LDFLAGS=${LDFLAGS} ${MAKE} -C squashfs-tools/ XZ_SUPPORT=1 mksquashfs
61- # ${MAKE} install unfortunately expects unsquashfs to be built as well, hence can't install the binary
62- # therefore using built file in SOURCE_DIR
63- # TODO: implement building out of source
64- BUILD_IN_SOURCE ON
65- INSTALL_COMMAND ${MAKE} -C squashfs-tools/ install INSTALL_DIR=<INSTALL_DIR>
66- )
67-
68- ExternalProject_Get_Property(mksquashfs INSTALL_DIR)
69- set (mksquashfs_INSTALL_DIR "${INSTALL_DIR} " )
70- mark_as_advanced (mksquashfs_INSTALL_DIR)
71-
72- # for later use when packaging as an AppImage
73- set (mksquashfs_BINARY "${mksquashfs_INSTALL_DIR} /mksquashfs" )
74- mark_as_advanced (mksquashfs_BINARY)
53+ ExternalProject_Add(mksquashfs
54+ GIT_REPOSITORY https://github.com/plougher/squashfs-tools/
55+ GIT_TAG 4.4
56+ UPDATE_COMMAND "" # Make sure CMake won't try to fetch updates unnecessarily and hence rebuild the dependency every time
57+ CONFIGURE_COMMAND ${SED} -i "s|CFLAGS += -DXZ_SUPPORT|CFLAGS += ${mksquashfs_cflags} |g" <SOURCE_DIR>/squashfs-tools/Makefile
58+ COMMAND ${SED} -i "s|LIBS += -llzma|LIBS += -Bstatic ${mksquashfs_ldflags} |g" <SOURCE_DIR>/squashfs-tools/Makefile
59+ COMMAND ${SED} -i "s|install: mksquashfs unsquashfs|install: mksquashfs|g" squashfs-tools/Makefile
60+ COMMAND ${SED} -i "/cp unsquashfs/d" squashfs-tools/Makefile
61+ BUILD_COMMAND env CC=${CC} CXX=${CXX} LDFLAGS=${LDFLAGS} ${MAKE} -C squashfs-tools/ XZ_SUPPORT=1 mksquashfs
62+ # ${MAKE} install unfortunately expects unsquashfs to be built as well, hence can't install the binary
63+ # therefore using built file in SOURCE_DIR
64+ # TODO: implement building out of source
65+ BUILD_IN_SOURCE ON
66+ INSTALL_COMMAND ${MAKE} -C squashfs-tools/ install INSTALL_DIR=<INSTALL_DIR>
67+ )
68+
69+ ExternalProject_Get_Property(mksquashfs INSTALL_DIR)
70+ set (mksquashfs_INSTALL_DIR "${INSTALL_DIR} " )
71+ mark_as_advanced (mksquashfs_INSTALL_DIR)
72+
73+ # for later use when packaging as an AppImage
74+ set (mksquashfs_BINARY "${mksquashfs_INSTALL_DIR} /mksquashfs" )
75+ mark_as_advanced (mksquashfs_BINARY)
76+ else ()
77+ message (STATUS "Using system mksquashfs" )
7578
79+ set (mksquashfs_BINARY "mksquashfs" )
80+ endif ()
7681
7782#### build dependency configuration ####
7883
0 commit comments