Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add precompiler definition FMI2_FUNCTION_PREFIX for static CMake FMUs (…
…#10509) * Compile static CMake FMUs * Add FMI2_FUNCTION_PREFIX to CMakeLists.txt * Adding test to re-compile static FMU
- Loading branch information
1 parent
cce0dbf
commit 872d6a9
Showing
6 changed files
with
122 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
testsuite/openmodelica/fmi/CoSimulation/2.0/RecompileSourceCodeFMU.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// name: RecompileSourceCodeFMU | ||
// keywords: fmu export simulation flags | ||
// status: correct | ||
// teardown_command: rm -rf Test_SinSource* reCompile.log Test.SinSource.fmu | ||
// | ||
// Export SinSource as 2.0 CS FMU with CVODE solver and re-compile FMU with static library | ||
|
||
// Generate FMU | ||
loadModel(Modelica, {"4.0.0"}); getErrorString(); | ||
loadString(" | ||
package Test | ||
model SinSource | ||
parameter Real amp=1; | ||
parameter Real freq=1; | ||
Modelica.Blocks.Interfaces.RealOutput y; | ||
protected | ||
Modelica.Blocks.Sources.Sine sine(amplitude = amp, f = freq); | ||
equation | ||
connect(sine.y, y); | ||
end SinSource; | ||
end Test; | ||
"); getErrorString(); | ||
|
||
setCommandLineOptions("--fmuCMakeBuild=true --fmiFlags=s:cvode --fmuRuntimeDepends=none"); getErrorString(); | ||
buildModelFMU(Test.SinSource, version="2.0", fmuType ="cs", platforms={"static"}); getErrorString(); | ||
|
||
// Check if CMake can re-compile a static library | ||
system("rm -rf Test_SinSource_FMU && unzip -qq Test.SinSource.fmu -d Test_SinSource_FMU && mkdir Test_SinSource_FMU/sources/build_cmake", outputFile="reCompile.log"); getErrorString(); | ||
//readFile("reCompile.log"); | ||
system("cd Test_SinSource_FMU/sources/build_cmake && cmake .. -DBUILD_SHARED_LIBS=OFF && cmake --build . && make install", outputFile="reCompile.log"); getErrorString(); | ||
//readFile("reCompile.log"); | ||
|
||
// Check if static library was compiled and that it used FMI2_FUNCTION_PREFIX=Test_SinSource_FMU for function names | ||
// Has to return "Test_SinSource_fmi2GetReal" | ||
system("nm Test_SinSource_FMU/binaries/linux64/Test_SinSource.a | grep -wo Test_SinSource_fmi2GetReal"); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// "Test.SinSource.fmu" | ||
// "" | ||
// 0 | ||
// "" | ||
// 0 | ||
// "" | ||
// Test_SinSource_fmi2GetReal | ||
// 0 | ||
// "" | ||
// endResult |