diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake index e139d69d145..27556f0e7af 100644 --- a/Meta/CMake/utils.cmake +++ b/Meta/CMake/utils.cmake @@ -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)