Meta: Use CMAKE_INSTALL_FOODIR variables instead of hardcoding usr/foo

In preparation for future refactoring of Lagom, let's use the variables
from GNUInstallDirs as much as possible for the helper macros and other
scripts used by the main build already.
This commit is contained in:
Andrew Kaster 2022-07-04 11:01:05 -06:00 committed by Andreas Kling
parent 2b82c83ceb
commit 02e8f29560
Notes: sideshowbarker 2024-07-17 09:40:09 +09:00
3 changed files with 12 additions and 10 deletions

View file

@ -152,13 +152,15 @@ if (ENABLE_ALL_THE_DEBUG_MACROS)
include(all_the_debug_macros)
endif(ENABLE_ALL_THE_DEBUG_MACROS)
set(CMAKE_STAGING_PREFIX "${CMAKE_BINARY_DIR}/Root")
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/Root")
set(CMAKE_INSTALL_DATAROOTDIR res)
set(CMAKE_INSTALL_INCLUDEDIR usr/include)
set(CMAKE_INSTALL_LIBDIR usr/lib)
configure_file(AK/Debug.h.in AK/Debug.h @ONLY)
configure_file(Kernel/Debug.h.in Kernel/Debug.h @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/AK/Debug.h DESTINATION usr/include/AK)
set(CMAKE_STAGING_PREFIX ${CMAKE_BINARY_DIR}/Root)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/Root)
set(CMAKE_INSTALL_DATAROOTDIR ${CMAKE_BINARY_DIR}/Root/res)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/AK/Debug.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/AK")
# We disable it completely because it makes cmake very spammy.
# This will need to be revisited when the Loader supports RPATH/RUN_PATH.

View file

@ -37,7 +37,7 @@ function(compile_ipc source output)
# https://cmake.org/cmake/help/v3.23/command/cmake_path.html#relative-path
string(LENGTH ${SerenityOS_SOURCE_DIR} root_source_dir_length)
string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${root_source_dir_length} -1 current_source_dir_relative)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION usr/include${current_source_dir_relative} OPTIONAL)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${current_source_dir_relative}" OPTIONAL)
endfunction()
function(generate_state_machine source header)

View file

@ -6,7 +6,7 @@ function(serenity_install_headers target_name)
file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
foreach(header ${headers})
get_filename_component(subdirectory ${header} DIRECTORY)
install(FILES ${header} DESTINATION usr/include/${target_name}/${subdirectory} OPTIONAL)
install(FILES ${header} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${target_name}/${subdirectory}" OPTIONAL)
endforeach()
endfunction()
@ -39,7 +39,7 @@ function(serenity_lib target_name fs_name)
add_library(${target_name} SHARED ${SOURCES} ${GENERATED_SOURCES})
set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(${target_name} PROPERTIES VERSION "serenity")
install(TARGETS ${target_name} DESTINATION usr/lib OPTIONAL)
install(TARGETS ${target_name} DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL)
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
serenity_generated_sources(${target_name})
endfunction()
@ -50,7 +50,7 @@ function(serenity_lib_static target_name fs_name)
add_library(${target_name} STATIC ${SOURCES} ${GENERATED_SOURCES})
set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(${target_name} PROPERTIES VERSION "serenity")
install(TARGETS ${target_name} DESTINATION usr/lib OPTIONAL)
install(TARGETS ${target_name} DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL)
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
serenity_generated_sources(${target_name})
endfunction()
@ -60,7 +60,7 @@ function(serenity_libc target_name fs_name)
serenity_install_sources()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -fpic")
add_library(${target_name} SHARED ${SOURCES})
install(TARGETS ${target_name} DESTINATION usr/lib)
install(TARGETS ${target_name} DESTINATION ${CMAKE_INSTALL_LIBDIR})
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
# Avoid creating a dependency cycle between system libraries and the C++ standard library. This is necessary
# to ensure that initialization functions will be called in the right order (libc++ must come after LibPthread).