diff options
-rw-r--r-- | AK/CMakeLists.txt | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 133 | ||||
-rw-r--r-- | Meta/CMake/all_the_debug_macros.cmake (renamed from Meta/all_the_debug_macros.cmake) | 0 | ||||
-rw-r--r-- | Meta/CMake/utils.cmake | 130 | ||||
-rwxr-xr-x | Meta/check-debug-flags.sh | 2 |
5 files changed, 133 insertions, 133 deletions
diff --git a/AK/CMakeLists.txt b/AK/CMakeLists.txt index 5fc9dcd20e..509d3d4509 100644 --- a/AK/CMakeLists.txt +++ b/AK/CMakeLists.txt @@ -1,2 +1,3 @@ +include(${CMAKE_SOURCE_DIR}/Meta/CMake/utils.cmake) serenity_install_headers(AK) serenity_install_sources(AK) diff --git a/CMakeLists.txt b/CMakeLists.txt index 024f5223a9..0c83aed194 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") endif() if (ALL_THE_DEBUG_MACROS) - include(Meta/all_the_debug_macros.cmake) + include(${CMAKE_SOURCE_DIR}/Meta/CMake/all_the_debug_macros.cmake) endif(ALL_THE_DEBUG_MACROS) include_directories(Libraries) @@ -69,137 +69,6 @@ add_subdirectory(Libraries/LibRegex/Tests) set(write_if_different ${CMAKE_SOURCE_DIR}/Meta/write-only-on-difference.sh) -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() - find_program(CCACHE_PROGRAM ccache) if(CCACHE_PROGRAM) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}") diff --git a/Meta/all_the_debug_macros.cmake b/Meta/CMake/all_the_debug_macros.cmake index e0e637f07a..e0e637f07a 100644 --- a/Meta/all_the_debug_macros.cmake +++ b/Meta/CMake/all_the_debug_macros.cmake diff --git a/Meta/CMake/utils.cmake b/Meta/CMake/utils.cmake new file mode 100644 index 0000000000..093b16bbae --- /dev/null +++ b/Meta/CMake/utils.cmake @@ -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() diff --git a/Meta/check-debug-flags.sh b/Meta/check-debug-flags.sh index 0d305bfd7f..822d348caa 100755 --- a/Meta/check-debug-flags.sh +++ b/Meta/check-debug-flags.sh @@ -11,7 +11,7 @@ while IFS= read -r FLAG; do # We simply search whether the CMakeLists.txt *ever* sets the flag. # There are (basically) no false positives, but there might be false negatives, # for example we intentionally don't check for commented-out lines here. - if ! grep -qP "add_compile_definitions\(\"${FLAG}" Meta/all_the_debug_macros.cmake ; then + if ! grep -qP "add_compile_definitions\(\"${FLAG}" Meta/CMake/all_the_debug_macros.cmake ; then echo "ALL_THE_DEBUG_MACROS probably doesn't include ${FLAG}" MISSING_FLAGS=y fi |