CMake: Resolve FIXMEs related to CMake < 3.20

We already have required this version for quite a while for Lagom,
Ladybird and Serenity. Now that we require it in all of our CMakeLists,
let's scrub for better ways of writing things.
This commit is contained in:
Andrew Kaster 2024-04-25 11:30:44 -06:00 committed by Andrew Kaster
parent 65bfd2ca2d
commit 37a0466285
3 changed files with 4 additions and 13 deletions

View file

@ -55,15 +55,12 @@ if (HAIKU)
endif()
# Lagom
# FIXME: PROJECT_IS_TOP_LEVEL with CMake 3.21+
set(LADYBIRD_IS_TOP_LEVEL FALSE)
set(LADYBIRD_CUSTOM_TARGET_SUFFIX "-ladybird")
if ("${CMAKE_BINARY_DIR}" STREQUAL "${PROJECT_BINARY_DIR}")
set(LADYBIRD_IS_TOP_LEVEL TRUE)
if (PROJECT_IS_TOP_LEVEL)
set(LADYBIRD_CUSTOM_TARGET_SUFFIX "")
endif()
if (LADYBIRD_IS_TOP_LEVEL)
if (PROJECT_IS_TOP_LEVEL)
get_filename_component(
SERENITY_SOURCE_DIR "${ladybird_SOURCE_DIR}/.."
ABSOLUTE

View file

@ -62,10 +62,7 @@ function(compile_ipc source output)
add_custom_target(generate_${output_name} DEPENDS ${output})
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(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${root_source_dir_length} -1 current_source_dir_relative)
cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${SerenityOS_SOURCE_DIR} OUTPUT_VARIABLE current_source_dir_relative)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${output} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${current_source_dir_relative}" OPTIONAL)
endfunction()

View file

@ -29,10 +29,7 @@ function(serenity_install_headers target_name)
endfunction()
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(SUBSTRING ${CMAKE_CURRENT_SOURCE_DIR} ${root_source_dir_length} -1 current_source_dir_relative)
cmake_path(RELATIVE_PATH CMAKE_CURRENT_SOURCE_DIR BASE_DIRECTORY ${SerenityOS_SOURCE_DIR} OUTPUT_VARIABLE current_source_dir_relative)
file(GLOB_RECURSE sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h" "*.cpp" "*.gml")
foreach(source ${sources})
get_filename_component(subdirectory ${source} DIRECTORY)