Meta: Guard everything that installs headers with an option

This commit is contained in:
Tim Schumacher 2024-07-20 19:03:24 +02:00 committed by Andrew Kaster
parent ffc03eb25a
commit cf6929fef3
Notes: github-actions[bot] 2024-07-25 19:26:05 +00:00
8 changed files with 83 additions and 59 deletions

View file

@ -78,10 +78,12 @@ if (APPLE)
target_link_libraries(ladybird PRIVATE LibThreading)
endif()
target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
BASE_DIRS ${LADYBIRD_SOURCE_DIR}
FILES ${LADYBIRD_HEADERS}
)
if (ENABLE_INSTALL_HEADERS)
target_sources(ladybird PUBLIC FILE_SET ladybird TYPE HEADERS
BASE_DIRS ${LADYBIRD_SOURCE_DIR}
FILES ${LADYBIRD_HEADERS}
)
endif()
if (TARGET ladybird_impl)
set(LADYBIRD_TARGET ladybird_impl PUBLIC)

View file

@ -41,6 +41,8 @@ function(compile_ipc source output)
add_dependencies(all_generated generate_${output_name})
cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${SerenityOS_SOURCE_DIR} OUTPUT_VARIABLE current_source_dir_relative)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${current_source_dir_relative}" OPTIONAL)
if (ENABLE_INSTALL_HEADERS)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${current_source_dir_relative}" OPTIONAL)
endif()
endfunction()

View file

