From cf6929fef306418e3fe5b302f30a508ae3ca6605 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Sat, 20 Jul 2024 19:03:24 +0200 Subject: [PATCH] Meta: Guard everything that installs headers with an option --- Ladybird/CMakeLists.txt | 10 ++-- Meta/CMake/code_generators.cmake | 4 +- Meta/CMake/common_options.cmake | 2 + Meta/CMake/libtextcodec_generators.cmake | 4 +- Meta/CMake/libweb_generators.cmake | 40 +++++++++------ Meta/Lagom/CMakeLists.txt | 54 +++++++++++--------- Userland/Libraries/LibGfx/CMakeLists.txt | 6 ++- Userland/Libraries/LibWebView/CMakeLists.txt | 22 ++++---- 8 files changed, 83 insertions(+), 59 deletions(-) diff --git a/Ladybird/CMakeLists.txt b/Ladybird/CMakeLists.txt index 312cb40f4a0..36f7c37f515 100644 --- a/Ladybird/CMakeLists.txt +++ b/Ladybird/CMakeLists.txt @@ -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) diff --git a/Meta/CMake/code_generators.cmake b/Meta/CMake/code_generators.cmake index d68bdcf9abb..ed54591ea61 100644 --- a/Meta/CMake/code_generators.cmake +++ b/Meta/CMake/code_generators.cmake @@ -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() diff --git a/Meta/CMake/common_options.cmake b/Meta/CMake/common_options.cmake index 7584f69f5c6..e6cdc0d3df7 100644 --- a/Meta/CMake/common_options.cmake +++ b/Meta/CMake/common_options.cmake @@ -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") diff --git a/Meta/CMake/libtextcodec_generators.cmake b/Meta/CMake/libtextcodec_generators.cmake index 317d7686e57..61918579817 100644 --- a/Meta/CMake/libtextcodec_generators.cmake +++ b/Meta/CMake/libtextcodec_generators.cmake @@ -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() diff --git a/Meta/CMake/libweb_generators.cmake b/Meta/CMake/libweb_generators.cmake index a65da9adb9f..339f3c9e16a 100644 --- a/Meta/CMake/libweb_generators.cmake +++ b/Meta/CMake/libweb_generators.cmake @@ -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") diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index e32a96649ba..21258be6414 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -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 - $ - $ - $ - ) + if (ENABLE_INSTALL_HEADERS) + target_include_directories(${target_name} INTERFACE + $ + $ + $ + ) + 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) diff --git a/Userland/Libraries/LibGfx/CMakeLists.txt b/Userland/Libraries/LibGfx/CMakeLists.txt index 0e36ccaa06c..94018facf22 100644 --- a/Userland/Libraries/LibGfx/CMakeLists.txt +++ b/Userland/Libraries/LibGfx/CMakeLists.txt @@ -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) diff --git a/Userland/Libraries/LibWebView/CMakeLists.txt b/Userland/Libraries/LibWebView/CMakeLists.txt index d649c9bfcb3..82c3b36c42b 100644 --- a/Userland/Libraries/LibWebView/CMakeLists.txt +++ b/Userland/Libraries/LibWebView/CMakeLists.txt @@ -55,16 +55,18 @@ target_compile_definitions(LibWebView PRIVATE ENABLE_PUBLIC_SUFFIX=$