mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:57:35 +00:00
CMake: Decouple cmake utility functions from top-level CMakeLists.txt
Problem: - These utility functions are only used in `AK`, but are being defined in the top-level. This clutters the top-level. Solution: - Move the utility functions to `Meta/CMake/utils.cmake` and include where needed. - Also, move `all_the_debug_macros.cmake` into `Meta/CMake` directory to consolidate the location of `*.cmake` script files.
This commit is contained in:
parent
6db224f020
commit
e4ce485309
5 changed files with 133 additions and 133 deletions
169
Meta/CMake/all_the_debug_macros.cmake
Normal file
169
Meta/CMake/all_the_debug_macros.cmake
Normal file
|
@ -0,0 +1,169 @@
|
|||
add_compile_definitions("ACPI_DEBUG")
|
||||
add_compile_definitions("APIC_DEBUG")
|
||||
add_compile_definitions("APIC_SMP_DEBUG")
|
||||
add_compile_definitions("ARP_DEBUG")
|
||||
add_compile_definitions("AWAVLOADER_DEBUG")
|
||||
add_compile_definitions("BBFS_DEBUG")
|
||||
add_compile_definitions("BMP_DEBUG")
|
||||
add_compile_definitions("BXVGA_DEBUG")
|
||||
add_compile_definitions("CACHE_DEBUG")
|
||||
add_compile_definitions("CALLBACK_MACHINE_DEBUG")
|
||||
add_compile_definitions("CHTTPJOB_DEBUG")
|
||||
add_compile_definitions("CNETWORKJOB_DEBUG")
|
||||
add_compile_definitions("COMPOSE_DEBUG")
|
||||
add_compile_definitions("CONTEXT_SWITCH_DEBUG")
|
||||
add_compile_definitions("CONTIGUOUS_VMOBJECT_DEBUG")
|
||||
add_compile_definitions("COPY_DEBUG")
|
||||
add_compile_definitions("CRYPTO_DEBUG")
|
||||
add_compile_definitions("CSOCKET_DEBUG")
|
||||
add_compile_definitions("DEBUG_AUTOCOMPLETE")
|
||||
add_compile_definitions("DEBUG_CPP_LANGUAGE_SERVER")
|
||||
add_compile_definitions("DEBUG_CURSOR_TOOL")
|
||||
add_compile_definitions("DEBUG_DIFF")
|
||||
add_compile_definitions("DEBUG_FILE_CONTENT")
|
||||
add_compile_definitions("DEBUG_GZIP")
|
||||
add_compile_definitions("DEBUG_HIGHLIGHT_FOCUSED_FRAME")
|
||||
add_compile_definitions("DEBUG_HUNKS")
|
||||
add_compile_definitions("DEBUG_IO")
|
||||
add_compile_definitions("DEBUG_ITEM_RECTS")
|
||||
add_compile_definitions("DEBUG_LOCAL_SOCKET")
|
||||
add_compile_definitions("DEBUG_MAPPED_FILE")
|
||||
add_compile_definitions("DEBUG_MARKDOWN")
|
||||
add_compile_definitions("DEBUG_MENUS")
|
||||
add_compile_definitions("DEBUG_POLL_SELECT")
|
||||
add_compile_definitions("DEBUG_SH_LANGUAGE_SERVER")
|
||||
add_compile_definitions("DEBUG_SPAM")
|
||||
add_compile_definitions("DEBUG_STRINGIMPL")
|
||||
add_compile_definitions("DEBUG_SYNTAX_HIGHLIGHTING")
|
||||
add_compile_definitions("DEBUG_TEXTEDITOR")
|
||||
add_compile_definitions("DEFERRED_INVOKE_DEBUG")
|
||||
add_compile_definitions("DHCPV4CLIENT_DEBUG")
|
||||
add_compile_definitions("DHCPV4_DEBUG")
|
||||
add_compile_definitions("DOUBLECLICK_DEBUG")
|
||||
add_compile_definitions("DRAGDROP_DEBUG")
|
||||
add_compile_definitions("DWARF_DEBUG")
|
||||
add_compile_definitions("DYNAMIC_LOAD_DEBUG")
|
||||
add_compile_definitions("E1000_DEBUG")
|
||||
add_compile_definitions("EBR_DEBUG")
|
||||
add_compile_definitions("EDITOR_DEBUG")
|
||||
add_compile_definitions("EMOJI_DEBUG")
|
||||
add_compile_definitions("ETHERNET_DEBUG")
|
||||
add_compile_definitions("ETHERNET_VERY_DEBUG")
|
||||
add_compile_definitions("EVENTLOOP_DEBUG")
|
||||
add_compile_definitions("EVENT_DEBUG")
|
||||
add_compile_definitions("EXEC_DEBUG")
|
||||
add_compile_definitions("EXT2_DEBUG")
|
||||
add_compile_definitions("EXT2_VERY_DEBUG")
|
||||
add_compile_definitions("FIFO_DEBUG")
|
||||
add_compile_definitions("FILL_PATH_DEBUG")
|
||||
add_compile_definitions("FORK_DEBUG")
|
||||
add_compile_definitions("GBOXLAYOUT_DEBUG")
|
||||
add_compile_definitions("GEMINIJOB_DEBUG")
|
||||
add_compile_definitions("GEMINI_DEBUG")
|
||||
add_compile_definitions("GENERATE_DEBUG_CODE")
|
||||
add_compile_definitions("GHASH_PROCESS_DEBUG")
|
||||
add_compile_definitions("GIF_DEBUG")
|
||||
add_compile_definitions("GLOBAL_DTORS_DEBUG")
|
||||
add_compile_definitions("GMENU_DEBUG")
|
||||
add_compile_definitions("GPT_DEBUG")
|
||||
add_compile_definitions("HEAP_DEBUG")
|
||||
add_compile_definitions("HEX_DEBUG")
|
||||
add_compile_definitions("HPET_COMPARATOR_DEBUG")
|
||||
add_compile_definitions("HPET_DEBUG")
|
||||
add_compile_definitions("HTTPSJOB_DEBUG")
|
||||
add_compile_definitions("ICMP_DEBUG")
|
||||
add_compile_definitions("ICO_DEBUG")
|
||||
add_compile_definitions("IMAGE_DECODER_CLIENT_DEBUG")
|
||||
add_compile_definitions("IMAGE_DECODER_DEBUG")
|
||||
add_compile_definitions("IMAGE_LOADER_DEBUG")
|
||||
add_compile_definitions("INTERRUPT_DEBUG")
|
||||
add_compile_definitions("IOAPIC_DEBUG")
|
||||
add_compile_definitions("IPC_DEBUG")
|
||||
add_compile_definitions("IPV4_DEBUG")
|
||||
add_compile_definitions("IPV4_SOCKET_DEBUG")
|
||||
add_compile_definitions("IRC_DEBUG")
|
||||
add_compile_definitions("IRQ_DEBUG")
|
||||
add_compile_definitions("Image_DEBUG")
|
||||
add_compile_definitions("JOB_DEBUG")
|
||||
add_compile_definitions("JPG_DEBUG")
|
||||
add_compile_definitions("KEYBOARD_DEBUG")
|
||||
add_compile_definitions("KEYBOARD_SHORTCUTS_DEBUG")
|
||||
add_compile_definitions("KMALLOC_DEBUG_LARGE_ALLOCATIONS")
|
||||
add_compile_definitions("LEXER_DEBUG")
|
||||
add_compile_definitions("LOCK_DEBUG")
|
||||
add_compile_definitions("LOCK_RESTORE_DEBUG")
|
||||
add_compile_definitions("LOCK_TRACE_DEBUG")
|
||||
add_compile_definitions("LOOKUPSERVER_DEBUG")
|
||||
add_compile_definitions("Loader_DEBUG")
|
||||
add_compile_definitions("MALLOC_DEBUG")
|
||||
add_compile_definitions("MASTERPTY_DEBUG")
|
||||
add_compile_definitions("MBR_DEBUG")
|
||||
add_compile_definitions("MEMORY_DEBUG")
|
||||
add_compile_definitions("MENU_DEBUG")
|
||||
add_compile_definitions("MINIMIZE_ANIMATION_DEBUG")
|
||||
add_compile_definitions("MM_DEBUG")
|
||||
add_compile_definitions("MOVE_DEBUG")
|
||||
add_compile_definitions("MULTIPROCESSOR_DEBUG")
|
||||
add_compile_definitions("NETWORK_TASK_DEBUG")
|
||||
add_compile_definitions("NT_DEBUG")
|
||||
add_compile_definitions("OBJECT_DEBUG")
|
||||
add_compile_definitions("OCCLUSIONS_DEBUG")
|
||||
add_compile_definitions("OFFD_DEBUG")
|
||||
add_compile_definitions("PAGE_FAULT_DEBUG")
|
||||
add_compile_definitions("PARSER_DEBUG")
|
||||
add_compile_definitions("PATA_DEBUG")
|
||||
add_compile_definitions("PATA_DEVICE_DEBUG")
|
||||
add_compile_definitions("PATH_DEBUG")
|
||||
add_compile_definitions("PCI_DEBUG")
|
||||
add_compile_definitions("PNG_DEBUG")
|
||||
add_compile_definitions("PORTABLE_IMAGE_LOADER_DEBUG")
|
||||
add_compile_definitions("PROCESS_DEBUG")
|
||||
add_compile_definitions("PROCFS_DEBUG")
|
||||
add_compile_definitions("PS2MOUSE_DEBUG")
|
||||
add_compile_definitions("PTHREAD_DEBUG")
|
||||
add_compile_definitions("PTMX_DEBUG")
|
||||
add_compile_definitions("REACHABLE_DEBUG")
|
||||
add_compile_definitions("REGEX_DEBUG")
|
||||
add_compile_definitions("RESIZE_DEBUG")
|
||||
add_compile_definitions("RESOURCE_DEBUG")
|
||||
add_compile_definitions("ROUTING_DEBUG")
|
||||
add_compile_definitions("RTL8139_DEBUG")
|
||||
add_compile_definitions("SAFE_SYSCALL_DEBUG")
|
||||
add_compile_definitions("SB16_DEBUG")
|
||||
add_compile_definitions("SCHEDULER_DEBUG")
|
||||
add_compile_definitions("SCHEDULER_RUNNABLE_DEBUG")
|
||||
add_compile_definitions("SELECTION_DEBUG")
|
||||
add_compile_definitions("SERVICE_DEBUG")
|
||||
add_compile_definitions("SHARED_BUFFER_DEBUG")
|
||||
add_compile_definitions("SH_DEBUG")
|
||||
add_compile_definitions("SIGNAL_DEBUG")
|
||||
add_compile_definitions("SLAVEPTY_DEBUG")
|
||||
add_compile_definitions("SMP_DEBUG")
|
||||
add_compile_definitions("SOCKET_DEBUG")
|
||||
add_compile_definitions("STORAGE_DEVICE_DEBUG")
|
||||
add_compile_definitions("SYSTEMSERVER_DEBUG")
|
||||
add_compile_definitions("SYSTEM_MENU_DEBUG")
|
||||
add_compile_definitions("TCP_DEBUG")
|
||||
add_compile_definitions("TCP_SOCKET_DEBUG")
|
||||
add_compile_definitions("TERMCAP_DEBUG")
|
||||
add_compile_definitions("TERMINAL_DEBUG")
|
||||
add_compile_definitions("THREAD_DEBUG")
|
||||
add_compile_definitions("TLS_DEBUG")
|
||||
add_compile_definitions("TTY_DEBUG")
|
||||
add_compile_definitions("UCI_DEBUG")
|
||||
add_compile_definitions("UDP_DEBUG")
|
||||
add_compile_definitions("UPDATE_COALESCING_DEBUG")
|
||||
add_compile_definitions("VERY_DEBUG")
|
||||
add_compile_definitions("VFS_DEBUG")
|
||||
add_compile_definitions("VMWAREBACKDOOR_DEBUG")
|
||||
add_compile_definitions("VRA_DEBUG")
|
||||
add_compile_definitions("WAITBLOCK_DEBUG")
|
||||
add_compile_definitions("WAITQUEUE_DEBUG")
|
||||
add_compile_definitions("WEAKABLE_DEBUG")
|
||||
add_compile_definitions("WINDOWMANAGER_DEBUG")
|
||||
add_compile_definitions("WSMESSAGELOOP_DEBUG")
|
||||
add_compile_definitions("WSSCREEN_DEBUG")
|
||||
# False positive: IF_BMP_DEBUG is not actually a flag.
|
||||
# add_compile_definitions("IF_BMP_DEBUG")
|
||||
# False positive: LOG_DEBUG is a flag, but for a bitset, not a feature.
|
||||
# add_compile_definitions("LOG_DEBUG")
|
130
Meta/CMake/utils.cmake
Normal file
130
Meta/CMake/utils.cmake
Normal file
|
@ -0,0 +1,130 @@
|
|||
function(serenity_install_headers target_name)
|
||||
file(GLOB_RECURSE headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||
foreach(header ${headers})
|
||||
get_filename_component(subdirectory ${header} DIRECTORY)
|
||||
install(FILES ${header} DESTINATION usr/include/${target_name}/${subdirectory})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(serenity_install_sources target_name)
|
||||
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})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(serenity_generated_sources target_name)
|
||||
if(DEFINED GENERATED_SOURCES)
|
||||
set_source_files_properties(${GENERATED_SOURCES} PROPERTIES GENERATED 1)
|
||||
foreach(generated ${GENERATED_SOURCES})
|
||||
get_filename_component(generated_name ${generated} NAME)
|
||||
add_dependencies(${target_name} generate_${generated_name})
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(serenity_lib target_name fs_name)
|
||||
serenity_install_headers(${target_name})
|
||||
serenity_install_sources("Libraries/${target_name}")
|
||||
#add_library(${target_name} SHARED ${SOURCES} ${GENERATED_SOURCES})
|
||||
add_library(${target_name} SHARED ${SOURCES} ${GENERATED_SOURCES} ${CMAKE_SOURCE_DIR}/Libraries/LibC/crt0_shared.cpp)
|
||||
#library_sources("{target_name}" PRIVATE ${CMAKE_SOURCE_DIR}/Libraries/LibC/crt0_shared.cpp)
|
||||
install(TARGETS ${target_name} DESTINATION usr/lib)
|
||||
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
|
||||
serenity_generated_sources(${target_name})
|
||||
endfunction()
|
||||
|
||||
function(serenity_shared_lib target_name fs_name)
|
||||
serenity_install_headers(${target_name})
|
||||
serenity_install_sources("Libraries/${target_name}")
|
||||
add_library(${target_name} SHARED ${SOURCES} ${GENERATED_SOURCES})
|
||||
install(TARGETS ${target_name} DESTINATION usr/lib)
|
||||
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
|
||||
serenity_generated_sources(${target_name})
|
||||
endfunction()
|
||||
|
||||
function(serenity_libc target_name fs_name)
|
||||
serenity_install_headers("")
|
||||
serenity_install_sources("Libraries/LibC")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib -fpic")
|
||||
add_library(${target_name} SHARED ${SOURCES})
|
||||
install(TARGETS ${target_name} DESTINATION usr/lib)
|
||||
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
|
||||
target_link_directories(LibC PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
serenity_generated_sources(${target_name})
|
||||
endfunction()
|
||||
|
||||
function(serenity_libc_static target_name fs_name)
|
||||
serenity_install_headers("")
|
||||
serenity_install_sources("Libraries/LibC")
|
||||
add_library(${target_name} ${SOURCES})
|
||||
install(TARGETS ${target_name} ARCHIVE DESTINATION usr/lib)
|
||||
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${fs_name})
|
||||
target_link_directories(${target_name} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
serenity_generated_sources(${target_name})
|
||||
endfunction()
|
||||
|
||||
function(serenity_bin target_name)
|
||||
add_executable(${target_name} ${SOURCES})
|
||||
target_sources(${target_name} PRIVATE ${CMAKE_SOURCE_DIR}/Libraries/LibC/crt0_shared.cpp)
|
||||
install(TARGETS ${target_name} RUNTIME DESTINATION bin)
|
||||
serenity_generated_sources(${target_name})
|
||||
endfunction()
|
||||
|
||||
function(serenity_app target_name)
|
||||
cmake_parse_arguments(SERENITY_APP "" "ICON" "" ${ARGN})
|
||||
|
||||
serenity_bin("${target_name}")
|
||||
set(small_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/16x16/${SERENITY_APP_ICON}.png")
|
||||
set(medium_icon "${CMAKE_SOURCE_DIR}/Base/res/icons/32x32/${SERENITY_APP_ICON}.png")
|
||||
|
||||
if (EXISTS "${small_icon}")
|
||||
embed_resource("${target_name}" serenity_icon_s "${small_icon}")
|
||||
endif()
|
||||
if (EXISTS "${medium_icon}")
|
||||
embed_resource("${target_name}" serenity_icon_m "${medium_icon}")
|
||||
endif()
|
||||
|
||||
# TODO: Issue warnings if the app icons don't exist
|
||||
endfunction()
|
||||
|
||||
function(compile_gml source output string_name)
|
||||
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
|
||||
add_custom_command(
|
||||
OUTPUT ${output}
|
||||
COMMAND ${write_if_different} ${output} ${CMAKE_SOURCE_DIR}/Meta/text-to-cpp-string.sh ${string_name} ${source}
|
||||
VERBATIM
|
||||
DEPENDS ${CMAKE_SOURCE_DIR}/Meta/text-to-cpp-string.sh
|
||||
MAIN_DEPENDENCY ${source}
|
||||
)
|
||||
get_filename_component(output_name ${output} NAME)
|
||||
add_custom_target(generate_${output_name} DEPENDS ${output})
|
||||
endfunction()
|
||||
|
||||
|
||||
function(compile_ipc source output)
|
||||
set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
|
||||
add_custom_command(
|
||||
OUTPUT ${output}
|
||||
COMMAND ${write_if_different} ${output} ${CMAKE_BINARY_DIR}/DevTools/IPCCompiler/IPCCompiler ${source}
|
||||
VERBATIM
|
||||
DEPENDS IPCCompiler
|
||||
MAIN_DEPENDENCY ${source}
|
||||
)
|
||||
get_filename_component(output_name ${output} NAME)
|
||||
add_custom_target(generate_${output_name} DEPENDS ${output})
|
||||
endfunction()
|
||||
|
||||
function(embed_resource target section file)
|
||||
get_filename_component(asm_file "${file}" NAME)
|
||||
set(asm_file "${CMAKE_CURRENT_BINARY_DIR}/${target}-${section}.s")
|
||||
get_filename_component(input_file "${file}" ABSOLUTE)
|
||||
add_custom_command(
|
||||
OUTPUT "${asm_file}"
|
||||
COMMAND "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh" "${asm_file}" "${section}" "${input_file}"
|
||||
DEPENDS "${input_file}" "${CMAKE_SOURCE_DIR}/Meta/generate-embedded-resource-assembly.sh"
|
||||
COMMENT "Generating ${asm_file}"
|
||||
)
|
||||
target_sources("${target}" PRIVATE "${asm_file}")
|
||||
endfunction()
|
Loading…
Add table
Add a link
Reference in a new issue