Skip to content

Commit

Permalink
Meta: Add a CPack installation target for js(1)
Browse files Browse the repository at this point in the history
This adds a CPack configuration to generate a release package for js(1).
Our current CMake requirement is 3.16, which doesn't have a great story
for automatically installing a binary target's library dependencies. If
we eventually require CMake 3.21 or above, we can remove the helper
.cmake file added here in lieu of RUNTIME_DEPENDENCIES.
  • Loading branch information
trflynn89 authored and alimpfard committed Feb 9, 2022
1 parent a05d25d commit 636a6a2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Meta/Lagom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ if (BUILD_LAGOM)
)

# ELF
# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
# for Lagom on Apple M1
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
file(GLOB LIBELF_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibELF/*.cpp")
Expand Down Expand Up @@ -462,7 +462,7 @@ if (BUILD_LAGOM)
)

# x86
# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
# for Lagom on Apple M1
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
file(GLOB LIBX86_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibX86/*.cpp")
Expand All @@ -484,7 +484,7 @@ if (BUILD_LAGOM)
set_target_properties(adjtime_lagom PROPERTIES OUTPUT_NAME adjtime)
target_link_libraries(adjtime_lagom LagomCore LagomMain)

# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
# FIXME: Excluding arm64 is a temporary hack to circumvent a build problem
# for Lagom on Apple M1
if (NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
add_executable(disasm_lagom ../../Userland/Utilities/disasm.cpp)
Expand Down Expand Up @@ -658,6 +658,20 @@ if (BUILD_LAGOM)
PASS_REGULAR_EXPRESSION "PASS"
)
endforeach()

# FIXME: When we are using CMake >= 3.21, the library installations can be replaced with RUNTIME_DEPENDENCIES.
# https://cmake.org/cmake/help/latest/command/install.html
include(get_linked_lagom_libraries.cmake)
get_linked_lagom_libraries(js_lagom js_lagom_libraries)

install(TARGETS js_lagom ${js_lagom_libraries} COMPONENT js)

set(CPACK_GENERATOR "TGZ")
set(CPACK_STRIP_FILES TRUE)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_COMPONENTS_ALL js)
set(CPACK_PACKAGE_FILE_NAME serenity-js)
include(CPack)
endif()
endif()

Expand Down
34 changes: 34 additions & 0 deletions Meta/Lagom/get_linked_lagom_libraries.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function(add_lagom_library list item)
list(FIND "${list}" "${item}" item_is_present)

if (item_is_present EQUAL -1)
set("${list}" "${${list}}" "${item}" PARENT_SCOPE)
endif()
endfunction()

function(get_linked_lagom_libraries_impl target output)
if (NOT TARGET "${target}")
return()
endif()

get_target_property(target_type "${target}" TYPE)

if ("${target_type}" STREQUAL "SHARED_LIBRARY")
add_lagom_library("${output}" "${target}")
elseif ("${target_type}" STREQUAL "INTERFACE_LIBRARY")
return()
endif()

get_target_property(target_libraries "${target}" LINK_LIBRARIES)

foreach(target_library IN LISTS target_libraries)
get_linked_lagom_libraries_impl("${target_library}" "${output}")
endforeach()

set("${output}" "${${output}}" PARENT_SCOPE)
endfunction()

function(get_linked_lagom_libraries target output)
get_linked_lagom_libraries_impl(${target} ${output})
set("${output}" "${${output}}" PARENT_SCOPE)
endfunction()

0 comments on commit 636a6a2

Please sign in to comment.