Add ability to install individual components

This change allows you to build multiple components and still choose to
install only some of them using CMake's `cmake_install.cmake` script.
This commit is contained in:
Ariel Abreu 2023-05-01 11:54:46 -04:00 committed by Thomas A
parent 1ad855c8ff
commit 1edcfebc27
11 changed files with 130 additions and 21 deletions

View File

@ -46,6 +46,8 @@ project(darling)
cmake_minimum_required(VERSION 3.10)
enable_language(ASM)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "core")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(InstallSymlink)
include(MacroEnsureOutOfSourceBuild)
@ -107,7 +109,13 @@ option(DEBIAN_PACKAGING "Packaging for Debian" OFF)
option(ENABLE_TESTS "Install in-prefix unit tests" OFF)
option(REGENERATE_SDK "Regenerate Header Files For Open Source SDK" OFF)
set(COMPONENTS "stock" CACHE STRING "Choose which components of Darling to build")
if (DEBIAN_PACKAGING)
set(COMPONENTS_DEFAULT "all")
else()
set(COMPONENTS_DEFAULT "stock")
endif()
set(COMPONENTS "${COMPONENTS_DEFAULT}" CACHE STRING "Choose which components of Darling to build")
include(darling_parse_components)
darling_parse_components("${COMPONENTS}")

View File

@ -14,15 +14,29 @@
# _sympath: absolute path of the installed symlink
macro(InstallSymlink _filepath _sympath)
cmake_parse_arguments(INSTALL_SYMLINK "EXCLUDE_FROM_ALL" "COMPONENT" "" ${ARGN})
get_filename_component(_symname ${_sympath} NAME)
get_filename_component(_installdir ${_sympath} PATH)
if (INSTALL_SYMLINK_EXCLUDE_FROM_ALL)
set(EXCLUDE_FROM_ALL_ARG "EXCLUDE_FROM_ALL")
else()
set(EXCLUDE_FROM_ALL_ARG "")
endif()
if (DEFINED INSTALL_SYMLINK_COMPONENT)
set(COMPONENT_ARG COMPONENT "${INSTALL_SYMLINK_COMPONENT}")
else()
set(COMPONENT_ARG "")
endif()
if (BINARY_PACKAGING_MODE)
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink
${_filepath}
${CMAKE_CURRENT_BINARY_DIR}/${_symname})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_symname}
DESTINATION ${_installdir})
DESTINATION ${_installdir} ${EXCLUDE_FROM_ALL_ARG} ${COMPONENT_ARG})
else ()
# scripting the symlink installation at install time should work
# for CMake 2.6.x and 2.8.x
@ -38,6 +52,6 @@ macro(InstallSymlink _filepath _sympath)
${_filepath}
\$ENV{DESTDIR}/${_installdir}/${_symname})
endif ()
")
" ${EXCLUDE_FROM_ALL_ARG} ${COMPONENT_ARG})
endif ()
endmacro(InstallSymlink)

View File

