Skip to content

Commit

Permalink
Fix cmake < 3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed May 14, 2024
1 parent 16d15be commit 0ec5a22
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 48 deletions.
72 changes: 36 additions & 36 deletions cmake/apple/CPackDMG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ set(COMMAND_ECHO NONE)

# Detect release|debug build
if(NOT CPACK_STRIP_FILES_ORIG)
# -use-debug-libs implies -no-strip
set(USE_DEBUG_LIBS -use-debug-libs)
# -use-debug-libs implies -no-strip
set(USE_DEBUG_LIBS -use-debug-libs)
endif()

if(CPACK_DEBUG)
Expand All @@ -18,10 +18,10 @@ if(CPACK_DEBUG)
endif()

execute_process(COMMAND convert
"${CPACK_CURRENT_SOURCE_DIR}/*.png"
"${CPACK_CURRENT_BINARY_DIR}/background.tiff"
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)
"${CPACK_CURRENT_SOURCE_DIR}/*.png"
"${CPACK_CURRENT_BINARY_DIR}/background.tiff"
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)

# Copy missing files
file(COPY "${CPACK_CURRENT_SOURCE_DIR}/project.icns" DESTINATION "${APP}/Contents/Resources")
Expand All @@ -40,9 +40,9 @@ file(MAKE_DIRECTORY "${APP}/Contents/Resources")

# Make all libraries writable for macdeployqt
file(CHMOD_RECURSE "${APP}/Contents" PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_WRITE GROUP_READ
WORLD_READ)
OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_EXECUTE GROUP_WRITE GROUP_READ
WORLD_READ)

# Fix layout
file(RENAME "${APP}/Contents/Resources/lib" "${APP}/Contents/lib")
Expand All @@ -58,17 +58,17 @@ file(REMOVE_RECURSE "${APP}/Contents/include")

# Replace @rpath with @loader_path for Carla
execute_process(COMMAND install_name_tool -change
"@rpath/libcarlabase.dylib"
"@loader_path/libcarlabase.dylib"
"${APP}/Contents/lib/lmms/libcarlapatchbay.so"
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)
"@rpath/libcarlabase.dylib"
"@loader_path/libcarlabase.dylib"
"${APP}/Contents/lib/lmms/libcarlapatchbay.so"
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND install_name_tool -change
"@rpath/libcarlabase.dylib"
"@loader_path/libcarlabase.dylib"
"${APP}/Contents/lib/lmms/libcarlarack.so"
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)
"@rpath/libcarlabase.dylib"
"@loader_path/libcarlabase.dylib"
"${APP}/Contents/lib/lmms/libcarlarack.so"
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)

# Build list of executables to inform macdeployqt about
# e.g. -executable=foo.dylib -executable=bar.dylib
Expand All @@ -80,36 +80,36 @@ list(SORT LIBS)

# Construct macdeployqt parameters
foreach(_LIB IN LISTS LIBS)
list(APPEND EXECUTABLES "-executable=${_LIB}")
list(APPEND EXECUTABLES "-executable=${_LIB}")
endforeach()

# Call macdeployqt
get_filename_component(QTBIN "${CPACK_QMAKE_EXECUTABLE}" DIRECTORY)
message(STATUS "Calling ${QTBIN}/macdeployqt ${APP} [... executables]")
execute_process(COMMAND "${QTBIN}/macdeployqt" "${APP}" ${EXECUTABLES}
-verbose=${VERBOSITY}
${USE_DEBUG_LIBS}
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)
-verbose=${VERBOSITY}
${USE_DEBUG_LIBS}
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)

# Remove dummy carla libs, relink to a sane location (e.g. /Applications/Carla.app/...)
# (must be done after calling macdeployqt)
file(GLOB CARLALIBS "${APP}/Contents/lib/lmms/libcarla*")
foreach(_CARLALIB IN LISTS CARLALIBS)
foreach(_LIB "${CPACK_CARLA_LIBRARIES}")
set(_OLDPATH "../../Frameworks/lib${_LIB}.dylib")
set(_NEWPATH "Carla.app/Contents/MacOS/lib${_LIB}.dylib")
execute_process(COMMAND install_name_tool -change
"@loader_path/${_OLDPATH}"
"@executable_path/../../../${_NEWPATH}"
"${_CARLALIB}"
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)
foreach(_LIB "${CPACK_CARLA_LIBRARIES}")
set(_OLDPATH "../../Frameworks/lib${_LIB}.dylib")
set(_NEWPATH "Carla.app/Contents/MacOS/lib${_LIB}.dylib")
execute_process(COMMAND install_name_tool -change
"@loader_path/${_OLDPATH}"
"@executable_path/../../../${_NEWPATH}"
"${_CARLALIB}"
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)
file(REMOVE "${APP}/Contents/Frameworks/lib${_LIB}.dylib")
endforeach()
endforeach()
endforeach()

