From a6d83e02d2b641f9e7e86cb9029f7716dfdd562f Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Mon, 6 Sep 2021 23:34:28 -0600 Subject: [PATCH] Meta: Define and use lagom_tool() CMake helper function for all Tools We'll use this to prevent repeating common tool dependencies. They all depend on LibCore and AK only. We also want to encapsulate common install rules for them. --- Meta/Lagom/Tools/CMakeLists.txt | 13 +++++++++++++ .../CodeGenerators/IPCCompiler/CMakeLists.txt | 3 +-- .../CodeGenerators/LibUnicode/CMakeLists.txt | 14 ++++++++++---- .../Tools/CodeGenerators/LibWeb/CMakeLists.txt | 17 +++++++---------- .../StateMachineGenerator/CMakeLists.txt | 3 +-- .../Tools/ConfigureComponents/CMakeLists.txt | 3 +-- 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/Meta/Lagom/Tools/CMakeLists.txt b/Meta/Lagom/Tools/CMakeLists.txt index 821c9baaa6..46adbcaaf4 100644 --- a/Meta/Lagom/Tools/CMakeLists.txt +++ b/Meta/Lagom/Tools/CMakeLists.txt @@ -1,2 +1,15 @@ +function(lagom_tool tool) + cmake_parse_arguments(LAGOM_TOOL "" "" "SOURCES" ${ARGN}) + add_executable(${tool} ${SOURCES} ${LAGOM_TOOL_SOURCES}) + # alias for parity with exports + add_executable(Lagom::${tool} ALIAS ${tool}) + target_link_libraries(${tool} LagomCore) + install( + TARGETS ${tool} + EXPORT LagomTargets + RUNTIME COMPONENT Lagom_Runtime + ) +endfunction() + add_subdirectory(ConfigureComponents) add_subdirectory(CodeGenerators) diff --git a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/CMakeLists.txt b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/CMakeLists.txt index 6969cef777..c734d1c175 100644 --- a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/CMakeLists.txt +++ b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/CMakeLists.txt @@ -2,5 +2,4 @@ set(SOURCES main.cpp ) -add_executable(IPCCompiler ${SOURCES}) -target_link_libraries(IPCCompiler LagomCore) +lagom_tool(IPCCompiler) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/CMakeLists.txt b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/CMakeLists.txt index 5fa68e5674..6b7ce96fc6 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/CMakeLists.txt +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/CMakeLists.txt @@ -1,5 +1,11 @@ -add_executable(GenerateUnicodeData GenerateUnicodeData.cpp) -target_link_libraries(GenerateUnicodeData LagomCore) +set(SOURCES + GenerateUnicodeData.cpp +) -add_executable(GenerateUnicodeLocale GenerateUnicodeLocale.cpp) -target_link_libraries(GenerateUnicodeLocale LagomCore) +lagom_tool(GenerateUnicodeData) + +set(SOURCES + GenerateUnicodeLocale.cpp +) + +lagom_tool(GenerateUnicodeLocale) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/CMakeLists.txt b/Meta/Lagom/Tools/CodeGenerators/LibWeb/CMakeLists.txt index b3c4073df9..3c0c5d1f30 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/CMakeLists.txt +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/CMakeLists.txt @@ -1,11 +1,8 @@ -add_executable(Generate_CSS_PropertyID_h Generate_CSS_PropertyID_h.cpp) -add_executable(Generate_CSS_PropertyID_cpp Generate_CSS_PropertyID_cpp.cpp) -add_executable(Generate_CSS_ValueID_h Generate_CSS_ValueID_h.cpp) -add_executable(Generate_CSS_ValueID_cpp Generate_CSS_ValueID_cpp.cpp) -add_executable(WrapperGenerator WrapperGenerator.cpp) +set(SOURCES "") # avoid pulling SOURCES from parent scope + +lagom_tool(Generate_CSS_PropertyID_h SOURCES Generate_CSS_PropertyID_h.cpp) +lagom_tool(Generate_CSS_PropertyID_cpp SOURCES Generate_CSS_PropertyID_cpp.cpp) +lagom_tool(Generate_CSS_ValueID_h SOURCES Generate_CSS_ValueID_h.cpp) +lagom_tool(Generate_CSS_ValueID_cpp SOURCES Generate_CSS_ValueID_cpp.cpp) +lagom_tool(WrapperGenerator SOURCES WrapperGenerator.cpp) target_compile_options(WrapperGenerator PUBLIC -g) -target_link_libraries(Generate_CSS_PropertyID_h LagomCore) -target_link_libraries(Generate_CSS_PropertyID_cpp LagomCore) -target_link_libraries(Generate_CSS_ValueID_h LagomCore) -target_link_libraries(Generate_CSS_ValueID_cpp LagomCore) -target_link_libraries(WrapperGenerator LagomCore) diff --git a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/CMakeLists.txt b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/CMakeLists.txt index b5e5da6c8d..98fafd84cc 100644 --- a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/CMakeLists.txt +++ b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/CMakeLists.txt @@ -2,5 +2,4 @@ set(SOURCES main.cpp ) -add_executable(StateMachineGenerator ${SOURCES}) -target_link_libraries(StateMachineGenerator LagomCore) +lagom_tool(StateMachineGenerator) diff --git a/Meta/Lagom/Tools/ConfigureComponents/CMakeLists.txt b/Meta/Lagom/Tools/ConfigureComponents/CMakeLists.txt index acc15f9dde..d5f314c778 100644 --- a/Meta/Lagom/Tools/ConfigureComponents/CMakeLists.txt +++ b/Meta/Lagom/Tools/ConfigureComponents/CMakeLists.txt @@ -2,5 +2,4 @@ set(SOURCES main.cpp ) -add_executable(ConfigureComponents ${SOURCES}) -target_link_libraries(ConfigureComponents LagomCore) +lagom_tool(ConfigureComponents)