@ -7,9 +7,15 @@ define_property(TARGET PROPERTY DYLIB_INSTALL_NAME BRIEF_DOCS "Stores the DYLIB_
FULL_DOCS "Used to make reexporting child frameworks less painful.")
function(add_framework name)
cmake_parse_arguments(FRAMEWORK "CURRENT_VERSION;FAT;PRIVATE;IOSSUPPORT;CIRCULAR;NO_INSTALL" "VERSION;LINK_FLAGS;PARENT;PARENT_VERSION;TARGET_NAME"
cmake_parse_arguments(FRAMEWORK "CURRENT_VERSION;FAT;PRIVATE;IOSSUPPORT;CIRCULAR;NO_INSTALL" "VERSION;LINK_FLAGS;PARENT;PARENT_VERSION;TARGET_NAME;PARENT_COMPONENT"
"SOURCES;DEPENDENCIES;CIRCULAR_DEPENDENCIES;RESOURCES;UPWARD_DEPENDENCIES;OBJECTS;STRONG_DEPENDENCIES" ${ARGN})
if (FRAMEWORK_NO_INSTALL)
set(EXCLUDE_FROM_ALL_ARG "EXCLUDE_FROM_ALL")
else()
set(EXCLUDE_FROM_ALL_ARG "")
endif()
if (DEFINED FRAMEWORK_TARGET_NAME)
set(my_name "${FRAMEWORK_TARGET_NAME}")
elseif (FRAMEWORK_CURRENT_VERSION)
@ -35,10 +41,14 @@ function(add_framework name)
# 99% of the time it's version A
set(FRAMEWORK_PARENT_VERSION "A")
endif(NOT DEFINED FRAMEWORK_PARENT_VERSION)
if (NOT FRAMEWORK_NO_INSTALL)
InstallSymlink(Versions/Current/Frameworks
"${CMAKE_INSTALL_PREFIX}/libexec/darling/${sys_library_dir}/${dir_name}/${FRAMEWORK_PARENT}.framework/Frameworks")
if (DEFINED FRAMEWORK_PARENT_COMPONENT)
set(COMPONENT_ARG COMPONENT "${FRAMEWORK_PARENT_COMPONENT}")
else()
set(COMPONENT_ARG "")
endif()
InstallSymlink(Versions/Current/Frameworks
"${CMAKE_INSTALL_PREFIX}/libexec/darling/${sys_library_dir}/${dir_name}/${FRAMEWORK_PARENT}.framework/Frameworks"
${EXCLUDE_FROM_ALL_ARG} ${COMPONENT_ARG})
set(dir_name "${dir_name}/${FRAMEWORK_PARENT}.framework/Versions/${FRAMEWORK_PARENT_VERSION}/Frameworks")
endif(DEFINED FRAMEWORK_PARENT)
@ -88,13 +98,11 @@ function(add_framework name)
set_property(TARGET ${my_name} APPEND_STRING PROPERTY LINK_FLAGS " ${FRAMEWORK_LINK_FLAGS}")
endif (FRAMEWORK_LINK_FLAGS)
if (NOT FRAMEWORK_NO_INSTALL)
install(TARGETS ${my_name} DESTINATION "libexec/darling/${sys_library_dir}/${dir_name}/${name}.framework/Versions/${FRAMEWORK_VERSION}/")
endif()
install(TARGETS ${my_name} DESTINATION "libexec/darling/${sys_library_dir}/${dir_name}/${name}.framework/Versions/${FRAMEWORK_VERSION}/" ${EXCLUDE_FROM_ALL_ARG})
if (FRAMEWORK_RESOURCES AND NOT FRAMEWORK_NO_INSTALL)
if (FRAMEWORK_RESOURCES)
if (FRAMEWORK_CURRENT_VERSION)
InstallSymlink("Versions/Current/Resources" "${CMAKE_INSTALL_PREFIX}/libexec/darling/${sys_library_dir}/${dir_name}/${name}.framework/Resources")
InstallSymlink("Versions/Current/Resources" "${CMAKE_INSTALL_PREFIX}/libexec/darling/${sys_library_dir}/${dir_name}/${name}.framework/Resources" ${EXCLUDE_FROM_ALL_ARG})
endif (FRAMEWORK_CURRENT_VERSION)
while (FRAMEWORK_RESOURCES)
list(GET FRAMEWORK_RESOURCES 0 res_install_path)
@ -103,14 +111,14 @@ function(add_framework name)
get_filename_component(res_install_name ${res_install_path} NAME)
install(FILES ${res_source_path}
DESTINATION libexec/darling/${sys_library_dir}/${dir_name}/${name}.framework/Versions/${FRAMEWORK_VERSION}/Resources/${res_install_dir}
RENAME ${res_install_name})
RENAME ${res_install_name} ${EXCLUDE_FROM_ALL_ARG})
list(REMOVE_AT FRAMEWORK_RESOURCES 0 1)
endwhile (FRAMEWORK_RESOURCES)
endif()
if (FRAMEWORK_CURRENT_VERSION AND NOT FRAMEWORK_NO_INSTALL)
InstallSymlink(${FRAMEWORK_VERSION} "${CMAKE_INSTALL_PREFIX}/libexec/darling/${sys_library_dir}/${dir_name}/${name}.framework/Versions/Current")
InstallSymlink("Versions/Current/${name}" "${CMAKE_INSTALL_PREFIX}/libexec/darling/${sys_library_dir}/${dir_name}/${name}.framework/${name}")
if (FRAMEWORK_CURRENT_VERSION)
InstallSymlink(${FRAMEWORK_VERSION} "${CMAKE_INSTALL_PREFIX}/libexec/darling/${sys_library_dir}/${dir_name}/${name}.framework/Versions/Current" ${EXCLUDE_FROM_ALL_ARG})
InstallSymlink("Versions/Current/${name}" "${CMAKE_INSTALL_PREFIX}/libexec/darling/${sys_library_dir}/${dir_name}/${name}.framework/${name}" ${EXCLUDE_FROM_ALL_ARG})
endif()
endfunction(add_framework)

