mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-02 16:25:34 +03:00
CMake: Simplify serenity_install_sources by inferring installation path
The serenity_install_sources function now infers the path under `/usr/src/serenity` in which to install the source files according to the relative path of the source files in the repository. For example `Userland/Libraries/LibGUI/Widget.h` gets installed at `/usr/src/serenity/Userland/Libraries/LibGUI/Widget.h`. This fixes cases where the source files of libraries are not under `Userland/Libraries` (for example LibShell & LibLanguageServer).
This commit is contained in:
parent
4a90729a3e
commit
3b5eeb7fdd
Notes:
sideshowbarker
2024-07-18 03:20:18 +09:00
Author: https://github.com/itamar8910 Commit: https://github.com/SerenityOS/serenity/commit/3b5eeb7fddd Pull-request: https://github.com/SerenityOS/serenity/pull/11079
@ -10,11 +10,13 @@ function(serenity_install_headers target_name)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(serenity_install_sources target_name)
|
||||
function(serenity_install_sources)
|
||||
string(LENGTH ${SerenityOS_SOURCE_DIR} root_source_dir_length)
|
||||
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")
|
||||
foreach(source ${sources})
|
||||
get_filename_component(subdirectory ${source} DIRECTORY)
|
||||
install(FILES ${source} DESTINATION usr/src/serenity/${target_name}/${subdirectory} OPTIONAL)
|
||||
install(FILES ${source} DESTINATION usr/src/serenity/${current_source_dir_relative}/${subdirectory} OPTIONAL)
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
@ -31,7 +33,7 @@ endfunction()
|
||||
|
||||
function(serenity_lib target_name fs_name)
|
||||
serenity_install_headers(${target_name})
|
||||
serenity_install_sources("Userland/Libraries/${target_name}")
|
||||
serenity_install_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 VERSION "serenity")
|
||||
@ -42,7 +44,7 @@ endfunction()
|
||||
|
||||
function(serenity_libc target_name fs_name)
|
||||
serenity_install_headers("")
|
||||
serenity_install_sources("Userland/Libraries/LibC")
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user