mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
Meta: Prefer SerenityOS_SOURCE_DIR to CMAKE_SOURCE_DIR
By using SerenityOS_SOURCE_DIR we can make custom targets and commands agnostic to the actual location of the root CMakeLists directory. All we care about is the root of the SerenityOS project.
This commit is contained in:
parent
20e904d87c
commit
47471c0ec2
Notes:
sideshowbarker
2024-07-18 05:10:50 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/47471c0ec22 Pull-request: https://github.com/SerenityOS/serenity/pull/9281 Reviewed-by: https://github.com/BenWiederhake
3 changed files with 26 additions and 25 deletions
|
@ -48,7 +48,7 @@ option(USE_CLANG_TOOLCHAIN "Build the kernel with the experimental Clang toolcha
|
||||||
include(Meta/CMake/wasm_spec_tests.cmake)
|
include(Meta/CMake/wasm_spec_tests.cmake)
|
||||||
|
|
||||||
add_custom_target(run
|
add_custom_target(run
|
||||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_ARCH=${SERENITY_ARCH}" ${CMAKE_SOURCE_DIR}/Meta/run.sh
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_ARCH=${SERENITY_ARCH}" "${SerenityOS_SOURCE_DIR}/Meta/run.sh"
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -72,40 +72,40 @@ set(GCC_VERSION 11.2.0)
|
||||||
set(LLVM_VERSION 12.0.1)
|
set(LLVM_VERSION 12.0.1)
|
||||||
|
|
||||||
add_custom_target(qemu-image
|
add_custom_target(qemu-image
|
||||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" ${CMAKE_SOURCE_DIR}/Meta/build-image-qemu.sh
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-qemu.sh"
|
||||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/_disk_image
|
BYPRODUCTS "${CMAKE_BINARY_DIR}/_disk_image"
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
add_custom_target(grub-image
|
add_custom_target(grub-image
|
||||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" ${CMAKE_SOURCE_DIR}/Meta/build-image-grub.sh
|
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-grub.sh"
|
||||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/grub_disk_image
|
BYPRODUCTS ${CMAKE_BINARY_DIR}/grub_disk_image
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
add_custom_target(extlinux-image
|
add_custom_target(extlinux-image
|
||||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" ${CMAKE_SOURCE_DIR}/Meta/build-image-extlinux.sh
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "USE_CLANG_TOOLCHAIN=$<BOOL:${USE_CLANG_TOOLCHAIN}>" "LLVM_VERSION=${LLVM_VERSION}" "${SerenityOS_SOURCE_DIR}/Meta/build-image-extlinux.sh"
|
||||||
BYPRODUCTS ${CMAKE_BINARY_DIR}/extlinux_disk_image
|
BYPRODUCTS "${CMAKE_BINARY_DIR}/extlinux_disk_image"
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(lint-shell-scripts
|
add_custom_target(lint-shell-scripts
|
||||||
COMMAND ${CMAKE_SOURCE_DIR}/Meta/lint-shell-scripts.sh
|
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/lint-shell-scripts.sh"
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
add_custom_target(check-style
|
add_custom_target(check-style
|
||||||
COMMAND ${CMAKE_SOURCE_DIR}/Meta/check-style.sh
|
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/check-style.sh"
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(install-ports
|
add_custom_target(install-ports
|
||||||
COMMAND ${CMAKE_COMMAND} -E env "SERENITY_SOURCE_DIR=${CMAKE_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" ${CMAKE_SOURCE_DIR}/Meta/install-ports-tree.sh
|
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SerenityOS_SOURCE_DIR}" "SERENITY_ARCH=${SERENITY_ARCH}" "${SerenityOS_SOURCE_DIR}/Meta/install-ports-tree.sh"
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_target(configure-components
|
add_custom_target(configure-components
|
||||||
COMMAND ConfigureComponents
|
COMMAND "$<TARGET_FILE:ConfigureComponents>"
|
||||||
DEPENDS ConfigureComponents
|
|
||||||
USES_TERMINAL
|
USES_TERMINAL
|
||||||
)
|
)
|
||||||
|
add_dependencies(configure-components ConfigureComponents)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
@ -137,7 +137,7 @@ if (ENABLE_ALL_DEBUG_FACILITIES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ENABLE_ALL_THE_DEBUG_MACROS)
|
if (ENABLE_ALL_THE_DEBUG_MACROS)
|
||||||
include(${CMAKE_SOURCE_DIR}/Meta/CMake/all_the_debug_macros.cmake)
|
include("${SerenityOS_SOURCE_DIR}/Meta/CMake/all_the_debug_macros.cmake")
|
||||||
endif(ENABLE_ALL_THE_DEBUG_MACROS)
|
endif(ENABLE_ALL_THE_DEBUG_MACROS)
|
||||||
|
|
||||||
configure_file(AK/Debug.h.in AK/Debug.h @ONLY)
|
configure_file(AK/Debug.h.in AK/Debug.h @ONLY)
|
||||||
|
@ -189,7 +189,7 @@ elseif(USE_CLANG_TOOLCHAIN)
|
||||||
# FIXME: Persuade LLVM maintainers to add `--update-section` to llvm-objcopy, as it's required for the kernel symbol map.
|
# FIXME: Persuade LLVM maintainers to add `--update-section` to llvm-objcopy, as it's required for the kernel symbol map.
|
||||||
set(CMAKE_OBJCOPY ${TOOLCHAIN_ROOT}/binutils/bin/${SERENITY_ARCH}-pc-serenity-objcopy)
|
set(CMAKE_OBJCOPY ${TOOLCHAIN_ROOT}/binutils/bin/${SERENITY_ARCH}-pc-serenity-objcopy)
|
||||||
else()
|
else()
|
||||||
set(TOOLCHAIN_ROOT ${CMAKE_SOURCE_DIR}/Toolchain/Local/${SERENITY_ARCH}/)
|
set(TOOLCHAIN_ROOT ${SerenityOS_SOURCE_DIR}/Toolchain/Local/${SERENITY_ARCH}/)
|
||||||
set(TOOLCHAIN_PATH ${TOOLCHAIN_ROOT}/bin)
|
set(TOOLCHAIN_PATH ${TOOLCHAIN_ROOT}/bin)
|
||||||
set(TOOLCHAIN_PREFIX ${TOOLCHAIN_PATH}/${SERENITY_ARCH}-pc-serenity-)
|
set(TOOLCHAIN_PREFIX ${TOOLCHAIN_PATH}/${SERENITY_ARCH}-pc-serenity-)
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ add_compile_options(-Wno-unused-command-line-argument)
|
||||||
add_compile_options(-Wwrite-strings)
|
add_compile_options(-Wwrite-strings)
|
||||||
add_compile_options(-Wno-maybe-uninitialized)
|
add_compile_options(-Wno-maybe-uninitialized)
|
||||||
|
|
||||||
add_compile_options(-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.)
|
add_compile_options(-ffile-prefix-map=${SerenityOS_SOURCE_DIR}=.)
|
||||||
add_compile_options(-fno-exceptions)
|
add_compile_options(-fno-exceptions)
|
||||||
add_compile_options(-ftls-model=initial-exec)
|
add_compile_options(-ftls-model=initial-exec)
|
||||||
add_compile_options(-fno-semantic-interposition)
|
add_compile_options(-fno-semantic-interposition)
|
||||||
|
@ -342,7 +342,7 @@ endif()
|
||||||
add_custom_target(components ALL)
|
add_custom_target(components ALL)
|
||||||
option(BUILD_EVERYTHING "Build all optional components" ON)
|
option(BUILD_EVERYTHING "Build all optional components" ON)
|
||||||
|
|
||||||
include(${CMAKE_SOURCE_DIR}/Meta/CMake/utils.cmake)
|
include(Meta/CMake/utils.cmake)
|
||||||
|
|
||||||
serenity_component(
|
serenity_component(
|
||||||
Tests
|
Tests
|
||||||
|
|
|
@ -81,7 +81,7 @@ function(serenity_bin target_name)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(serenity_test test_src sub_dir)
|
function(serenity_test test_src sub_dir)
|
||||||
cmake_parse_arguments(SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS" ${ARGN})
|
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "MAIN_ALREADY_DEFINED" "CUSTOM_MAIN" "LIBS")
|
||||||
set(TEST_SOURCES ${test_src})
|
set(TEST_SOURCES ${test_src})
|
||||||
if ("${SERENITY_TEST_CUSTOM_MAIN}" STREQUAL "")
|
if ("${SERENITY_TEST_CUSTOM_MAIN}" STREQUAL "")
|
||||||
set(SERENITY_TEST_CUSTOM_MAIN "$<TARGET_OBJECTS:LibTestMain>")
|
set(SERENITY_TEST_CUSTOM_MAIN "$<TARGET_OBJECTS:LibTestMain>")
|
||||||
|
@ -102,7 +102,7 @@ endfunction()
|
||||||
|
|
||||||
|
|
||||||
function(serenity_testjs_test test_src sub_dir)
|
function(serenity_testjs_test test_src sub_dir)
|
||||||
cmake_parse_arguments(SERENITY_TEST "" "CUSTOM_MAIN" "LIBS" ${ARGN})
|
cmake_parse_arguments(PARSE_ARGV 2 SERENITY_TEST "" "CUSTOM_MAIN" "LIBS")
|
||||||
if ("${SERENITY_TEST_CUSTOM_MAIN}" STREQUAL "")
|
if ("${SERENITY_TEST_CUSTOM_MAIN}" STREQUAL "")
|
||||||
set(SERENITY_TEST_CUSTOM_MAIN "$<TARGET_OBJECTS:JavaScriptTestRunnerMain>")
|
set(SERENITY_TEST_CUSTOM_MAIN "$<TARGET_OBJECTS:JavaScriptTestRunnerMain>")
|
||||||
endif()
|
endif()
|
||||||
|
@ -113,11 +113,11 @@ function(serenity_testjs_test test_src sub_dir)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(serenity_app target_name)
|
function(serenity_app target_name)
|
||||||
cmake_parse_arguments(SERENITY_APP "" "ICON" "" ${ARGN})
|
cmake_parse_arguments(PARSE_ARGV 1 SERENITY_APP "" "ICON" "")
|
||||||
|
|
||||||
serenity_bin("${target_name}")
|
serenity_bin("${target_name}")
|
||||||
set(small_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/16x16/${SERENITY_APP_ICON}.png")
|
set(small_icon "${SerenityOS_SOURCE_DIR}/Base/res/icons/16x16/${SERENITY_APP_ICON}.png")
|
||||||
set(medium_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/32x32/${SERENITY_APP_ICON}.png")
|
set(medium_icon "${SerenityOS_SOURCE_DIR}/Base/res/icons/32x32/${SERENITY_APP_ICON}.png")
|
||||||
|
|
||||||
if (EXISTS "${small_icon}")
|
if (EXISTS "${small_icon}")
|
||||||
embed_resource("${target_name}" serenity_icon_s "${small_icon}")
|
embed_resource("${target_name}" serenity_icon_s "${small_icon}")
|
||||||
|
@ -145,8 +145,8 @@ function(embed_resource target section file)
|
||||||
file(SIZE "${input_file}" file_size)
|
file(SIZE "${input_file}" file_size)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT "${asm_file}"
|
OUTPUT "${asm_file}"
|
||||||
COMMAND "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}" "${file_size}"
|
COMMAND "${SerenityOS_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}" "${file_size}"
|
||||||
DEPENDS "${input_file}" "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh"
|
DEPENDS "${input_file}" "${SerenityOS_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh"
|
||||||
COMMENT "Generating ${asm_file}"
|
COMMENT "Generating ${asm_file}"
|
||||||
)
|
)
|
||||||
target_sources("${target}" PRIVATE "${asm_file}")
|
target_sources("${target}" PRIVATE "${asm_file}")
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
option(INCLUDE_WASM_SPEC_TESTS "Download and include the WebAssembly spec testsuite" OFF)
|
option(INCLUDE_WASM_SPEC_TESTS "Download and include the WebAssembly spec testsuite" OFF)
|
||||||
|
|
||||||
if(INCLUDE_WASM_SPEC_TESTS)
|
if(INCLUDE_WASM_SPEC_TESTS)
|
||||||
set(SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
if (CMAKE_PROJECT_NAME STREQUAL "SerenityOS")
|
||||||
if (CMAKE_SOURCE_DIR MATCHES ".*/Lagom")
|
set(SOURCE_DIR "${SerenityOS_SOURCE_DIR}")
|
||||||
set(SOURCE_DIR ${SOURCE_DIR}/../..)
|
else()
|
||||||
|
set(SOURCE_DIR "${SERENITY_PROJECT_ROOT}")
|
||||||
endif()
|
endif()
|
||||||
set(WASM_SPEC_TEST_GZ_URL https://github.com/WebAssembly/testsuite/archive/refs/heads/master.tar.gz)
|
set(WASM_SPEC_TEST_GZ_URL https://github.com/WebAssembly/testsuite/archive/refs/heads/master.tar.gz)
|
||||||
set(WASM_SPEC_TEST_GZ_PATH ${CMAKE_BINARY_DIR}/wasm-spec-testsuite.tar.gz)
|
set(WASM_SPEC_TEST_GZ_PATH ${CMAKE_BINARY_DIR}/wasm-spec-testsuite.tar.gz)
|
||||||
|
|
Loading…
Reference in a new issue