View File

@ -1,6 +1,14 @@
function(dsym target)
cmake_parse_arguments(DSYM "EXCLUDE_FROM_ALL" "" "" ${ARGN})
string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type)
if (DSYM_EXCLUDE_FROM_ALL)
set(EXCLUDE_FROM_ALL_ARG "EXCLUDE_FROM_ALL")
else()
set(EXCLUDE_FROM_ALL_ARG "")
endif()
if (DSYMUTIL_EXE AND build_type MATCHES debug)
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}.dSYM" DEPENDS "${target}" COMMAND ${CMAKE_COMMAND} -E env
@ -9,8 +17,8 @@ function(dsym target)
add_custom_target("${target}-dSYM" ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target}.dSYM" getuuid lipo)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${target}.dSYM" DESTINATION "${CMAKE_INSTALL_PREFIX}/libexec/darling/System/Library/Caches/dsym/files")
install(DIRECTORY DESTINATION "${CMAKE_INSTALL_PREFIX}/libexec/darling/System/Library/Caches/dsym/uuid")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${target}.dSYM" DESTINATION "${CMAKE_INSTALL_PREFIX}/libexec/darling/System/Library/Caches/dsym/files" ${EXCLUDE_FROM_ALL_ARG})
install(DIRECTORY DESTINATION "${CMAKE_INSTALL_PREFIX}/libexec/darling/System/Library/Caches/dsym/uuid" ${EXCLUDE_FROM_ALL_ARG})
install(CODE "execute_process(COMMAND \"${CMAKE_BINARY_DIR}/src/buildtools/getuuid\" \"${CMAKE_CURRENT_BINARY_DIR}/${target}.dSYM\" RESULT_VARIABLE getuuid_result OUTPUT_VARIABLE macho_uuid)
@ -26,7 +34,7 @@ function(dsym target)
\$ENV{DESTDIR}/${CMAKE_INSTALL_PREFIX}/libexec/darling/System/Library/Caches/dsym/uuid/\${uuid}.dSYM)
endforeach (uuid)
endif()
")
" ${EXCLUDE_FROM_ALL_ARG})
endif ()
endfunction(dsym)

View File

@ -25,6 +25,8 @@ include(pyc)
# these projects are always built
#
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "core")
#add_subdirectory(external/xcbuild)
add_subdirectory(bsdln)
@ -203,6 +205,8 @@ add_subdirectory(external/ncurses)
#
if (COMPONENT_system)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "system")
add_subdirectory(external/libiconv)
add_subdirectory(external/bzip2)
add_subdirectory(external/libressl-2.8.3)
@ -219,6 +223,8 @@ if (COMPONENT_system)
endif()
if (COMPONENT_cli)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli")
add_subdirectory(external/darling-dmg)
add_subdirectory(external/libutil)
add_subdirectory(xtrace)
@ -280,14 +286,18 @@ if (COMPONENT_cli)
endif()
if (COMPONENT_python OR COMPONENT_ruby)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "ffi")
add_subdirectory(external/libffi)
endif()
if (COMPONENT_cli_dev)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_dev")
add_subdirectory(libgmalloc)
endif()
if (COMPONENT_cli OR COMPONENT_dev_gui_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_gui_common")
add_subdirectory(external/libxml2)
add_subdirectory(external/foundation)
add_subdirectory(external/cfnetwork/src)
@ -313,19 +323,26 @@ if (COMPONENT_cli OR COMPONENT_dev_gui_common)
endif()
if (COMPONENT_iokitd)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME iokitd)
add_subdirectory(external/iokitd)
endif()
if (COMPONENT_dev_gui_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_dev_gui_common")
add_subdirectory(libaccessibility)
add_subdirectory(external/openjdk) # *should* be in `cli` component, but requires AppKit
endif()
if (COMPONENT_cli_extra)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_extra")
add_subdirectory(external/gnutar/gnutar)
endif()
if (COMPONENT_gui)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "gui")
add_subdirectory(external/cocotron)
add_subdirectory(CoreAudio)
@ -337,26 +354,36 @@ if (COMPONENT_gui)
endif()
if (COMPONENT_python)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "python")
add_subdirectory(external/python_modules)
add_subdirectory(external/python/2.7/Python-2.7.16)
endif()
if (COMPONENT_cli OR COMPONENT_python)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_python_common")
add_subdirectory(external/BerkeleyDB)
add_subdirectory(external/expat)
endif()
if (COMPONENT_gui_frameworks AND COMPONENT_gui_stubs AND COMPONENT_python)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "pyobjc")
# TODO: pyobjc should only build individual modules if the respective components are enabled.
# right now, it's all-or-nothing.
add_subdirectory(external/pyobjc)
endif()
if (COMPONENT_ruby)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "ruby")
add_subdirectory(external/ruby)
endif()
if (COMPONENT_perl)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "perl")
add_subdirectory(external/perl)
endif()
@ -395,6 +422,8 @@ include_directories(BEFORE
# start core components with C++
#
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "core")
add_subdirectory(external/libcxxabi)
add_subdirectory(external/libcxx)
@ -406,26 +435,36 @@ add_subdirectory(external/cctools)
#
if (COMPONENT_cli OR COMPONENT_dev_gui_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_gui_common")
add_subdirectory(external/SmartCardServices)
add_subdirectory(external/security)
add_subdirectory(external/SecurityTokend)
endif()
if (COMPONENT_cli)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli")
add_subdirectory(external/dtrace)
add_subdirectory(external/libauto)
endif()
if (COMPONENT_dev_gui_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_dev_gui_common")
add_subdirectory(external/metal)
endif()
if (COMPONENT_jsc OR COMPONENT_webkit)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "jsc_webkit_common")
add_subdirectory(external/WTF)
add_subdirectory(external/bmalloc)
endif()
if (COMPONENT_jsc)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "jsc")
add_subdirectory(external/JavaScriptCore)
endif()

@ -1 +1 @@
Subproject commit 605de48441f45243e79428478d7bd7d840bb3c0d
Subproject commit b61a4f075726e7d5ef4652033f8d7b829c008d06

@ -1 +1 @@
Subproject commit d10ae7852dc951358470761ba74026061949ac32
Subproject commit 18a33aa40da5e0dc5329ccfb86399f6c3a7393e6

View File

@ -1,6 +1,8 @@
project(frameworks)
if (COMPONENT_system)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "system")
# for memberd
add_subdirectory(DirectoryServices)
endif()
@ -8,6 +10,8 @@ endif()
# this is mainly for frameworks that are required for Security,
# since Security is built for both CLI and GUI
if (COMPONENT_cli OR COMPONENT_dev_gui_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_gui_common")
add_subdirectory(CoreServices)
# these are also stubs, but they're needed for Security
@ -27,12 +31,16 @@ if (COMPONENT_cli OR COMPONENT_dev_gui_common)
endif()
if (COMPONENT_iokitd OR COMPONENT_dev_gui_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "iokitd_cli_dev_gui_common")
# this is for iokitd (and Xcode)
add_subdirectory(IOSurface)
endif()
# this is mainly for anything that Xcode requires to run on the CLI
if (COMPONENT_dev_gui_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_dev_gui_common")
add_subdirectory(ApplicationServices)
add_subdirectory(ColorSync)
add_subdirectory(Carbon)
@ -44,6 +52,8 @@ endif()
# same here, except this is for stubs that Xcode needs
if (COMPONENT_dev_gui_stubs_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_dev_gui_stubs_common")
add_subdirectory(Accelerate)
add_subdirectory(AVFoundation)
add_subdirectory(Contacts)
@ -61,12 +71,16 @@ endif()
# this is for core GUI frameworks with actual implementations
if (COMPONENT_gui)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "gui")
add_subdirectory(OpenGL)
add_subdirectory(ImageIO)
endif()
# this is for all the other stubbed frameworks
if (COMPONENT_gui_stubs)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "gui_stubs")
add_subdirectory(AddressBook)
add_subdirectory(AGL)
add_subdirectory(AuthenticationServices)
@ -121,6 +135,8 @@ endif()
#if (COMPONENT_dev_gui_common AND NOT COMPONENT_webkit)
if (COMPONENT_dev_gui_common OR COMPONENT_webkit)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_dev_gui_common")
# stub
add_subdirectory(WebKit)
endif()
@ -130,6 +146,8 @@ endif()
# Darling packages; we need to build a package that has these stubs available to be able to install Darling for CLI development
# without GUI dependencies like X11.
if ((COMPONENT_cli_dev AND NOT COMPONENT_gui) OR COMPONENT_cli_dev_gui_stubs)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_dev")
# if we're building the GUI components (i.e. Cocotron), don't install these stubs
if (COMPONENT_gui)
set(NO_INSTALL_ARG NO_INSTALL)

View File

@ -3,6 +3,8 @@ project(native)
include(wrap_elf)
if (COMPONENT_gui)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "gui")
wrap_elf(FreeType libfreetype.so)
wrap_elf(jpeg libjpeg.so)
wrap_elf(png libpng.so)

View File

@ -3,6 +3,8 @@ project(private-frameworks)
# this is mainly for frameworks that are required for Security,
# since Security is built for both CLI and GUI
if (COMPONENT_cli OR COMPONENT_dev_gui_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_gui_common")
# these are also stubs, but they're needed for Security
add_subdirectory(AppleFSCompression)
add_subdirectory(AppleSystemInfo)
@ -20,11 +22,15 @@ endif()
# this is mainly for anything that Xcode requires to run on the CLI
if (COMPONENT_dev_gui_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_dev_gui_common")
add_subdirectory(DebugSymbols)
endif()
# same here, except this is for stubs that Xcode needs
if (COMPONENT_dev_gui_stubs_common)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli_dev_gui_stubs_common")
add_subdirectory(AppleSauce)
add_subdirectory(AssetCacheServices)
add_subdirectory(AssistantServices)
@ -54,6 +60,8 @@ endif()
# this is for all the other stubbed frameworks
if (COMPONENT_gui_stubs)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "gui_stubs")
add_subdirectory(AssertionServices)
add_subdirectory(Bom)
add_subdirectory(CoreUtils)

View File

@ -1,6 +1,8 @@
project(tools)
if (COMPONENT_cli)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "cli")
add_darling_executable(sw_vers sw_vers.c)
add_darling_executable(sudo sudo.c)
add_darling_executable(codesign codesign.c)
@ -15,6 +17,8 @@ if (COMPONENT_cli)
endif()
if (COMPONENT_gui)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "gui")
add_darling_executable(open open.m)
target_link_libraries(open CoreServices Foundation AppKit)
install(TARGETS open DESTINATION libexec/darling/usr/bin)