@ -35,3 +35,5 @@ serenity_option(ENABLE_CLANG_PLUGINS_INVALID_FUNCTION_MEMBERS OFF CACHE BOOL "En
serenity_option(ENABLE_GUI_TARGETS ON CACHE BOOL "Enable building GUI targets")
serenity_option(ENABLE_SWIFT OFF CACHE BOOL "Enable building Swift files")
serenity_option(ENABLE_INSTALL_HEADERS ON CACHE BOOL "Enable installing headers")

View file

@ -11,5 +11,7 @@ function (generate_encoding_indexes)
arguments -j "${LIBTEXTCODEC_INPUT_FOLDER}/indexes.json"
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LookupTables.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibTextCodec/")
if (ENABLE_INSTALL_HEADERS)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LookupTables.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibTextCodec/")
endif()
endfunction()

View file

@ -96,17 +96,19 @@ function (generate_css_implementation)
NAMESPACE "Web::CSS"
)
set(CSS_GENERATED_TO_INSTALL
"CSS/Enums.h"
"CSS/MathFunctions.h"
"CSS/MediaFeatureID.h"
"CSS/PropertyID.h"
"CSS/PseudoClass.h"
"CSS/TransformFunctions.h"
"CSS/ValueID.h"
)
list(TRANSFORM CSS_GENERATED_TO_INSTALL PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${CSS_GENERATED_TO_INSTALL} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibWeb/CSS")
if (ENABLE_INSTALL_HEADERS)
set(CSS_GENERATED_TO_INSTALL
"CSS/Enums.h"
"CSS/MathFunctions.h"
"CSS/MediaFeatureID.h"
"CSS/PropertyID.h"
"CSS/PseudoClass.h"
"CSS/TransformFunctions.h"
"CSS/ValueID.h"
)
list(TRANSFORM CSS_GENERATED_TO_INSTALL PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${CSS_GENERATED_TO_INSTALL} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibWeb/CSS")
endif()
endfunction()
@ -173,9 +175,11 @@ function (generate_js_bindings target)
add_dependencies(all_generated generate_${basename})
add_dependencies(${target} generate_${basename})
# install generated sources
list(FILTER BINDINGS_SOURCES INCLUDE REGEX "\.h$")
install(FILES ${BINDINGS_SOURCES} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibWeb/Bindings")
if (ENABLE_INSTALL_HEADERS)
# install generated sources
list(FILTER BINDINGS_SOURCES INCLUDE REGEX "\.h$")
install(FILES ${BINDINGS_SOURCES} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibWeb/Bindings")
endif()
list(APPEND LIBWEB_ALL_IDL_FILES "${LIBWEB_INPUT_FOLDER}/${class}.idl")
set(LIBWEB_ALL_IDL_FILES ${LIBWEB_ALL_IDL_FILES} PARENT_SCOPE)
@ -208,9 +212,11 @@ function (generate_js_bindings target)
add_dependencies(all_generated generate_exposed_interfaces)
add_dependencies(${target} generate_exposed_interfaces)
list(FILTER exposed_interface_sources INCLUDE REGEX "\.h$")
list(TRANSFORM exposed_interface_sources PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${exposed_interface_sources} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibWeb/Bindings")
if (ENABLE_INSTALL_HEADERS)
list(FILTER exposed_interface_sources INCLUDE REGEX "\.h$")
list(TRANSFORM exposed_interface_sources PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${exposed_interface_sources} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibWeb/Bindings")
endif()
endfunction()
include("idl_files.cmake")

View file

@ -228,19 +228,23 @@ function(lagom_lib target_name fs_name)
endif()
# FIXME: Clean these up so that we don't need so many include dirs
target_include_directories(${target_name} INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Services>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Userland/Libraries>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Userland/Services>
)
if (ENABLE_INSTALL_HEADERS)
target_include_directories(${target_name} INTERFACE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Services>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Userland/Libraries>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Userland/Services>
)
endif()
add_lagom_library_install_rules(${target_name} ALIAS_NAME ${library})
# FIXME: Move this to serenity_install_headers
install(
DIRECTORY "${SERENITY_PROJECT_ROOT}/Userland/Libraries/Lib${library}"
COMPONENT Lagom_Development
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
if (ENABLE_INSTALL_HEADERS)
# FIXME: Move this to serenity_install_headers
install(
DIRECTORY "${SERENITY_PROJECT_ROOT}/Userland/Libraries/Lib${library}"
COMPONENT Lagom_Development
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
endif()
serenity_generated_sources(${target_name})
endfunction()
@ -347,18 +351,20 @@ add_serenity_subdirectory(Userland/Libraries/LibFileSystem)
add_serenity_subdirectory(Userland/Libraries/LibIDL)
# Manually install AK headers
install(
DIRECTORY "${SERENITY_PROJECT_ROOT}/AK"
COMPONENT Lagom_Development
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(FILES
${Lagom_BINARY_DIR}/AK/Debug.h
${Lagom_BINARY_DIR}/AK/Backtrace.h
COMPONENT Lagom_Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/AK"
)
if (ENABLE_INSTALL_HEADERS)
install(
DIRECTORY "${SERENITY_PROJECT_ROOT}/AK"
COMPONENT Lagom_Development
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(FILES
${Lagom_BINARY_DIR}/AK/Debug.h
${Lagom_BINARY_DIR}/AK/Backtrace.h
COMPONENT Lagom_Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/AK"
)
endif()
# Code Generators and other host tools
if (BUILD_LAGOM_TOOLS)

View file

@ -83,8 +83,10 @@ add_custom_target(generate_tiff_files_handler DEPENDS ${generated_sources})
add_dependencies(all_generated generate_tiff_files_handler)
add_dependencies(LibGfx generate_tiff_files_handler)
list(TRANSFORM generated_sources PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${generated_sources} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibGfx/ImageFormats")
if (ENABLE_INSTALL_HEADERS)
list(TRANSFORM generated_sources PREPEND "${CMAKE_CURRENT_BINARY_DIR}/")
install(FILES ${generated_sources} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/LibGfx/ImageFormats")
endif()
# Third-party
find_package(PkgConfig)

View file

@ -55,16 +55,18 @@ target_compile_definitions(LibWebView PRIVATE ENABLE_PUBLIC_SUFFIX=$<BOOL:${ENAB
find_package(SQLite3 REQUIRED)
target_link_libraries(LibWebView PRIVATE SQLite::SQLite3)
foreach(header ${GENERATED_SOURCES})
get_filename_component(extension ${header} EXT)
if (NOT "${extension}" STREQUAL ".h")
continue()
endif()
if (ENABLE_INSTALL_HEADERS)
foreach(header ${GENERATED_SOURCES})
get_filename_component(extension ${header} EXT)
if (NOT "${extension}" STREQUAL ".h")
continue()
endif()
get_filename_component(subdirectory ${header} DIRECTORY)
string(REGEX REPLACE "^\\.\\./\\.\\./" "" subdirectory "${subdirectory}")
get_filename_component(subdirectory ${header} DIRECTORY)
string(REGEX REPLACE "^\\.\\./\\.\\./" "" subdirectory "${subdirectory}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${header}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${subdirectory}")
endforeach()
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${header}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${subdirectory}")
endforeach()
install(FILES "${SERENITY_PROJECT_ROOT}/Userland/Services/RequestServer/ConnectionCache.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/RequestServer")
install(FILES "${SERENITY_PROJECT_ROOT}/Userland/Services/RequestServer/ConnectionCache.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/RequestServer")
endif()