Commit 12890f21 authored by Christoph Richter's avatar Christoph Richter
Browse files

StreamTest CMake generation: Link against already created library if possible

parent f4b6dbee
Pipeline #67184 passed with stage
in 2 minutes and 49 seconds
......@@ -99,18 +99,24 @@ public final class TestsGeneratorCPP {
private void addTestExecutionToCMakeConfig(ExpandedComponentInstanceSymbol componentSymbol) {
// executable name
String name;
if (componentSymbol != null)
name = componentSymbol.getFullName().replace('.', '_').replace('[', '_').replace(']', '_') + "_StreamTests";
else
name = "StreamTests";
String compName;
final String execuatablePostFix = "_StreamTests";
CMakeConfig cmake = generator.getCMakeConfig();
cmake.addCMakeCommandEnd("include_directories(test)");
cmake.addCMakeCommandEnd("add_executable(" + name + " test/tests_main.cpp)");
cmake.addCMakeCommandEnd("target_compile_definitions(" + name + " PRIVATE CATCH_CONFIG_MAIN=1 ARMA_DONT_USE_WRAPPER)");
cmake.addCMakeCommandEnd("target_include_directories(" + name + " PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})");
cmake.addCMakeCommandEnd("target_link_libraries(" + name + " PUBLIC ${LIBS})");
cmake.addCMakeCommandEnd("set_target_properties(" + name + " PROPERTIES LINKER_LANGUAGE CXX)");
if (componentSymbol != null) {
compName = componentSymbol.getFullName().replace('.', '_').replace('[', '_').replace(']', '_');
} else {
compName = "";
}
cmake.addCMakeCommandEnd("add_executable(" + compName + execuatablePostFix + " test/tests_main.cpp)");
cmake.addCMakeCommandEnd("target_compile_definitions(" + compName + execuatablePostFix + " PRIVATE CATCH_CONFIG_MAIN=1 ARMA_DONT_USE_WRAPPER)");
if (compName.isEmpty()) {
cmake.addCMakeCommandEnd("target_include_directories(" + compName + execuatablePostFix + " PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})");
cmake.addCMakeCommandEnd("target_link_libraries(" + compName + execuatablePostFix + " PUBLIC ${LIBS})");
} else { // link against already created static library
cmake.addCMakeCommandEnd("target_link_libraries(" + compName + execuatablePostFix + " PUBLIC " + compName + ")");
}
cmake.addCMakeCommandEnd("set_target_properties(" + compName + execuatablePostFix + " PROPERTIES LINKER_LANGUAGE CXX)");
}
private String getExistingComponentNames() {
......
......@@ -27,6 +27,5 @@ export(TARGETS test_basicPortsMath FILE test_basicPortsMath.cmake)
include_directories(test)
add_executable(test_basicPortsMath_StreamTests test/tests_main.cpp)
target_compile_definitions(test_basicPortsMath_StreamTests PRIVATE CATCH_CONFIG_MAIN=1 ARMA_DONT_USE_WRAPPER)
target_include_directories(test_basicPortsMath_StreamTests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(test_basicPortsMath_StreamTests PUBLIC ${LIBS})
target_link_libraries(test_basicPortsMath_StreamTests PUBLIC test_basicPortsMath)
set_target_properties(test_basicPortsMath_StreamTests PROPERTIES LINKER_LANGUAGE CXX)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment