Skip to content

Commit 4d104bb

Browse files
Some mingw support
1 parent 64be417 commit 4d104bb

File tree

12 files changed

+86
-31
lines changed

12 files changed

+86
-31
lines changed

Modelica_DeviceDrivers/OperatingSystem/RealTimeSynchronization.mo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ class RealTimeSynchronization "An object for real-time synchronization."
33
extends ExternalObject;
44
function constructor "Creates a RealTimeSynchronization instance."
55
output RealTimeSynchronization rtSync;
6-
external "C" rtSync = MDD_realtimeSynchronizeConstructor()
6+
external "C" rtSync= MDD_realtimeSynchronizeConstructor()
77
annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
88
Include = "#include \"MDDRealtimeSynchronize.h\" ",
9-
Library = "rt",
9+
Library = {"rt", "Winmm"},
1010
__iti_dll = "ITI_MDD.dll");
1111
end constructor;
1212

@@ -15,7 +15,7 @@ class RealTimeSynchronization "An object for real-time synchronization."
1515
external "C" MDD_realtimeSynchronizeDestructor(rtSync)
1616
annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
1717
Include = "#include \"MDDRealtimeSynchronize.h\" ",
18-
Library = "rt",
18+
Library = {"rt", "Winmm"},
1919
__iti_dll = "ITI_MDD.dll");
2020
end destructor;
2121
end RealTimeSynchronization;
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
within Modelica_DeviceDrivers.OperatingSystem;
2-
function realtimeSynchronize "pauses the simulation until synchronization with real-time is achieved"
2+
function realtimeSynchronize
3+
"pauses the simulation until synchronization with real-time is achieved"
34
input Modelica_DeviceDrivers.OperatingSystem.RealTimeSynchronization rtSync;
45
input Real simTime;
56
output Real calculationTime;
67
output Real availableTime;
78
external "C" calculationTime = MDD_realtimeSynchronize(rtSync, simTime, availableTime)
89
annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
910
Include = "#include \"MDDRealtimeSynchronize.h\" ",
10-
Library = "rt",
11+
Library = {"rt", "Winmm"},
1112
__iti_dll = "ITI_MDD.dll");
1213
annotation(__OpenModelica_Impure=true, __iti_Impure=true);
1314
end realtimeSynchronize;

Modelica_DeviceDrivers/OperatingSystem/setProcessPriority.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ input Integer priority "Simulation process priority (-2(lowest)..2(realtime))";
55
external "C" MDD_setPriority(procPrio, priority)
66
annotation(IncludeDirectory="modelica://Modelica_DeviceDrivers/Resources/Include",
77
Include = "#include \"MDDRealtimeSynchronize.h\" ",
8-
Library = "rt",
8+
Library = {"rt", "Winmm"},
99
__iti_dll = "ITI_MDD.dll");
1010
annotation(__OpenModelica_Impure=true, __iti_Impure=true);
1111
end setProcessPriority;

Modelica_DeviceDrivers/Resources/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,23 @@ set(CMAKE_EDIT_COMMAND cmake-gui)
1616
include_directories(src/include)
1717
include_directories(Include)
1818

19-
if (MSVC)
19+
if (MSVC OR MINGW)
2020
# Dummy Windows rt library for uniform treatment of GCC and MS Visual C within Modelica
2121
add_subdirectory(src/DummyRTLibrary)
2222
# Dummy Windows X11 library for uniform treatment of GCC and MS Visual C within Modelica
2323
add_subdirectory(src/DummyX11Library)
2424
# Dummy Windows pthread library for uniform treatment of GCC and MS Visual C within Modelica
2525
add_subdirectory(src/DummyPthreadLibrary)
26+
endif (MSVC OR MINGW)
27+
28+
if (MSVC)
2629
# Create a SimulationX specific DLL wrapper library
2730
add_subdirectory(src/ITI_ModelicaDeviceDrivers)
2831
endif (MSVC)
2932

