mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 02:38:13 +00:00
Meta: Move components CMake helpers to their own file
It's hard to follow how all the functions in the utils.cmake helper file flow together, so let's move the pieces that are related to each other into specialized helpers. First up: all the ConfigureComponents related properties and functions.
This commit is contained in:
parent
e36931fffe
commit
a83847f8bf
2 changed files with 93 additions and 80 deletions
|
@ -1,3 +1,6 @@
|
|||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/serenity_components.cmake)
|
||||
|
||||
function(serenity_install_headers target_name)
|
||||
file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||
foreach(header ${headers})
|
||||
|
@ -134,86 +137,6 @@ function(serenity_app target_name)
|
|||
endif()
|
||||
endfunction()
|
||||
|
||||
define_property(TARGET PROPERTY SERENITY_COMPONENT_NAME BRIEF_DOCS "SerenityOS component name" FULL_DOCS "-")
|
||||
define_property(TARGET PROPERTY SERENITY_COMPONENT_DESCRIPTION BRIEF_DOCS "SerenityOS component description" FULL_DOCS "-")
|
||||
define_property(TARGET PROPERTY SERENITY_COMPONENT_RECOMMENDED BRIEF_DOCS "SerenityOS component recommended (flag)" FULL_DOCS "-")
|
||||
define_property(TARGET PROPERTY SERENITY_COMPONENT_REQUIRED BRIEF_DOCS "SerenityOS component required (flag)" FULL_DOCS "-")
|
||||
define_property(TARGET PROPERTY SERENITY_COMPONENT_DEPENDS BRIEF_DOCS "SerenityOS component dependencies" FULL_DOCS "-")
|
||||
|
||||
function(serenity_component name)
|
||||
cmake_parse_arguments(SERENITY_COMPONENT "RECOMMENDED;REQUIRED" "DESCRIPTION" "TARGETS;DEPENDS" ${ARGN})
|
||||
string(TOUPPER "${name}" NAME_UPPER)
|
||||
option("BUILD_${NAME_UPPER}" "Build ${name}" ${SERENITY_COMPONENT_RECOMMENDED})
|
||||
add_custom_target("Component${name}")
|
||||
set_property(TARGET "Component${name}" PROPERTY SERENITY_COMPONENT_NAME ${name})
|
||||
set_property(TARGET "Component${name}" PROPERTY SERENITY_COMPONENT_DESCRIPTION ${SERENITY_COMPONENT_DESCRIPTION})
|
||||
set_property(TARGET "Component${name}" PROPERTY SERENITY_COMPONENT_RECOMMENDED ${SERENITY_COMPONENT_RECOMMENDED})
|
||||
set_property(TARGET "Component${name}" PROPERTY SERENITY_COMPONENT_REQUIRED ${SERENITY_COMPONENT_REQUIRED})
|
||||
set_property(TARGET "Component${name}" PROPERTY SERENITY_COMPONENT_DEPENDS ${SERENITY_COMPONENT_DEPENDS})
|
||||
if(NOT "${SERENITY_COMPONENT_TARGETS}" STREQUAL "")
|
||||
foreach(target IN LISTS SERENITY_COMPONENT_TARGETS)
|
||||
add_dependencies("Component${name}" "${target}")
|
||||
endforeach()
|
||||
endif()
|
||||
if(BUILD_EVERYTHING OR BUILD_${NAME_UPPER} OR SERENITY_COMPONENT_REQUIRED)
|
||||
add_dependencies(components "Component${name}")
|
||||
endif()
|
||||
foreach(dependency ${SERENITY_COMPONENT_DEPENDS})
|
||||
add_dependencies("Component${name}" "Component${dependency}")
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
macro(export_components_helper file_name current_dir)
|
||||
get_property(sub_dirs DIRECTORY ${current_dir} PROPERTY SUBDIRECTORIES)
|
||||
foreach(sub_dir ${sub_dirs})
|
||||
export_components_helper(${file_name} ${sub_dir})
|
||||
endforeach()
|
||||
|
||||
get_property(targets DIRECTORY ${current_dir} PROPERTY BUILDSYSTEM_TARGETS)
|
||||
foreach(target ${targets})
|
||||
get_property(component_name TARGET ${target} PROPERTY SERENITY_COMPONENT_NAME)
|
||||
if(NOT "${component_name}" STREQUAL "")
|
||||
get_property(component_name TARGET ${target} PROPERTY SERENITY_COMPONENT_NAME)
|
||||
get_property(component_description TARGET ${target} PROPERTY SERENITY_COMPONENT_DESCRIPTION)
|
||||
get_property(component_recommended TARGET ${target} PROPERTY SERENITY_COMPONENT_RECOMMENDED)
|
||||
get_property(component_required TARGET ${target} PROPERTY SERENITY_COMPONENT_REQUIRED)
|
||||
get_property(component_depends TARGET ${target} PROPERTY SERENITY_COMPONENT_DEPENDS)
|
||||
file(APPEND ${file_name} "[${component_name}]\n")
|
||||
file(APPEND ${file_name} "description=${component_description}\n")
|
||||
if(component_recommended)
|
||||
file(APPEND ${file_name} "recommended=1\n")
|
||||
else()
|
||||
file(APPEND ${file_name} "recommended=0\n")
|
||||
endif()
|
||||
if(component_required)
|
||||
file(APPEND ${file_name} "required=1\n")
|
||||
else()
|
||||
file(APPEND ${file_name} "required=0\n")
|
||||
endif()
|
||||
string(TOUPPER "${component_name}" component_name_upper)
|
||||
if(BUILD_${component_name_upper})
|
||||
file(APPEND ${file_name} "user_selected=1\n")
|
||||
else()
|
||||
file(APPEND ${file_name} "user_selected=0\n")
|
||||
endif()
|
||||
|
||||
file(APPEND ${file_name} "depends=${component_depends}\n")
|
||||
file(APPEND ${file_name} "\n")
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
function(export_components file_name)
|
||||
file(WRITE ${file_name} "[Global]\n")
|
||||
if(BUILD_EVERYTHING)
|
||||
file(APPEND ${file_name} "build_everything=1\n")
|
||||
else()
|
||||
file(APPEND ${file_name} "build_everything=0\n")
|
||||
endif()
|
||||
file(APPEND ${file_name} "\n")
|
||||
export_components_helper(${file_name} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endfunction()
|
||||
|
||||
function(compile_gml source output string_name)
|
||||
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
|
||||
add_custom_command(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue