| 18 | } |
| 19 | |
| 20 | std::string genCMake(const std::string name) |
| 21 | { |
| 22 | using namespace fmt::literals; |
| 23 | |
| 24 | return fmt::format(R"(set(COMPONENT_NAME {name}) |
| 25 | |
| 26 | set(SRC |
| 27 | {name}.cpp |
| 28 | {name}_p.cpp |
| 29 | {name}model.cpp |
| 30 | ) |
| 31 | |
| 32 | add_library(${{COMPONENT_NAME}} ${{SRC}}) |
| 33 | target_link_libraries(${{COMPONENT_NAME}} Qt5::Widgets Qt5::Core Qt5::SerialBus nodes cds-common) |
| 34 | target_include_directories(${{COMPONENT_NAME}} INTERFACE ${{CMAKE_CURRENT_SOURCE_DIR}}) |
| 35 | |
| 36 | if(WITH_TESTS) |
| 37 | add_executable(${{COMPONENT_NAME}}_test tests/${{COMPONENT_NAME}}_test.cpp) |
| 38 | target_link_libraries(${{COMPONENT_NAME}}_test ${{COMPONENT_NAME}} Qt5::Test fakeit) |
| 39 | add_test(NAME ${{COMPONENT_NAME}}_test COMMAND ${{COMPONENT_NAME}}_test) |
| 40 | |
| 41 | add_executable(${{COMPONENT_NAME}}model_test tests/${{COMPONENT_NAME}}model_test.cpp) |
| 42 | target_link_libraries(${{COMPONENT_NAME}}model_test ${{COMPONENT_NAME}} Qt5::Test fakeit) |
| 43 | add_test(NAME ${{COMPONENT_NAME}}model_test COMMAND ${{COMPONENT_NAME}}model_test) |
| 44 | endif() |
| 45 | )", |
| 46 | "name"_a = name); |
| 47 | } |
| 48 | |
| 49 | std::string genComponentHdr(const std::string& name) |
| 50 | { |