3033
if (UNIX)
34+
# Dummy Linux Winmm library for uniform treatment of GCC and MS Visual C within Modelica
35+
add_subdirectory(src/DummyWinmmLibrary)
3136
# Are we trying to force compilation for linux32 on a native linux64 platform?
3237
if ( ($ENV{CFLAGS} MATCHES "-m32") AND ($ENV{CXXFLAGS} MATCHES "-m32") )
3338
set(M32_FLAG TRUE)
@@ -42,7 +47,7 @@ if (UNIX)
4247
endif (UNIX)
4348

4449
# Windows and linux library for 3Dconnexion space mouse support
45-
add_subdirectory(src/SpaceMouse)
50+
# add_subdirectory(src/SpaceMouse)
4651

4752
# Library providing some utility functions
4853
add_subdirectory(src/Util)

Modelica_DeviceDrivers/Resources/Include/MDDRealtimeSynchronize.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include <windows.h>
1818
#include "../src/include/CompatibilityDefs.h"
19-
#pragma comment( lib, "Winmm.lib" )
2019

2120
#if !defined(BELOW_NORMAL_PRIORITY_CLASS)
2221
#define BELOW_NORMAL_PRIORITY_CLASS 0x00004000

Modelica_DeviceDrivers/Resources/src/DummyPthreadLibrary/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ add_library(pthread SHARED ${libSrcsMDDDummyPthreadLibrary})
77

88
# install to directory (CMAKE_INSTALL_PREFIX) into subdirectory "lib"
99
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
10-
install(TARGETS X11 DESTINATION Library/win64)
10+
install(TARGETS pthread DESTINATION Library/win64)
1111
elseif ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
12-
install(TARGETS X11 DESTINATION Library/win32)
12+
install(TARGETS pthread DESTINATION Library/win32)
1313
else ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
1414
message(SEND_ERROR "Uups. Shouldn't be possible to get here")
1515
endif ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
message(STATUS "WRITING BUILD FILES FOR DummyWinmmLibrary")
2+
#message(STATUS "${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}")
3+
4+
set(libSrcsMDDDummyWinmmLibrary MDDDummyWinmmLibrary.c)
5+
6+
add_library(Winmm SHARED ${libSrcsMDDDummyWinmmLibrary})
7+
8+
# install to directory (CMAKE_INSTALL_PREFIX) into subdirectory "lib"
9+
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
10+
install(TARGETS rt DESTINATION Library/linux64)
11+
elseif ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
12+
install(TARGETS rt DESTINATION Library/linux32)
13+
else ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
14+
message(SEND_ERROR "Uups. Shouldn't be possible to get here")
15+
endif ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
16+
17+
18+
19+
20+
21+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/** Dummy library for uniform treatment of Modelica external function in windows and linux.
2+
*
3+
* @file
4+
* @author Bernhard Thiele
5+
* @since 2015-04-18
6+
* @copyright Modelica License 2
7+
* For windows, various functions need to link the Winmm.lib library.
8+
* However, Linux neither provides nor requires this library for the implemented functions.
9+
*
10+
* - <B>The problem</B>: We need to specify in Modelica to link the Winmm.lib library if running on Windows, but
11+
* it is not needed for Linux (and results in a linking error if specified in the
12+
* annotation).
13+
* - <B>The workaround</B>: We provide a dummy libWinmm.a library for Linux, so that linking won't result in an
14+
* error. This is not nice for several reasons and good suggestions how to solve that
15+
* differently are welcome.
16+
*/
17+
18+
static void MDD_dummy(void);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dummy library for Linux.

Modelica_DeviceDrivers/Resources/src/SpaceMouse/MDDSpaceMouse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,6 @@ int MDD_spaceMouseXEventsProcessing(void *p_mDDSpaceMouse) {
544544

545545
#else
546546

547-
#error "Modelica_DeviceDrivers: No Keyboard support for your platform"
547+
#error "Modelica_DeviceDrivers: No space mouse support for your platform"
548548

549549
#endif /* defined(_MSC_VER) */

0 commit comments

Comments
 (0)