Kaynağa Gözat

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.
Andrew Kaster 3 yıl önce
ebeveyn
işleme
02e8f29560
3 değiştirilmiş dosya ile 12 ekleme ve 10 silme
  1. 7 5
      CMakeLists.txt
  2. 1 1
      Meta/CMake/code_generators.cmake
  3. 4 4
      Meta/CMake/utils.cmake

+ 7 - 5
CMakeLists.txt

@@ -152,13 +152,15 @@ if (ENABLE_ALL_THE_DEBUG_MACROS)
     include(all_the_debug_macros)
     include(all_the_debug_macros)
 endif(ENABLE_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(AK/Debug.h.in AK/Debug.h @ONLY)
 configure_file(Kernel/Debug.h.in Kernel/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.
 # We disable it completely because it makes cmake very spammy.
 # This will need to be revisited when the Loader supports RPATH/RUN_PATH.
 # This will need to be revisited when the Loader supports RPATH/RUN_PATH.

+ 1 - 1
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
     #       https://cmake.org/cmake/help/v3.23/command/cmake_path.html#relative-path
     string(LENGTH ${SerenityOS_SOURCE_DIR} root_source_dir_length)
     string(LENGTH ${SerenityOS_SOURCE_DIR} root_source_dir_length)
     string(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${root_source_dir_length} -1 current_source_dir_relative)
     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()
 endfunction()
 
 
 function(generate_state_machine source header)
 function(generate_state_machine source header)

+ 4 - 4
Meta/CMake/utils.cmake

@@ -6,7 +6,7 @@ function(serenity_install_headers target_name)
     file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
     file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
     foreach(header ${headers})
     foreach(header ${headers})
         get_filename_component(subdirectory ${header} DIRECTORY)
         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()
     endforeach()
 endfunction()
 endfunction()
 
 
@@ -39,7 +39,7 @@ function(serenity_lib target_name fs_name)
     add_library(${target_name} SHARED ${SOURCES} ${GENERATED_SOURCES})
     add_library(${target_name} SHARED ${SOURCES} ${GENERATED_SOURCES})
     set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
     set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
     set_target_properties(${target_name} PROPERTIES VERSION "serenity")
     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})
     set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
     serenity_generated_sources(${target_name})
     serenity_generated_sources(${target_name})
 endfunction()
 endfunction()
@@ -50,7 +50,7 @@ function(serenity_lib_static target_name fs_name)
     add_library(${target_name} STATIC ${SOURCES} ${GENERATED_SOURCES})
     add_library(${target_name} STATIC ${SOURCES} ${GENERATED_SOURCES})
     set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
     set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL TRUE)
     set_target_properties(${target_name} PROPERTIES VERSION "serenity")
     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})
     set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
     serenity_generated_sources(${target_name})
     serenity_generated_sources(${target_name})
 endfunction()
 endfunction()
@@ -60,7 +60,7 @@ function(serenity_libc target_name fs_name)
     serenity_install_sources()
     serenity_install_sources()
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -fpic")
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -fpic")
     add_library(${target_name} SHARED ${SOURCES})
     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})
     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
     # 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).
     # to ensure that initialization functions will be called in the right order (libc++ must come after LibPthread).