# Call ad-hoc codesign manually (CMake offers this as well)
execute_process(COMMAND codesign --force --deep --sign - "${APP}"
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)
19 changes: 11 additions & 8 deletions cmake/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
install(DIRECTORY icons DESTINATION "${DATA_DIR}/icons/hicolor")
install(FILES lmms.desktop DESTINATION "${DATA_DIR}/applications")
install(FILES lmms.xml DESTINATION "${DATA_DIR}/mime/packages")
# Copy rawwaves into bundle
file(GLOB RAWWAVES "${STK_RAWWAVE_ROOT}/*.raw")
install(FILES ${RAWWAVES} DESTINATION "usr/share/stk")

# Preserve old CPack behavior
if(WANT_CPACK_TARBALL)
message(STATUS "Skipping AppImage creation")
return()
message(STATUS "Skipping AppImage creation")
return()
endif()

# Copy rawwaves into bundle
file(GLOB RAWWAVES "${STK_RAWWAVE_ROOT}/*.raw")
install(FILES ${RAWWAVES} DESTINATION share/stk)

install(FILES launch_lmms.sh DESTINATION bin)

# Standard CPack options
set(CPACK_GENERATOR "External" PARENT_SCOPE)
set(CPACK_EXTERNAL_ENABLE_STAGING true PARENT_SCOPE)
Expand All @@ -34,11 +37,11 @@ set(CPACK_CMAKE_COMMAND "${CMAKE_COMMAND}" PARENT_SCOPE)

# TODO: Canidate for DetectMachine.cmake
if(IS_X86_64)
set(CPACK_TARGET_ARCH x86_64 PARENT_SCOPE)
set(CPACK_TARGET_ARCH x86_64 PARENT_SCOPE)
elseif(IS_ARM64)
set(CPACK_TARGET_ARCH arm64 PARENT_SCOPE)
set(CPACK_TARGET_ARCH arm64 PARENT_SCOPE)
else()
set(CPACK_TARGET_ARCH unknown PARENT_SCOPE)
set(CPACK_TARGET_ARCH unknown PARENT_SCOPE)
endif()

set(CPACK_PRE_BUILD_SCRIPTS "${CMAKE_CURRENT_SOURCE_DIR}/CPackAppImage.cmake" PARENT_SCOPE)
8 changes: 6 additions & 2 deletions cmake/linux/CPackAppImage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ endif()

# Create a wrapper script which calls the lmms executable
file(RENAME "${APP}/usr/bin/${LMMS}" "${APP}/usr/bin/${LMMS}.real")
file(COPY "${CPACK_CURRENT_SOURCE_DIR}/launch_lmms.sh" DESTINATION "${APP}/usr/bin/${LMMS}")
file(RENAME "${APP}/usr/bin/launch_lmms.sh" "${APP}/usr/bin/${LMMS}")
# Ensure the file is executable
file(CHMOD "${APP}/usr/bin/${LMMS}" PERMISSIONS
OWNER_EXECUTE OWNER_WRITE OWNER_READ
Expand Down Expand Up @@ -200,4 +200,8 @@ execute_process(COMMAND appimagetool
COMMAND_ECHO ${COMMAND_ECHO}
COMMAND_ERROR_IS_FATAL ANY)

message(STATUS "AppImage create: ${APPIMAGE_FILE}")
if(EXISTS "${APPIMAGE_FILE}")
message(STATUS "AppImage create: ${APPIMAGE_FILE}")
else()
message(FATAL_ERROR "An error occured generating the AppImage")
endif()
5 changes: 3 additions & 2 deletions cmake/modules/BashCompletion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ macro(BASHCOMP_INSTALL SCRIPT_NAME)
else()
install(FILES "${SCRIPT_NAME}" DESTINATION "${BASHCOMP_USER_PATH}")
if(BASHCOMP_PKG_PATH)
# TODO: CMake 3.21 Use "file(COPY_FILE ...)"
install(CODE "
file(COPY_FILE \"${SCRIPT_NAME}\" \"${BASHCOMP_PKG_PATH}\" RESULT result)
if(NOT result EQUAL \"0\")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy \"${SCRIPT_NAME}\" \"${BASHCOMP_PKG_PATH}\" ERROR_QUIET RESULT_VARIABLE result)
if(NOT result EQUAL 0)
message(STATUS \"Unable to install bash-completion support system-wide: ${BASHCOMP_USER_PATH}/${SCRIPT_NAME}. This is normal for user-space installs.\")
else()
message(STATUS \"Bash completion-support has been installed to ${BASHCOMP_USER_PATH}/${SCRIPT_NAME}\")
Expand Down

0 comments on commit 0ec5a22

Please sign in to comment.