From 488da351c057226801e3e9b93ecbdf92d55f18aa Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Fri, 16 Sep 2022 04:08:24 -0600 Subject: [PATCH] Ladybird/CMake: Install resources and Lagom libraries alongside ladybird This setup should allow the package maintainers who are looking to distribute ladybird on their distributions to use CMake to install ladybird using cmake install rules rather than having to write their own --- Ladybird/CMakeLists.txt | 12 ++-- Ladybird/cmake/InstallRules.cmake | 75 ++++++++++++++++++++++ Ladybird/cmake/LadybirdInstallConfig.cmake | 1 + 3 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 Ladybird/cmake/InstallRules.cmake create mode 100644 Ladybird/cmake/LadybirdInstallConfig.cmake diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index cdbacedde96..49692399f5e 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -6,6 +6,8 @@ project(ladybird DESCRIPTION "Ladybird Web Browser" ) +include(GNUInstallDirs) + if (ANDROID) set(BUILD_SHARED_LIBS OFF) endif() @@ -19,7 +21,7 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # See slide 100 of the following ppt :^) # https://crascit.com/wp-content/uploads/2019/09/Deep-CMake-For-Library-Authors-Craig-Scott-CppCon-2019.pdf if (NOT APPLE) - set(CMAKE_INSTALL_RPATH $ORIGIN) + set(CMAKE_INSTALL_RPATH $ORIGIN;$ORIGIN/../${CMAKE_INSTALL_LIBDIR}) endif() set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -92,8 +94,6 @@ add_custom_target(debug qt_finalize_executable(ladybird) -install(TARGETS ladybird - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - BUNDLE DESTINATION bundle - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -) +if(NOT CMAKE_SKIP_INSTALL_RULES) + include(cmake/InstallRules.cmake) +endif() diff --git a/Ladybird/cmake/InstallRules.cmake b/Ladybird/cmake/InstallRules.cmake new file mode 100644 index 00000000000..04a222f5be6 --- /dev/null +++ b/Ladybird/cmake/InstallRules.cmake @@ -0,0 +1,75 @@ + +include(CMakePackageConfigHelpers) +include(GNUInstallDirs) + +set(package ladybird) + +install(TARGETS ladybird + EXPORT ladybirdTargets + RUNTIME + COMPONENT ladybird_Runtime + DESTINATION ${CMAKE_INSTALL_BINDIR} + BUNDLE + COMPONENT ladybird_Runtime + DESTINATION bundle + LIBRARY + COMPONENT ladybird_Runtime + NAMELINK_COMPONENT ladybird_Development + DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +include("${Lagom_SOURCE_DIR}/get_linked_lagom_libraries.cmake") +get_linked_lagom_libraries(ladybird ladybird_lagom_libraries) + +install(TARGETS ${ladybird_lagom_libraries} + EXPORT ladybirdTargets + COMPONENT ladybird_Runtime + LIBRARY + COMPONENT ladybird_Runtime + NAMELINK_COMPONENT ladybird_Development + DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +write_basic_package_version_file( + "${package}ConfigVersion.cmake" + COMPATIBILITY SameMajorVersion +) + +# Allow package maintainers to freely override the path for the configs +set( + ladybird_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${package}" + CACHE PATH "CMake package config location relative to the install prefix" +) +mark_as_advanced(ladybird_INSTALL_CMAKEDIR) + +install( + FILES cmake/LadybirdInstallConfig.cmake + DESTINATION "${ladybird_INSTALL_CMAKEDIR}" + RENAME "${package}Config.cmake" + COMPONENT ladybird_Development +) + +install( + FILES "${PROJECT_BINARY_DIR}/${package}ConfigVersion.cmake" + DESTINATION "${ladybird_INSTALL_CMAKEDIR}" + COMPONENT ladybird_Development +) + +install( + EXPORT ladybirdTargets + NAMESPACE ladybird:: + DESTINATION "${ladybird_INSTALL_CMAKEDIR}" + COMPONENT ladybird_Development +) + +install(DIRECTORY + "${SERENITY_SOURCE_DIR}/Base/res/html" + "${SERENITY_SOURCE_DIR}/Base/res/fonts" + "${SERENITY_SOURCE_DIR}/Base/res/icons" + "${SERENITY_SOURCE_DIR}/Base/res/themes" + "${SERENITY_SOURCE_DIR}/Base/res/color-palettes" + "${SERENITY_SOURCE_DIR}/Base/res/cursor-themes" + DESTINATION "${CMAKE_INSTALL_DATADIR}/res" + USE_SOURCE_PERMISSIONS MESSAGE_NEVER + COMPONENT ladybird_Runtime +) diff --git a/Ladybird/cmake/LadybirdInstallConfig.cmake b/Ladybird/cmake/LadybirdInstallConfig.cmake new file mode 100644 index 00000000000..b308ac1c0a7 --- /dev/null +++ b/Ladybird/cmake/LadybirdInstallConfig.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/ladybirdTargets.cmake")