summaryrefslogtreecommitdiff
path: root/Meta/CMake/code_generators.cmake
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2022-05-19 23:46:36 -0600
committerAndreas Kling <kling@serenityos.org>2022-05-23 23:05:45 +0200
commitca42da23c232623f28bb67bb6a373709701875fe (patch)
treee22018a3efc59f99966502284343b1ac03ba1f23 /Meta/CMake/code_generators.cmake
parentf19aad8336cf3c53a2f805be121f49fcf3a3877f (diff)
downloadserenity-ca42da23c232623f28bb67bb6a373709701875fe.zip
Meta+Userland: Add jakt as an optional Lagom Tool
We can now use ENABLE_JAKT to pull jakt as a host tool and use it to pre-process .jakt files into .cpp files for use in serenity applications
Diffstat (limited to 'Meta/CMake/code_generators.cmake')
-rw-r--r--Meta/CMake/code_generators.cmake22
1 files changed, 22 insertions, 0 deletions
diff --git a/Meta/CMake/code_generators.cmake b/Meta/CMake/code_generators.cmake
index 0baf6fd117..90340fdbae 100644
--- a/Meta/CMake/code_generators.cmake
+++ b/Meta/CMake/code_generators.cmake
@@ -62,3 +62,25 @@ function(generate_state_machine source header)
add_dependencies(all_generated ${target_name})
endif()
endfunction()
+
+function(compile_jakt source)
+ set(source ${CMAKE_CURRENT_SOURCE_DIR}/${source})
+ get_filename_component(source_base ${source} NAME_WE)
+ set(output "${source_base}.cpp")
+ add_custom_command(
+ OUTPUT ${output}
+ COMMAND $<TARGET_FILE:Lagom::jakt> -o "${CMAKE_CURRENT_BINARY_DIR}/jakt_tmp" ${source}
+ COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/jakt_tmp/${output}" ${output}
+ COMMAND "${CMAKE_COMMAND}" -E remove "${CMAKE_CURRENT_BINARY_DIR}/jakt_tmp/${output}"
+ VERBATIM
+ DEPENDS Lagom::jakt
+ MAIN_DEPENDENCY ${source}
+ )
+ get_property(JAKT_INCLUDE_DIR TARGET Lagom::jakt PROPERTY IMPORTED_INCLUDE_DIRECTORIES)
+ set_source_files_properties("${output}" PROPERTIES
+ INCLUDE_DIRECTORIES "${JAKT_INCLUDE_DIR};${JAKT_INCLUDE_DIR}/runtime"
+ COMPILE_FLAGS "-Wno-unused-local-typedefs")
+ get_filename_component(output_name ${output} NAME)
+ add_custom_target(generate_${output_name} DEPENDS ${output})
+ add_dependencies(all_generated generate_${output_name})
+endfunction()