Fix target conflict when generating the same msg files in several subprojects

parent 6138102d
Pipeline #104138 passed with stages
in 9 minutes and 30 seconds
......@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-middleware-generator</artifactId>
<version>0.0.15-SNAPSHOT</version>
<version>0.0.16-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......
......@@ -70,18 +70,12 @@ public class DistributedTargetGenerator extends CMakeGenerator {
protected File generateCMake(EMAComponentInstanceSymbol componentInstanceSymbol) throws IOException {
FileContent fileContent = new FileContent();
fileContent.setFileName("CMakeLists.txt");
StringBuilder content = new StringBuilder();
content.append("cmake_minimum_required(VERSION 3.5)\n");
//TODO setProjectName?
content.append("project (default)\n");
content.append("set (CMAKE_CXX_STANDARD 11)\n");
subDirs.stream().filter(dir -> dir.equals("rosMsg")).forEach(
dir -> content.append("add_subdirectory(" + dir + ")\n")
);
StringBuilder content = new StringBuilder();
content.append(TemplateHelper.getSubprojectsCMake());
subDirs.stream().filter(dir -> !dir.equals("rosMsg")).forEach(
dir -> content.append("add_subdirectory(" + dir + ")\n")
subDirs.forEach(
dir -> content.append("add_subdir_without_target_import(" + dir + ")\n")
);
fileContent.setFileContent(content.toString());
......
......@@ -48,4 +48,8 @@ public class TemplateHelper {
return getTemplate("coordinatorCmakeListsTemplate.ftl");
}
public static String getSubprojectsCMake() {
return getTemplate("SubprojectsCMakeListsTemplate.ftl");
}
}
cmake_minimum_required(VERSION 3.5)
project (default)
set (CMAKE_CXX_STANDARD 14)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
function(add_subdir_without_target_import subdir)
ExternalProject_Add(
_${subdir}
DOWNLOAD_COMMAND ""
INSTALL_COMMAND cmake -E echo "Skipping install step."
SOURCE_DIR ${CMAKE_SOURCE_DIR}/${subdir}
BUILD_ALWAYS 1
)
endfunction(add_subdir_without_target_import)
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