浏览代码

CMake: Modify include path when building from Hack Studio

With regular builds, the generated IPC headers exist inside the Build
directory. The path Userland/Services under the build directory is
added to the include path.

For in-system builds the IPC headers are installed at /usr/include/.
To support this, we add /usr/include/Userland/Services to the build path
when building from Hack Studio.

Co-Authored-By: Andrew Kaster <akaster@serenityos.org>
Itamar 3 年之前
父节点
当前提交
b6f358689c
共有 3 个文件被更改,包括 5 次插入0 次删除
  1. 1 0
      CMakeLists.txt
  2. 2 0
      Meta/CMake/code_generators.cmake
  3. 2 0
      Meta/CMake/utils.cmake

+ 1 - 0
CMakeLists.txt

@@ -269,6 +269,7 @@ serenity_component(
 )
 )
 
 
 if (HACKSTUDIO_BUILD)
 if (HACKSTUDIO_BUILD)
+    include_directories(/usr/include/Userland/Services)
     include(${HACKSTUDIO_BUILD_CMAKE_FILE})
     include(${HACKSTUDIO_BUILD_CMAKE_FILE})
     return()
     return()
 endif()
 endif()

+ 2 - 0
Meta/CMake/code_generators.cmake

@@ -33,6 +33,8 @@ function(compile_ipc source output)
     add_custom_target(generate_${output_name} DEPENDS ${output})
     add_custom_target(generate_${output_name} DEPENDS ${output})
     add_dependencies(all_generated generate_${output_name})
     add_dependencies(all_generated generate_${output_name})
 
 
+    # TODO: Use cmake_path() when we upgrade the minimum CMake version to 3.20
+    #       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 usr/include${current_source_dir_relative} OPTIONAL)

+ 2 - 0
Meta/CMake/utils.cmake

@@ -11,6 +11,8 @@ function(serenity_install_headers target_name)
 endfunction()
 endfunction()
 
 
 function(serenity_install_sources)
 function(serenity_install_sources)
+    # TODO: Use cmake_path() when we upgrade the minimum CMake version to 3.20
+    #       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)
     file(GLOB_RECURSE sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h" "*.cpp")
     file(GLOB_RECURSE sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h" "*.cpp")