diff --git a/CMakeLists.txt b/CMakeLists.txt index 96ebfbff9d..7a0f794319 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. diff --git a/Meta/CMake/code_generators.cmake b/Meta/CMake/code_generators.cmake index 20c7ddccfa..e54a4c1023 100644 --- a/Meta/CMake/code_generators.cmake +++ b/Meta/CMake/code_generators.cmake @@ -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) diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake index 1bfc3b8ea2..5da86a1d3a 100644 --- a/Meta/CMake/utils.cmake +++ b/Meta/CMake/utils.cmake @@ -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).