Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
generators
EMAM2Cpp
Commits
12890f21
Commit
12890f21
authored
Aug 08, 2018
by
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
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/monticar/generator/cpp/TestsGeneratorCPP.java
View file @
12890f21
...
...
@@ -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
()
{
...
...
src/test/resources/results/cmake/test/BasicPortsMath/CMakeLists.txt
View file @
12890f21
...
...
@@ -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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment