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 @@ ...@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId> <groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-middleware-generator</artifactId> <artifactId>embedded-montiarc-math-middleware-generator</artifactId>
<version>0.0.15-SNAPSHOT</version> <version>0.0.16-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= --> <!-- == PROJECT DEPENDENCIES ============================================= -->
......
...@@ -70,18 +70,12 @@ public class DistributedTargetGenerator extends CMakeGenerator { ...@@ -70,18 +70,12 @@ public class DistributedTargetGenerator extends CMakeGenerator {
protected File generateCMake(EMAComponentInstanceSymbol componentInstanceSymbol) throws IOException { protected File generateCMake(EMAComponentInstanceSymbol componentInstanceSymbol) throws IOException {
FileContent fileContent = new FileContent(); FileContent fileContent = new FileContent();
fileContent.setFileName("CMakeLists.txt"); 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( StringBuilder content = new StringBuilder();
dir -> content.append("add_subdirectory(" + dir + ")\n") content.append(TemplateHelper.getSubprojectsCMake());
);
subDirs.stream().filter(dir -> !dir.equals("rosMsg")).forEach( subDirs.forEach(
dir -> content.append("add_subdirectory(" + dir + ")\n") dir -> content.append("add_subdir_without_target_import(" + dir + ")\n")
); );
fileContent.setFileContent(content.toString()); fileContent.setFileContent(content.toString());
......
...@@ -48,4 +48,8 @@ public class TemplateHelper { ...@@ -48,4 +48,8 @@ public class TemplateHelper {
return getTemplate("coordinatorCmakeListsTemplate.ftl"); 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