From 826c2e086969ec607641647c5fe4137ec0d4fce4 Mon Sep 17 00:00:00 2001 From: Andreas <38031952+AnHeuermann@users.noreply.github.com> Date: Thu, 1 Feb 2024 17:46:05 +0100 Subject: [PATCH] MSYS2 change MINGW64 to UCRT64 (#10939) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [WIP] Use UCRT64 instead of MINGW64 * [WIP] Use UCRT64 instead of MINGW64 * [WIP] OMedit can simulate models with UCRT64 * Use MSYSTEM_PREFIX for MSYS environment - Updating submodules * Runtime dependencies for OMEdit - Install QT5 plugins - Install runtime dependencies (mainly qt) using CMake install * [WIP] Build OMEdit with UCRT64 and MINGW64 CMake I hope... * Fixing const char* * UCRT64 compiling with Makefiles.omdev.mingw * Fix Cmake check OMDEv on Linux * Compile OMSimulator with gcc only (on Windows) * revert MetaModelicaDev examples * Use System_openModelicaPlatform in OMEdit for msys * Fixing OMSI CMake command * Changing linking of libbfd for OMEdit * Improving cpp build, but it still failes * Fix om_curl for clang * Fixing cpp CMake bug * [WIP] remove TLM from build * Revert all metamodelica changes * Updating Readme for MINGW64 and UCRT64 * Adding missing environment variable * Revert change: Use C:\OMDev\tools\msys * Try finding gdb from OMEdit * Fixes for MINGW64 * Fixing MINGW64 C++ Makefile build * update the Windows MinGW build job to use UCRT64 * limit the msys2 execution on w3 computer that has Msys2/UTRC64 installed * quote cmd /c build*.bat as sh translates it to a c:\ * circumvent msys2 transforming /c to c:\ * $(where cmake) doesn't seem to work * set OMDEVMSYS in OMCompiler Makefile.omdev.mingw * add missing quote * echo some info on make variables * attempt to get rid of OMDEVMSYS * add the files missed in the previous commit * geez * resolve conflict with mater * use 996OMDEV windows path instead of C:\OMDev which is msys style * remember the original OMDEV and use it for MSVC * attempt to fix saving of original OMDEV * Revert "attempt to fix saving of original OMDEV" This reverts commit 80c7f54df4f7fb6e31a44dd0b3b92a3ce9b99ba5. * OMDEV_ESCAPED is not an environment variable. - The variable is set locally in the CMake file. Attempt to evaluate it as an environment variable will just return an empty value. * Tell boost we do not want to use its CMake config files. - If MSVC, we do not want to use MSYS/MingGW installed boost's CMake config files for locating Boost We have a manually provided boost already specified using BOOST_ROOT. - This is essentially saying we do not want any help from boost itself in finding its libraries and setup. Let CMake do it alone the old way by just finding the files it knows. - The reason this might be happening now is that we have a more recent boost installed in UCRT which knows and tries to help CMake in finding it. For MSVC we do not want that help because we do not want to use the installed boost. * IF MSVC use the Lapack from OMDev. Otherwise use from MinGW. - MSVC version of Lapack, just like Boost, is shipped by OMDev along separately (not from the MSYS/MinGW packages). Use that for MSVC. * Do not set BOOST_PATH_MSVC without checking VS version. - I am not sure how this all works together. It is not the easiest thing to follow. Too many duplications and redundancies. This might not fix the latest issue where we try to use a path where the value of $(OMDEV) variable has not been subsituted yet. It is probably because it was set as $$(OMDEV). In any case first try to cleanup things and see where it actually picks the value to use for BOOST_PATH_MSVC. * Run the getMSVCversion to set the BOOST_PATH_MSVC. - Make runtimeCPPmsvcinstall_old depend on getMSVCversion. We need the BOOST_PATH_MSVC variable set. Hopefully this works(?) * Fix handling of Boost and apack for OMSICpp too. * Define NPY_OS_MINGW for OMSens on Windows/MinGW. - There is a small bug in numpy's f2yc which does not detect MinGW environments as it is supposed to. See: https://github.com/numpy/numpy/issues/24761 - This Makefile is used for MinGW only. So we can just define the variable without any other checks being needed. * Test the CMake based build on ucrt labeled machines. - For this PR (until it is merged and everything has settled down) the one machine that has ucrt support is labled `omdev-ucrt`. Use only that machine to test the CMake built too. * ucrt's `libbfd` depends on libsframe and `libzstd`. - ucrt version of `libbfd` depends on `libsframe` and `libzstd` in addition to `libiberity`. Add those libraries to the linking. * Updating OMOptim, README * - change the MinGW to UCRT in Jenkinsfile and add new labels on github so we can handle them differently - fix OMSens issues and update OMOptim - get rid of OMDEV_MSYS as is not really needed and is good to keep it simple * update OMOptim sumbodule and remove OMDEV_MSYS everywhere * adapt to new ucrt labels and parameters * do not copy unnecessary files * remove msvc runtimes targets from all-runtimes * properly name stuff * Fixing CMake builds, adding OMSens - Adding CMakeLists to OMSens - Workaround in OMEdit CMake to run install multiple times - Removing TODOs * update OMSens * Adding more runtime dependencies * put back the OMPython stuff * partially adapt the python infrastructure * fix missing tab * add the missing dlls for OMEdit and omc * forgot to remove conflict markup * updáted OMSimulator * some minor updates * OMEdit fixes for msys2-ucrt64 - fix the crash reporting to properly activate the handler - add a "Crash Test" button to About dialog for easy crash testing --------- Co-authored-by: Adrian Pop Co-authored-by: Mahder Gebremedhin --- .CI/common.groovy | 26 +- ...NGW-OpenModelicaBuilder32bit.launch-sample | 50 ++-- ...NGW-OpenModelicaBuilder64bit.launch-sample | 4 +- CMakeLists.txt | 1 + Jenkinsfile | 28 +- Makefile.omdev.mingw | 256 +++++++----------- OMCompiler/CMakeLists.txt | 9 + OMCompiler/Compiler/CMakeLists.txt | 25 +- OMCompiler/Compiler/Main/Main.mo | 15 +- .../Compiler/Makefile.compiler_subdirs.common | 2 +- OMCompiler/Compiler/Makefile.omdev.mingw | 18 +- .../Compiler/SimCode/SimCodeFunctionUtil.mo | 2 +- OMCompiler/Compiler/Template/CodegenOMSIC.tpl | 2 +- .../Compiler/Util/Autoconf.mo.omdev.mingw | 11 +- OMCompiler/Compiler/boot/Makefile.omdev.mingw | 28 +- OMCompiler/Compiler/runtime/CMakeLists.txt | 6 + OMCompiler/Compiler/runtime/Makefile.common | 9 +- .../Compiler/runtime/Makefile.omdev.mingw | 44 ++- OMCompiler/Compiler/runtime/System_omc.c | 7 + OMCompiler/Compiler/runtime/om_curl.c | 98 +++++-- OMCompiler/Compiler/runtime/settingsimpl.h | 6 +- OMCompiler/Compiler/runtime/systemimpl.c | 8 +- OMCompiler/Compiler/scripts/Compile.bat | 4 +- OMCompiler/Compiler/scripts/Prompt.bat | 6 +- OMCompiler/INSTALL.mingw.crosscompile.sh | 12 - OMCompiler/Makefile.common | 6 +- OMCompiler/Makefile.in | 20 +- OMCompiler/Makefile.omdev.mingw | 184 ++++++------- OMCompiler/README.Windows.md | 117 +++++--- .../OMSI/Makefile.omdev.mingw | 24 +- .../OMSI/solver/CMakeLists.txt | 13 +- .../SimulationRuntime/OMSICpp/CMakeLists.txt | 90 +++--- .../OMSICpp/Makefile.omdev.mingw | 21 +- .../omcWrapper/omcZeroMQ/CMakeLists.txt | 26 +- .../OMSICpp/omsi/CMakeLists.txt | 48 ++-- .../runtime/src/Core/Modelica/CMakeLists.txt | 17 +- .../ParModelica/auto/Makefile.omdev.mingw | 6 + .../SimulationRuntime/c/Makefile.omdev.mingw | 12 +- .../SimulationRuntime/c/util/omc_file.c | 5 +- .../SimulationRuntime/cpp/CMakeLists.txt | 129 ++++----- .../cpp/Core/Modelica/CMakeLists.txt | 6 +- .../cpp/Makefile.omdev.mingw | 41 +-- .../cpp/Solver/ARKode/CMakeLists.txt | 4 +- .../cpp/Solver/Dgesv/CMakeLists.txt | 11 +- .../opc/da/Makefile.omdev.mingw | 10 +- OMCompiler/configure.ac | 4 +- OMCompiler/omc_config.h | 46 ++-- OMCompiler/omc_config.unix.h.in | 35 +++ OMEdit/Makefile.omdev.mingw | 9 +- OMEdit/OMEditGUI/CMakeLists.txt | 118 +++----- OMEdit/OMEditGUI/OMEditGUI.win.config.pri | 42 ++- OMEdit/OMEditGUI/main.cpp | 42 ++- OMEdit/OMEditLIB/MainWindow.cpp | 21 ++ OMEdit/OMEditLIB/MainWindow.h | 1 + OMEdit/OMEditLIB/OMEditLIB.pro | 7 +- .../Simulation/SimulationOutputWidget.cpp | 11 +- OMEdit/OMEditLIB/Util/Helper.cpp | 2 + OMEdit/OMEditLIB/Util/Helper.h | 1 + OMEdit/OMEditLIB/Util/Utilities.cpp | 29 +- .../OMNotebookGUI/Makefile.omdev.mingw | 2 +- OMNotebook/README.md | 3 +- OMPlot/README.md | 3 +- OMSens | 2 +- OMShell/README.md | 3 +- README.cmake.md | 21 +- cmake/modules/Findbinutils.cmake | 46 +++- common/config.guess | 4 +- omsimulator.cmake | 133 +++++++++ 68 files changed, 1144 insertions(+), 908 deletions(-) delete mode 100755 OMCompiler/INSTALL.mingw.crosscompile.sh create mode 100644 omsimulator.cmake diff --git a/.CI/common.groovy b/.CI/common.groovy index 49fc2e27042..372ca690557 100644 --- a/.CI/common.groovy +++ b/.CI/common.groovy @@ -91,7 +91,7 @@ void partest(partition=1,partitionmodulo=1,cache=true, extraArgs='') { echo fi ) > runTestWindows.sh - set MSYSTEM=MINGW64 + set MSYSTEM=UCRT64 set MSYS2_PATH_TYPE=inherit %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath '${WORKSPACE}'` && chmod +x runTestWindows.sh && ./runTestWindows.sh && rm -f ./runTestWindows.sh" """) @@ -240,7 +240,7 @@ void buildOMC(CC, CXX, extraFlags, Boolean buildCpp, Boolean clean) { echo rm -rf ./path\\ with\\ space/ ) > buildOMCWindows.sh - set MSYSTEM=MINGW64 + set MSYSTEM=UCRT64 set MSYS2_PATH_TYPE=inherit %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath '${WORKSPACE}'` && chmod +x buildOMCWindows.sh && ./buildOMCWindows.sh && rm -f ./buildOMCWindows.sh" """) @@ -300,7 +300,7 @@ void buildOMSens() { echo time make -f Makefile.omdev.mingw \${MAKETHREADS} omsens ) > buildOMSensWindows.sh - set MSYSTEM=MINGW64 + set MSYSTEM=UCRT64 set MSYS2_PATH_TYPE=inherit %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath '${WORKSPACE}'` && chmod +x buildOMSensWindows.sh && ./buildOMSensWindows.sh && rm -f ./buildOMSensWindows.sh" """) @@ -325,7 +325,7 @@ void buildOMC_CMake(cmake_args, cmake_exe='cmake') { echo time ${cmake_exe} --build ./build_cmake --parallel ${numPhysicalCPU()} --target install ) > buildOMCWindows.sh - set MSYSTEM=MINGW64 + set MSYSTEM=UCRT64 set MSYS2_PATH_TYPE=inherit %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath '${WORKSPACE}'` && chmod +x buildOMCWindows.sh && ./buildOMCWindows.sh && rm -f ./buildOMCWindows.sh" """) @@ -357,7 +357,7 @@ void buildGUI(stash, isQt5) { echo ./build/bin/OMEdit --help ) > buildGUIWindows.sh - set MSYSTEM=MINGW64 + set MSYSTEM=UCRT64 set MSYS2_PATH_TYPE=inherit %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath '${WORKSPACE}'` && chmod +x buildGUIWindows.sh && ./buildGUIWindows.sh && rm -f ./buildGUIWindows.sh" """) @@ -402,7 +402,7 @@ void buildAndRunOMEditTestsuite(stash) { echo ./RunOMEditTestsuite.sh ) > buildOMEditTestsuiteWindows.sh - set MSYSTEM=MINGW64 + set MSYSTEM=UCRT64 set MSYS2_PATH_TYPE=inherit %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "cd `cygpath '${WORKSPACE}'` && chmod +x buildOMEditTestsuiteWindows.sh && ./buildOMEditTestsuiteWindows.sh && rm -f ./buildOMEditTestsuiteWindows.sh" """) @@ -445,7 +445,7 @@ void generateTemplates() { def getVersion() { if (isWindows()) { - return (bat (script: 'set OMDEV=C:\\OMDev && set MSYSTEM=MINGW64 && set MSYS2_PATH_TYPE=inherit && %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "build/bin/omc --version | grep -o \"v[0-9]\\+[.][0-9]\\+[.][0-9]\\+[^ ]*\""', returnStdout: true)).replaceAll("\\s","") + return (bat (script: 'set OMDEV=C:\\OMDev && set MSYSTEM=UCRT64 && set MSYS2_PATH_TYPE=inherit && %OMDEV%\\tools\\msys\\usr\\bin\\sh --login -i -c "build/bin/omc --version | grep -o \"v[0-9]\\+[.][0-9]\\+[.][0-9]\\+[^ ]*\""', returnStdout: true)).replaceAll("\\s","") } else { return (sh (script: 'build/bin/omc --version | grep -o "v[0-9]\\+[.][0-9]\\+[.][0-9]\\+[^ ]*"', returnStdout: true)).replaceAll("\\s","") } @@ -492,13 +492,13 @@ def makeCommand() { return env.GMAKE ?: "make" } -def shouldWeBuildMINGW() { +def shouldWeBuildUCRT() { if (isPR()) { - if (pullRequest.labels.contains("CI/Build MINGW")) { + if (pullRequest.labels.contains("CI/Build MSYS2-UCRT64")) { return true } } - return params.BUILD_MINGW + return params.BUILD_MSYS2_UCRT64 } def shouldWeDisableAllCMakeBuilds() { @@ -510,13 +510,13 @@ def shouldWeDisableAllCMakeBuilds() { return params.DISABLE_ALL_CMAKE_BUILDS } -def shouldWeEnableMinGWCMakeBuild() { +def shouldWeEnableUCRTCMakeBuild() { if (isPR()) { - if (pullRequest.labels.contains("CI/CMake/Enable/MinGW")) { + if (pullRequest.labels.contains("CI/CMake/Enable/MSYS2-UCRT64")) { return true } } - return params.ENABLE_MINGW_CMAKE_BUILD + return params.ENABLE_MSYS2_UCRT64_CMAKE_BUILD } def shouldWeEnableMacOSCMakeBuild() { diff --git a/.externalToolBuilders/OMDev-MINGW-OpenModelicaBuilder32bit.launch-sample b/.externalToolBuilders/OMDev-MINGW-OpenModelicaBuilder32bit.launch-sample index ea2b036e392..d5aca5c65f3 100644 --- a/.externalToolBuilders/OMDev-MINGW-OpenModelicaBuilder32bit.launch-sample +++ b/.externalToolBuilders/OMDev-MINGW-OpenModelicaBuilder32bit.launch-sample @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.externalToolBuilders/OMDev-MINGW-OpenModelicaBuilder64bit.launch-sample b/.externalToolBuilders/OMDev-MINGW-OpenModelicaBuilder64bit.launch-sample index d267043e45d..58a6010af30 100644 --- a/.externalToolBuilders/OMDev-MINGW-OpenModelicaBuilder64bit.launch-sample +++ b/.externalToolBuilders/OMDev-MINGW-OpenModelicaBuilder64bit.launch-sample @@ -5,11 +5,11 @@ - + - + diff --git a/CMakeLists.txt b/CMakeLists.txt index 638d58cace7..10ccc8843c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,7 @@ if(OM_ENABLE_GUI_CLIENTS) omc_add_subdirectory(OMSens_Qt) endif() +omc_add_subdirectory(OMSens) omc_add_subdirectory(libraries) omc_add_subdirectory(testsuite) diff --git a/Jenkinsfile b/Jenkinsfile index 5f7bd469043..c9d5a7506d5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,8 @@ def common -def shouldWeBuildMINGW +def shouldWeBuildUCRT def shouldWeDisableAllCMakeBuilds_value def shouldWeEnableMacOSCMakeBuild_value -def shouldWeEnableMinGWCMakeBuild_value +def shouldWeEnableUCRTCMakeBuild_value def shouldWeRunTests def isPR pipeline { @@ -15,10 +15,10 @@ pipeline { LC_ALL = 'C.UTF-8' } parameters { - booleanParam(name: 'BUILD_MINGW', defaultValue: false, description: 'Build with Win/MinGW') + booleanParam(name: 'BUILD_MSYS2_UCRT64', defaultValue: false, description: 'Build with Win/MSYS2-UCRT64') booleanParam(name: 'DISABLE_ALL_CMAKE_BUILDS', defaultValue: false, description: 'Skip building omc with CMake (CMake 3.17.2) on all platforms') - booleanParam(name: 'ENABLE_MINGW_CMAKE_BUILD', defaultValue: false, description: 'Enable building omc with CMake on MinGW') - booleanParam(name: 'ENABLE_MACOS_CMAKE_BUILD', defaultValue: false, description: 'Enable building omc with CMake on macOS') + booleanParam(name: 'ENABLE_MSYS2_UCRT64_CMAKE_BUILD', defaultValue: false, description: 'Enable building omc with CMake on MSYS2-UCRT64') + booleanParam(name: 'ENABLE_MACOS_CMAKE_BUILD', defaultValue: false, description: 'Enable building omc with CMake on MacOS') } // stages are ordered according to execution time; highest time first // nodes are selected based on a priority (in Jenkins config) @@ -37,14 +37,14 @@ pipeline { common = load("${env.workspace}/.CI/common.groovy") isPR = common.isPR() print "isPR: ${isPR}" - shouldWeBuildMINGW = common.shouldWeBuildMINGW() - print "shouldWeBuildMINGW: ${shouldWeBuildMINGW}" + shouldWeBuildUCRT = common.shouldWeBuildUCRT() + print "shouldWeBuildUCRT: ${shouldWeBuildUCRT}" shouldWeDisableAllCMakeBuilds_value = common.shouldWeDisableAllCMakeBuilds() print "shouldWeDisableAllCMakeBuilds: ${shouldWeDisableAllCMakeBuilds_value}" shouldWeEnableMacOSCMakeBuild_value = common.shouldWeEnableMacOSCMakeBuild() print "shouldWeEnableMacOSCMakeBuild: ${shouldWeEnableMacOSCMakeBuild_value}" - shouldWeEnableMinGWCMakeBuild_value = common.shouldWeEnableMinGWCMakeBuild() - print "shouldWeEnableMinGWCMakeBuild: ${shouldWeEnableMinGWCMakeBuild_value}" + shouldWeEnableUCRTCMakeBuild_value = common.shouldWeEnableUCRTCMakeBuild() + print "shouldWeEnableUCRTCMakeBuild: ${shouldWeEnableUCRTCMakeBuild_value}" shouldWeRunTests = common.shouldWeRunTests() print "shouldWeRunTests: ${shouldWeRunTests}" } @@ -90,15 +90,15 @@ pipeline { stash name: 'omc-clang', includes: 'build/**, **/config.status' } } - stage('Win/MinGW') { + stage('Win/UCRT64') { agent { node { - label 'windows' + label 'omdev-ucrt64' } } when { beforeAgent true - expression { shouldWeBuildMINGW } + expression { shouldWeBuildUCRT } } environment { RUNTESTDB = '/c/dev/' @@ -176,12 +176,12 @@ pipeline { stage('cmake-OMDev-gcc') { agent { node { - label 'windows' + label 'omdev-ucrt64' } } when { beforeAgent true - expression { !shouldWeDisableAllCMakeBuilds_value && shouldWeEnableMinGWCMakeBuild_value} + expression { !shouldWeDisableAllCMakeBuilds_value && shouldWeEnableUCRTCMakeBuild_value} } steps { script { diff --git a/Makefile.omdev.mingw b/Makefile.omdev.mingw index 761dca8cd1a..00016a03030 100644 --- a/Makefile.omdev.mingw +++ b/Makefile.omdev.mingw @@ -22,9 +22,18 @@ defaultMakefileTarget = Makefile.omdev.mingw REALPATH = $(realpath .) OMBUILDDIR=$(REALPATH)/build -OMDEVMSYS=$(shell cygpath $$OMDEV) +ifndef OMDEV +$(error Environment variable OMDEV not set!) +endif +ifndef MSYSTEM_PREFIX +$(error Environment variable MSYSTEM_PREFIX not set. Is this a msys2 shell?) +endif +OMDEV = $(shell cygpath $$OMDEV) +OMDEV_MSYS = $(shell cygpath $$OMDEV/tools/msys) +MSYSTEM_PREFIX = $(shell cygpath $$MSYSTEM_PREFIX) +OM_MSYS_ENV_DIR = $(MSYSTEM_PREFIX) -CMAKE = $(OMDEVMSYS)/bin/cmake/bin/cmake +CMAKE = cmake CMAKE_TARGET = "MSYS Makefiles" builddir_build=$(OMBUILDDIR) @@ -32,27 +41,13 @@ builddir_bin=$(OMBUILDDIR)/bin builddir_lib=$(OMBUILDDIR)/lib/omc builddir_inc=$(OMBUILDDIR)/include/omc -PKG_CONFIG_BIN = $(OMDEVMSYS)/lib/gtk+-2.24.10/bin -ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) -DBUS_INCLUDE_DIR = $(OMDEVMSYS)/tools/msys/mingw32/include/dbus-1.0/ -DBUS_INCLUDE_LIB_DIR = $(OMDEVMSYS)/tools/msys/mingw32/lib/dbus-1.0/include/ -DBUS_PATH = $(OMDEVMSYS)/tools/msys/mingw32/bin/ -BOOST_PATH_MSVC = $(OMDEVMSYS)/lib/3rdParty/boost-1_55/ -OSG_PATH = $(OMDEVMSYS)/tools/msys/mingw32/ -PKG_CONFIG_PATH=$(OMDEVMSYS)/tools/msys/mingw32/lib/pkgconfig -else # mingw64 -DBUS_INCLUDE_DIR = $(OMDEVMSYS)/tools/msys/mingw64/include/dbus-1.0/ -DBUS_INCLUDE_LIB_DIR = $(OMDEVMSYS)/tools/msys/mingw64/lib/dbus-1.0/include/ -DBUS_PATH = $(OMDEVMSYS)/tools/msys/mingw64/bin/ -BOOST_PATH = $(OMDEVMSYS)/tools/msys/mingw64/include -OSG_PATH = $(OMDEVMSYS)/tools/msys/mingw64/ -PKG_CONFIG_PATH=$(OMDEVMSYS)/tools/msys/mingw64/lib/pkgconfig -endif +PKG_CONFIG_PATH=$(OM_MSYS_ENV_DIR)/lib/pkgconfig + ifeq ($(BUILDTYPE),) -BUILDTYPE=$(BuildType) + BUILDTYPE=$(BuildType) endif ifeq ($(BUILDTYPE),) -BUILDTYPE=Debug + BUILDTYPE=Debug endif @@ -62,6 +57,9 @@ all: omc testsuite-depends omc: echo "Selected compiler: CC=$(CC), CXX=$(CXX)" + echo "Using OMDev from: $(OMDEV)" + echo "Using Msys from: $(OMDEV_MSYS)" + echo "MSYS2 MSYSTEM_PREFIX: $(MSYSTEM_PREFIX)" $(MAKE) -f $(defaultMakefileTarget) -C OMCompiler OMBUILDDIR=$(OMBUILDDIR) OM_ENABLE_ENCRYPTION=$(OM_ENABLE_ENCRYPTION) CC="$(CC)" CXX="$(CXX)" omc-diff: @@ -110,6 +108,7 @@ omsimulator: cp -vpPR OMSimulator/install/share/OMSimulator/ $(OMBUILDDIR)/share cp -vpPR OMSimulator/install/lib/* $(OMBUILDDIR)/lib/omc/ + omnotebook: omc omplot qtclientsDLLs $(MAKE) -f $(defaultMakefileTarget) -C OMNotebook/OMNotebook/OMNotebookGUI OMBUILDDIR=$(OMBUILDDIR) CC="$(CC)" CXX="$(CXX)" @@ -133,107 +132,65 @@ qtclients: omplot omedit omnotebook omshell omoptim omsens_qt qtclientsDLLs: echo Copying needed .dlls mkdir -p $(builddir_bin)/ -ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libgcc_s*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libintl-8.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libiconv-2.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Core.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Gui.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Network.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Svg.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5WebKit.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5WebKitWidgets.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Xml.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5XmlPatterns.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Widgets.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5PrintSupport.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Multimedia.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5MultimediaWidgets.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Positioning.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Qml.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Quick.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Sensors.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5WebChannel.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5Sql.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/Qt5OpenGL.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libxslt-1.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/liblzma-5.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libxml2-2.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libwebp-*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libsqlite3-0.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/zlib1.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libszip*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libhdf5-0.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libpng16-16.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libjpeg-8.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libfreetype-6.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libglib-2.0-0.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libbz2-1.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libicuin*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libicuuc*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libicudt*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libpcre*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libharfbuzz-0.dll $(builddir_bin)/ - cp -pufr $(OMDEVMSYS)/tools/msys/mingw32/share/qt5/plugins/* $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libOpenThreads.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libosg.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libosgViewer.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libosgDB.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libosgUtil.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libosgGA.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libosgText.dll $(builddir_bin)/ - for f in $(QT_EXTRA_DLLS); do cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/$$f $(builddir_bin)/; done -else # mingw64 - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libgcc_s*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libintl-8.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libiconv-2.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Core.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Gui.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Network.dll $(builddir_bin) - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Svg.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5WebKit.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5WebKitWidgets.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Xml.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5XmlPatterns.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Widgets.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5PrintSupport.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Multimedia.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5MultimediaWidgets.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Positioning.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Qml.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Quick.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Sensors.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5WebChannel.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5Sql.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/Qt5OpenGL.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libxslt-1.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/liblzma-5.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libxml2-2.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libwebp-*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libsqlite3-0.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/zlib1.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libszip*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libhdf5-0.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libpng16-16.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libjpeg-8.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libfreetype-6.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libglib-2.0-0.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libbz2-1.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libicuin*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libicuuc*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libicudt*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libpcre*.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libharfbuzz-0.dll $(builddir_bin)/ - cp -pufr $(OMDEVMSYS)/tools/msys/mingw64/share/qt5/plugins/* $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libOpenThreads.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libosg.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libosgViewer.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libosgDB.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libosgUtil.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libosgGA.dll $(builddir_bin)/ - cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libosgText.dll $(builddir_bin)/ - for f in $(QT_EXTRA_DLLS); do cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/$$f $(builddir_bin)/; done -endif + + cp -puf $(OM_MSYS_ENV_DIR)/bin/libgcc_s*.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libintl-8.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libiconv-2.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Core.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Gui.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Network.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Svg.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5WebKit.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5WebKitWidgets.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Xml.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5XmlPatterns.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Widgets.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5PrintSupport.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Multimedia.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5MultimediaWidgets.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Positioning.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Qml.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Quick.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Sensors.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5WebChannel.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5Sql.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/Qt5OpenGL.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libxslt-1.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/liblzma-5.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libxml2-2.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libwebp-*.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libsqlite3-0.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/zlib1.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libsz*.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libhdf5-*.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libpng16-16.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libjpeg-8.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libfreetype-6.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libglib-2.0-0.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libbz2-1.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libicuin*.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libicuuc*.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libicudt*.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libpcre*.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libharfbuzz-0.dll $(builddir_bin)/ + cp -pufr $(OM_MSYS_ENV_DIR)/share/qt5/plugins/* $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libOpenThreads.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libosg.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libosgViewer.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libosgDB.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libosgUtil.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libosgGA.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libosgText.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libmd4c.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libsharpyuv-0.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libcurl-4.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libcrypto-3-x64.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libidn2-0.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libunistring-5.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libpsl-5.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libssh2-1.dll $(builddir_bin)/ + cp -puf $(OM_MSYS_ENV_DIR)/bin/libssl-3-x64.dll $(builddir_bin)/ + for f in $(QT_EXTRA_DLLS); do cp -puf $(OM_MSYS_ENV_DIR)/bin/$$f $(builddir_bin)/; done clean-qtclients: rm -f $(OMBUILDDIR)/bin/OMPlot.exe $(OMBUILDDIR)/bin/OMEdit.exe $(OMBUILDDIR)/bin/OMNotebook.exe $(OMBUILDDIR)/bin/OMShell.exe $(OMBUILDDIR)/bin/OMOptim.exe @@ -259,8 +216,6 @@ OMSICPPinstall: all-runtimes: $(MAKE) -C OMCompiler -f $(defaultMakefileTarget) OMBUILDDIR=$(OMBUILDDIR) BUILDTYPE=$(BUILDTYPE) runtimeCPPinstall - $(MAKE) -C OMCompiler -f $(defaultMakefileTarget) OMBUILDDIR=$(OMBUILDDIR) BUILDTYPE=$(BUILDTYPE) runtimeCPPmsvcinstall - $(MAKE) -C OMCompiler -f $(defaultMakefileTarget) OMBUILDDIR=$(OMBUILDDIR) BUILDTYPE=$(BUILDTYPE) simulationruntimecmsvc testlogwindows: $(MAKE) -C testsuite -f Makefile ReferenceFiles > testsuite/testsuite-trace.txt @@ -278,54 +233,35 @@ testlogwindows: builddir_lib=$(OMBUILDDIR)/lib builddir_share=$(OMBUILDDIR)/share -ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) -IDLPYTHON = $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/bin/x86_win32/omniidl -bpython -Wbglobal=_OMCIDL -Wbpackage=OMPythonIDL -else # mingw64 -IDLPYTHON = $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/bin/x86_win32/omniidl -bpython -Wbglobal=_OMCIDL -Wbpackage=OMPythonIDL -endif +IDLPYTHON = $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/bin/x86_win32/omniidl -bpython -Wbglobal=_OMCIDL -Wbpackage=OMPythonIDL IDLPYTHONTARGET = $(builddir_share)/omc/scripts/PythonInterface/OMPythonIDL/omc_communication_idl.py IDLFILE=OMCompiler/Compiler/runtime/omc_communication.idl -install-python: $(IDLPYTHONTARGET) +install-python: script-files-python # $(IDLPYTHONTARGET) .PHONY: script-files-python script-files-python: mkbuilddirs-python # copy library files neeeded by OMPython -ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/bin/x86_win32/omniORB420_vc10_rt.dll $(builddir_lib)/python) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/bin/x86_win32/omnithread40_vc10_rt.dll $(builddir_lib)/python) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/x86_win32/_omnipy.pyd $(builddir_lib)/python) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/__init__.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/boxes_idl.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/CORBA.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/corbaidl_idl.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/minorCodes.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/PortableServer.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/tcInternal.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/omniPolicy.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/pollable_idl.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win32/lib/python/omniORB/messaging_idl.py $(builddir_lib)/python/omniORB/) -else # mingw64 - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/bin/x86_win32/omniORB420_vc10_rt.dll $(builddir_lib)/python) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/bin/x86_win32/omnithread40_vc10_rt.dll $(builddir_lib)/python) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/x86_win32/_omnipy.pyd $(builddir_lib)/python) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/__init__.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/boxes_idl.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/CORBA.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/corbaidl_idl.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/minorCodes.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/PortableServer.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/tcInternal.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/omniPolicy.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/pollable_idl.py $(builddir_lib)/python/omniORB/) - (cp -puf $(OMDEVMSYS)/lib/omniORBpy-4.2.0-win64/lib/python/omniORB/messaging_idl.py $(builddir_lib)/python/omniORB/) -endif + (cp -puf $(OMDEV)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/omni*_rt.dll $(builddir_lib)/python) + (cp -puf $(OMDEV)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/COS*_rt.dll $(builddir_lib)/python) + (cp -puf $(OMDEV)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/lib*.dll $(builddir_lib)/python) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/x86_win32/_omnipy.pyd $(builddir_lib)/python) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/__init__.py $(builddir_lib)/python/omniORB/) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/boxes_idl.py $(builddir_lib)/python/omniORB/) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/CORBA.py $(builddir_lib)/python/omniORB/) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/corbaidl_idl.py $(builddir_lib)/python/omniORB/) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/minorCodes.py $(builddir_lib)/python/omniORB/) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/PortableServer.py $(builddir_lib)/python/omniORB/) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/tcInternal.py $(builddir_lib)/python/omniORB/) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/omniPolicy.py $(builddir_lib)/python/omniORB/) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/pollable_idl.py $(builddir_lib)/python/omniORB/) + #(cp -puf $(OMDEV)/lib/omniORBpy-4.2.0-mingw64/lib/python/omniORB/messaging_idl.py $(builddir_lib)/python/omniORB/) # copy OMPython files cp -rfp OMPython/setup.py $(builddir_share)/omc/scripts/PythonInterface cp -rfp OMPython/OMPython/* $(builddir_share)/omc/scripts/PythonInterface/OMPython -$(IDLPYTHONTARGET) : $(IDLFILE) script-files-python +$(IDLPYTHONTARGET) : $(IDLFILE) $(IDLPYTHON) -C$(builddir_share)/omc/scripts/PythonInterface $(IDLFILE) mkbuilddirs-python: @@ -342,4 +278,4 @@ clean: gitclean: git submodule foreach --recursive 'git clean -fdx -e /git -e /svn' - git clean -fdx -e OpenModelicaSetup -e OMSetup -e OMEncryption -e .project -e *.launch -e .vscode \ No newline at end of file + git clean -fdx -e OpenModelicaSetup -e OMSetup -e OMEncryption -e .project -e *.launch -e .vscode/ diff --git a/OMCompiler/CMakeLists.txt b/OMCompiler/CMakeLists.txt index 558c21cc388..1cf83fd8c4a 100644 --- a/OMCompiler/CMakeLists.txt +++ b/OMCompiler/CMakeLists.txt @@ -42,6 +42,15 @@ string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") ## by linking to this library you get the include directories. add_library(omc_config INTERFACE) add_library(omc::config ALIAS omc_config) +if(WIN32) + if(DEFINED ENV{MSYSTEM_PREFIX}) + string(FIND $ENV{MSYSTEM_PREFIX} "ucrt64" IS_UCRT64) + if(IS_UCRT64) + target_compile_definitions(omc_config INTERFACE UCRT64) + message(STATUS "omc_config.h: CONFIG_OPENMODELICA_SPEC_PLATFORM=ucrt64") + endif() + endif() +endif() target_include_directories(omc_config INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/OMCompiler/Compiler/CMakeLists.txt b/OMCompiler/Compiler/CMakeLists.txt index 87ed6ff3063..fb4963c4ded 100644 --- a/OMCompiler/Compiler/CMakeLists.txt +++ b/OMCompiler/Compiler/CMakeLists.txt @@ -288,8 +288,29 @@ endif() # Install omc to the directory for RUNTIME (default=bin) # They are part of "compiler" installation component. This means that you can # install just the files in this component by specifying its name. -install(TARGETS omc OpenModelicaCompiler - COMPONENT omc) +if(WIN32) + # Escape the environment variable path + if(NOT DEFINED ENV{MSYSTEM_PREFIX}) + message(FATAL_ERROR "Environment variable \"MSYSTEM_PREFIX\" is not set.") + endif() + string(REPLACE "\\" "/" MSYSTEM_PREFIX_ESCAPED "$ENV{MSYSTEM_PREFIX}") + + set(OMCOMPILER_LIB_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}OMCompiler/Compiler/bin) + set(SIMULATION_RUNTIME_LIB_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}OMCompiler/SimulationRuntime/c) + set(GC_RUNTIME_LIB_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}OMCompiler/3rdParty/gc) + set(RUNTIME_LIB_DIRS ${OMPLOT_LIB_DIR} ${OMSIMULATOR_LIB_DIR} ${OMCOMPILER_LIB_DIR} ${SIMULATION_RUNTIME_LIB_DIR} ${GC_RUNTIME_LIB_DIR}) + + install(TARGETS OpenModelicaCompiler + RUNTIME_DEPENDENCIES + DIRECTORIES ${MSYSTEM_PREFIX_ESCAPED}/bin ${RUNTIME_LIB_DIRS} + PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" + POST_EXCLUDE_REGEXES ".*system32/.*\\.dll") + install(TARGETS omc + COMPONENT omc) +else(WIN32) + install(TARGETS omc OpenModelicaCompiler + COMPONENT omc) +endif(WIN32) # Install the *ModelicaBuiltin files to /omc/ that is where omc.exe expects them to be. # They are also part of "compiler" installation component. diff --git a/OMCompiler/Compiler/Main/Main.mo b/OMCompiler/Compiler/Main/Main.mo index 6eb7e816b60..ed6edcb9854 100644 --- a/OMCompiler/Compiler/Main/Main.mo +++ b/OMCompiler/Compiler/Main/Main.mo @@ -612,15 +612,15 @@ end readSettingsFile; public function setWindowsPaths "@author: adrpo - set the windows paths for MinGW. - do some checks on where needed things are present. + Set the windows paths for MSYS. + Do some checks on where needed things are present. BIG WARNING: if MinGW gcc version from OMDev or OpenModelica/MinGW changes you will need to change here!" input String inOMHome; algorithm _ := match(inOMHome) local - String oldPath, newPath, omHome, omdevPath, mingwDir, binDir, libBinDir, msysBinDir; + String oldPath, newPath, omHome, omdevPath, msysPath, mingwDir, binDir, libBinDir, msysBinDir; Boolean hasBinDir, hasLibBinDir; // check if we have OMDEV set @@ -628,16 +628,17 @@ algorithm equation System.setEnv("OPENMODELICAHOME",omHome,true); omdevPath = Util.makeValueOrDefault(System.readEnv,"OMDEV",""); - mingwDir = System.openModelicaPlatform(); // if we don't have something in OMDEV use OMHOME if stringEq(omdevPath, "") then omdevPath = omHome; end if; - msysBinDir = omdevPath + "\\tools\\msys\\usr\\bin"; - binDir = omdevPath + "\\tools\\msys\\" + mingwDir + "\\bin"; + msysPath = omdevPath + "\\tools\\msys"; + mingwDir = System.openModelicaPlatform(); + msysBinDir = msysPath + "\\usr\\bin"; + binDir = msysPath + "\\" + mingwDir + "\\bin"; // if compiler is gcc if System.getCCompiler() == "gcc" then - libBinDir = omdevPath + "\\tools\\msys\\" + mingwDir + "\\lib\\gcc\\" + System.gccDumpMachine() + "\\" + System.gccVersion(); + libBinDir = msysPath + "\\" + mingwDir + "\\lib\\gcc\\" + System.gccDumpMachine() + "\\" + System.gccVersion(); else // if is clang libBinDir = binDir; end if; diff --git a/OMCompiler/Compiler/Makefile.compiler_subdirs.common b/OMCompiler/Compiler/Makefile.compiler_subdirs.common index 26b5c775b02..92dcf81c740 100644 --- a/OMCompiler/Compiler/Makefile.compiler_subdirs.common +++ b/OMCompiler/Compiler/Makefile.compiler_subdirs.common @@ -1,6 +1,6 @@ # # A common Makefile for subdirectories (runtime and parser) -# Should be used for both OMDev and Linux +# Should be used for both Windows and Linux # include $(srcdir)/Makefile.common diff --git a/OMCompiler/Compiler/Makefile.omdev.mingw b/OMCompiler/Compiler/Makefile.omdev.mingw index 1954aca6194..f974cdf95d0 100644 --- a/OMCompiler/Compiler/Makefile.omdev.mingw +++ b/OMCompiler/Compiler/Makefile.omdev.mingw @@ -1,19 +1,9 @@ -# Adrian Pop, adrpo@ida.liu.se, 2006-02-01 -# Makefile for compilation of OMC using OMDev-mingw -# OMDev-mingw: http://www.ida.liu.se/~adrpo/omc/omdev/ -# -# $Id: Makefile.omdev.mingw.in 1817 2006-02-01 12:21:26Z adrpo $ -# - -# The path to the OMDev-mingw package MUST BE SET! -#OMDEV=$OMDEV -# Test if the needed variables are there... +# Makefile for compilation of OMC using MSYS UCRT .testvariables: ifndef OMDEV @echo You have to set the OMDEV variabile pointing to your OMDev package root! Exiting.... - @echo Take the OMDev package from: http://www.ida.liu.se/~adrpo/omc/omdev/ - @echo For questions or problems email Adrian Pop, adrpo@ida.liu.se + @echo See OpenModelica/OMCompiler/README.Windows.md ABORT endif @@ -25,10 +15,6 @@ builddir_lib=$(OMBUILDDIR)/lib/omc LIBSOCKET = -lwsock32 SHELL = /bin/sh -override CFLAGS += $(USE_CORBA) - -USE_CORBA = -DUSE_CORBA -CORBAHOME = $(OMDEV) SCRIPT_FILES = Compile.bat Prompt.bat openmodelica.lefty default_profiling.xsl replace-startValue.* simcodedump.xsl ngspicetoModelica.py diff --git a/OMCompiler/Compiler/SimCode/SimCodeFunctionUtil.mo b/OMCompiler/Compiler/SimCode/SimCodeFunctionUtil.mo index 91c7060fcb5..4d90214052b 100644 --- a/OMCompiler/Compiler/SimCode/SimCodeFunctionUtil.mo +++ b/OMCompiler/Compiler/SimCode/SimCodeFunctionUtil.mo @@ -2195,7 +2195,7 @@ algorithm if "Windows_NT" == Autoconf.os then // omcruntime on windows needs linking with mico2313 and wsock and then some :) str = "-l" + str; - strs = str :: "-lintl" :: "-liconv" :: "-lexpat" :: "-lsqlite3" :: "-ltre" :: "-lomniORB420_rt" :: "-lomnithread40_rt" :: "-lws2_32" :: "-lRpcrt4" :: "-lregex" :: {}; + strs = str :: "-lintl" :: "-liconv" :: "-lexpat" :: "-lsqlite3" :: "-ltre" :: "-lws2_32" :: "-lRpcrt4" :: "-lregex" :: {}; else strs = Autoconf.systemLibs; end if; diff --git a/OMCompiler/Compiler/Template/CodegenOMSIC.tpl b/OMCompiler/Compiler/Template/CodegenOMSIC.tpl index ff1e8cedd97..ebc650d81a9 100644 --- a/OMCompiler/Compiler/Template/CodegenOMSIC.tpl +++ b/OMCompiler/Compiler/Template/CodegenOMSIC.tpl @@ -143,7 +143,7 @@ template createMakefile(SimCode simCode, String target, String makeflieName) let includedir = '<%fileNamePrefix%>.fmutmp/sources/include/' let mkdir = match makefileParams.platform case "win32" case "win64" then '"mkdir.exe"' else 'mkdir' let OMLibs = match makefileParams.platform case "win32" case "win64" then 'lib' case "linux64" then 'lib/x86_64-linux-gnu' else 'lib' - let lapackDirWin = match makefileParams.platform case "win32" then '$(OMDEV)/tools/msys/mingw32/bin' case "win64" then '$(OMDEV)/tools/msys/mingw64/bin' else '' + let lapackDirWin = match makefileParams.platform case "win64" then '$(MSYSTEM_PREFIX)/bin' else '' let libEnding = match makefileParams.platform case "win32" case "win64" then 'dll' else 'so' let rpath = match makefileParams.platform case "win32" case "win64" then '' else "\"-Wl,-rpath,\$$ORIGIN/.\"" let star = match makefileParams.platform case "win32" case "win64" then '' else '*' diff --git a/OMCompiler/Compiler/Util/Autoconf.mo.omdev.mingw b/OMCompiler/Compiler/Util/Autoconf.mo.omdev.mingw index 2ac9396e3bd..0f7df157620 100644 --- a/OMCompiler/Compiler/Util/Autoconf.mo.omdev.mingw +++ b/OMCompiler/Compiler/Util/Autoconf.mo.omdev.mingw @@ -2,6 +2,7 @@ encapsulated package Autoconf constant Boolean is64Bit = @ISMINGW64@; constant Boolean isNewOMDev = @IS_NEW_OMDEV@; + constant Boolean isNewNewOMDev = @IS_NEW_NEW_OMDEV@; constant String bstatic = "-Wl,-Bstatic"; constant String bdynamic = "-Wl,-Bdynamic"; @@ -27,17 +28,21 @@ encapsulated package Autoconf constant String ldflags_runtime = " -lOpenModelicaRuntimeC" + ldflags_basic; constant String ldflags_runtime_sim = "-lSimulationRuntimeC -Wl,-Bdynamic -lomcgc -lryu -lopenblas" + linkType + " -lstdc++ -Wl,-Bdynamic "; - constant String ldflags_runtime_fmu = linkType + "-lregex -lryu -ltre -lintl -liconv -static-libgcc -lpthread -lm " + + // Same for szip instead of sz. + constant String ldflags_zip = if isNewNewOMDev then "-lz -lsz " else "-lzip -lszip "; + constant String ldflags_runtime_fmu = linkType + "-lregex -ltre -lintl -liconv -static-libgcc -lpthread -lm " + libFortran + "-lgfortran -lquadmath -lmingw32 -lgcc_eh -lmoldname -lmingwex " + - libMsvcrt + "-luser32 -lkernel32 -ladvapi32 -lshell32 -limagehlp -lopenblas -lhdf5 -lz -lszip -Wl,-Bdynamic"; + libMsvcrt + "-luser32 -lkernel32 -ladvapi32 -lshell32 -limagehlp -lopenblas -lhdf5 " + + ldflags_zip + + "-Wl,-Bdynamic"; constant String ldflags_runtime_fmu_static = " -lSimulationRuntimeFMI " + ldflags_runtime_fmu; constant String platform = if is64Bit then "WIN64" else "WIN32"; constant String pathDelimiter = "/"; constant String groupDelimiter = ";"; - constant String corbaLibs = "-L$(OPENMODELICAHOME)/lib/omc -lomniORB420_rt -lomnithread40_rt"; + constant String corbaLibs = ""; constant list systemLibs = {}; constant String triple = ""; diff --git a/OMCompiler/Compiler/boot/Makefile.omdev.mingw b/OMCompiler/Compiler/boot/Makefile.omdev.mingw index 525a39e96d5..3bbb79e999f 100644 --- a/OMCompiler/Compiler/boot/Makefile.omdev.mingw +++ b/OMCompiler/Compiler/boot/Makefile.omdev.mingw @@ -5,13 +5,11 @@ CXX=g++ EXE_EXT=.exe EXE_SUFFIX= -OMDEVMSYS=$(shell cygpath $$OMDEV) - ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) - EXTRA_LD_FLAGS = -Wl,--stack,16777216,--large-address-aware -L$(OMDEVMSYS)/lib/omniORB-4.2.0-mingw32/lib/x86_win32 + EXTRA_LD_FLAGS = -Wl,--stack,16777216,--large-address-aware ISMINGW64 = false else - EXTRA_LD_FLAGS = -Wl,--stack,33554432 -L$(OMDEVMSYS)/lib/omniORB-4.2.0-mingw64/lib/x86_win32 + EXTRA_LD_FLAGS = -Wl,--stack,33554432 ISMINGW64 = true endif @@ -20,13 +18,23 @@ PREVIOUS_GCC_VERSION = "5.3.0" GCC_VERSION := "`gcc -dumpversion`" OLD_OMDEV := $(shell expr "$(GCC_VERSION)" "==" "$(PREVIOUS_GCC_VERSION)") +# Uggly hack to decied what version of msys we have. +# If ucrt64 is set, it must be the newer version, so it's libbrotli instead of libbrotli-static +ifeq (ucrt64,$(findstring ucrt64,$(MSYSTEM_PREFIX))) +BROTLI_STATIC_LINKER_FLAGS = -lbrotlienc -lbrotlidec -lbrotlicommon +IS_NEW_NEW_OMDEV = true +else +BROTLI_STATIC_LINKER_FLAGS = -lbrotlienc-static -lbrotlidec-static -lbrotlicommon-static +IS_NEW_NEW_OMDEV = false +endif + ifeq "$(OLD_OMDEV)" "1" IS_NEW_OMDEV = false - LDFLAGS_CURL = -Wl,-Bstatic -lcurl -lidn -lrtmp -lssh2 -lssl -lcrypto -lwldap32 -lz -lws2_32 -lgnutls -ltasn1 -lhogweed -lgmp -lnettle -Wl,-Bdynamic -lcrypt32 -lintl -lp11-kit -lwinmm -lgdi32 + LDFLAGS_CURL = -lcurl -Wl,-Bstatic -lidn -lrtmp -lssh2 -lssl -lcrypto -lwldap32 -lz -lws2_32 -lgnutls -ltasn1 -lhogweed -lgmp -lnettle -Wl,-Bdynamic -lcrypt32 -lintl -lp11-kit -lwinmm -lgdi32 override CFLAGS += -fno-ipa-pure-const else IS_NEW_OMDEV = true - LDFLAGS_CURL = -Wl,-Bstatic -lcurl -lidn2 -lpsl -lbrotlienc-static -lbrotlidec-static -lbrotlicommon-static -lssh2 -lssl -lcrypto -lwldap32 -lzstd -lz -lws2_32 -lgnutls -ltasn1 -lhogweed -lgmp -lnettle -Wl,-Bdynamic -lunistring -lnghttp2 -lcrypt32 -lintl -lp11-kit -lwinmm -lgdi32 + LDFLAGS_CURL = -lcurl -Wl,-Bstatic -lidn2 -lpsl $(BROTLI_STATIC_LINKER_FLAGS) -lssh2 -lssl -lcrypto -lwldap32 -lzstd -lz -lws2_32 -lgnutls -ltasn1 -lhogweed -lgmp -lnettle -lbcrypt -Wl,-Bdynamic -lunistring -lnghttp2 -lcrypt32 -lintl -lp11-kit -lwinmm -lgdi32 endif TOP_DIR=../../ @@ -41,7 +49,7 @@ LDFLAGS=-L./ $(LOMPARSE) $(LCOMPILERRUNTIME) -L"$(OMHOME)/lib/omc" \ -lomantlr3 -lregex -lwsock32 -luuid -lole32 -lws2_32 -limagehlp \ -lRpcrt4 -lopenblas -fopenmp -lomcgc -lryu -lpthread $(FMILIB_OR_BOOT) -lshlwapi -liconv -lintl -lmetis \ -Wl,--enable-stdcall-fixup -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -static-libgcc \ --lgfortran -ltre -lomniORB420_rt -lomnithread40_rt \ +-lgfortran -ltre \ -lzmq \ $(OMENCRYPTIONLIBS) \ $(LDFLAGS_CURL) \ @@ -71,8 +79,8 @@ default: all ../Util/Autoconf.mo: ../Util/Autoconf.mo.omdev.mingw sed "s/@ISMINGW64@/$(ISMINGW64)/" "$<" > "$@.tmp" - sed "s/@IS_NEW_OMDEV@/$(IS_NEW_OMDEV)/" "$@.tmp" > "$@.tmp_" - rm "$@.tmp" - mv "$@.tmp_" "$@" + sed -i "s/@IS_NEW_OMDEV@/$(IS_NEW_OMDEV)/" "$@.tmp" + sed -i "s/@IS_NEW_NEW_OMDEV@/$(IS_NEW_NEW_OMDEV)/" "$@.tmp" + mv "$@.tmp" "$@" include Makefile.common diff --git a/OMCompiler/Compiler/runtime/CMakeLists.txt b/OMCompiler/Compiler/runtime/CMakeLists.txt index 5e43c12643d..c5d3d8dbc43 100644 --- a/OMCompiler/Compiler/runtime/CMakeLists.txt +++ b/OMCompiler/Compiler/runtime/CMakeLists.txt @@ -92,6 +92,12 @@ endif() # Corba support if(OM_OMC_USE_CORBA) if(MINGW) + if(DEFINED ENV{MSYSTEM_PREFIX}) + string(FIND $ENV{MSYSTEM_PREFIX} "ucrt64" IS_UCRT64) + if(IS_UCRT64) + message(FATAL_ERROR "No corba support on UCRT64") + endif() + endif() # setup omniORB for MinGW OMDev include(.cmake/omdev_omniorb_setup.cmake) # Include the macro for compiling corba targets. diff --git a/OMCompiler/Compiler/runtime/Makefile.common b/OMCompiler/Compiler/runtime/Makefile.common index fe7b3c85dd4..52fc32350f2 100644 --- a/OMCompiler/Compiler/runtime/Makefile.common +++ b/OMCompiler/Compiler/runtime/Makefile.common @@ -13,10 +13,11 @@ LDFLAGS += ../../3rdParty/FMIL/build/Config.cmake/Minizip/libminizip.a SimRuntimeCDir = $(top_builddir)/SimulationRuntime/c/ -ifndef OMDEV - configUnix = $(OMC_CONFIG_INC)/omc_config.unix.h -else +detected_OS ?= $(shell uname -s) +ifeq (MINGW,$(findstring MINGW,$(detected_OS))) configUnix = +else + configUnix = $(OMC_CONFIG_INC)/omc_config.unix.h endif OMC_OBJ_SHARED = Error_omc$(OBJEXT) \ @@ -100,7 +101,9 @@ libomcruntime-boot.dll : $(OMC_OBJ) $(CXX) -shared $(RPATH) -o $@ $(OMC_OBJ) $(LDFLAGS) omc_communication.cc : omc_communication.idl +ifdef USE_CORBA $(IDL) omc_communication.idl +endif omc_communication.h: omc_communication.cc Print_omc.o : printimpl.c printimpl.h diff --git a/OMCompiler/Compiler/runtime/Makefile.omdev.mingw b/OMCompiler/Compiler/runtime/Makefile.omdev.mingw index dff8ab7489b..bf2935fa22a 100644 --- a/OMCompiler/Compiler/runtime/Makefile.omdev.mingw +++ b/OMCompiler/Compiler/runtime/Makefile.omdev.mingw @@ -1,26 +1,24 @@ -# Adrian Pop, adrpo@ida.liu.se, 2006-02-01 -# Makefile for Compiler/runtime compilation of OMC using OMDev-mingw -# OMDev-mingw: http://www.ida.liu.se/~adrpo/omc/omdev/ -# -# $Id: Makefile.omdev.mingw.in 1817 2006-02-01 12:21:26Z adrpo $ -# +# Makefile for Compiler/runtime compilation of OMC using MSYS UCRT -# The path to the OMDev-mingw package MUST BE SET! -#OMDEV=$OMDEV # Test if the needed variables are there... .testvariables: ifndef OMDEV @echo You have to set the OMDEV variabile pointing to your OMDev package root! Exiting.... - @echo Take the OMDev package from: http://www.ida.liu.se/~adrpo/omc/omdev/ - @echo For questions or problems email Adrian Pop, adrpo@ida.liu.se + @echo See OpenModelica/OMCompiler/README.Windows.md ABORT endif +ifndef MSYSTEM_PREFIX +$(error Environment variable MSYSTEM_PREFIX not set. Is this a msys2 shell?) +endif -OMDEVMSYS=$(shell cygpath $$OMDEV) +OMDEV = $(shell cygpath $$OMDEV) +MSYSTEM_PREFIX = $(shell cygpath $$MSYSTEM_PREFIX) TOP_DIR=../../ USE_METIS = -DUSE_METIS -CORBAHOME = $(OMDEVMSYS) +# We don't compile with corba on OMDev-mingw any more +USE_CORBA = +CORBAHOME = $(OMDEV) FMIINCLUDE = ../../3rdParty/FMIL/install/include GRAPHINCLUDE=../../3rdParty/metis-5.1.0/include CJSONINCLUDE = ../../3rdParty/cJSON/ @@ -34,22 +32,22 @@ OMC=$(OMBUILDDIR)/bin/omc SHREXT=.a OMPCC = gcc -fopenmp -# We always compile with corba on OMDev-mingw -ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) -USE_CORBA = -DUSE_CORBA -D__x86__ -D__NT__ -D__OSVERSION__=4 -CORBAINCL = -I$(CORBAHOME)/lib/omniORB-4.2.0-mingw32/include -IDL = $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw32/bin/x86_win32/omniidl -T -bcxx -Wbh=.h -Wbs=.cc -p../../lib/python -Wbdebug -else # 64 bit -USE_CORBA = -DUSE_CORBA -D__x86__ -D__NT__ -D__OSVERSION__=4 -D_WIN64 -DMS_WIN64 -CORBAINCL = -I$(CORBAHOME)/lib/omniORB-4.2.0-mingw64/include -IDL = $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/omniidl -T -bcxx -Wbh=.h -Wbs=.cc -p../../lib/python -Wbdebug +ifdef USE_CORBA + CORBA_C_CLFAGS = -DUSE_CORBA -D__x86__ -D__NT__ -D__OSVERSION__=4 -D_WIN64 -DMS_WIN64 + CORBAINCL = -I$(CORBAHOME)/lib/omniORB-4.2.0-mingw64/include + IDL = $(OMDEV)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/omniidl -T -bcxx -Wbh=.h -Wbs=.cc -p../../lib/python -Wbdebug + OMCCORBASRC = omc_communication.o omc_communication_impl.o Corba_omc.o +else + CORBA_C_CLFAGS = + CORBAINCL = + OMCCORBASRC = corbaimpl_stub_omc.o + IDL = endif -OMCCORBASRC = omc_communication.o omc_communication_impl.o Corba_omc.o SHELL = /bin/sh CC = gcc CXX = g++ -override CFLAGS += $(USE_CORBA) $(USE_METIS) -Werror=implicit-function-declaration -Wall -Wno-unused-variable -I$(OMC_CONFIG_INC) -I$(top_builddir)/SimulationRuntime/c -I$(top_builddir)/SimulationRuntime/c/simulation/results -I$(top_builddir)/SimulationRuntime/c/util -I$(top_builddir)/SimulationRuntime/c/meta -I$(top_builddir)/SimulationRuntime/c/meta/gc $(CORBAINCL) $(GCINCLUDE) -I$(FMIINCLUDE) -I$(CJSONINCLUDE) -I$(GRAPHINCLUDE) -I$(SQLITE3INCLUDE) -I$(ZMQINCLUDE) -I"$(TOP_DIR)/3rdParty/zlib" -I"$(TOP_DIR)/3rdParty/libffi/install/include/" -DWIN32_LEAN_AND_MEAN +override CFLAGS += $(CORBA_C_CLFAGS) $(USE_METIS) -Werror=implicit-function-declaration -Wall -Wno-unused-variable -I$(OMC_CONFIG_INC) -I$(top_builddir)/SimulationRuntime/c -I$(top_builddir)/SimulationRuntime/c/simulation/results -I$(top_builddir)/SimulationRuntime/c/util -I$(top_builddir)/SimulationRuntime/c/meta -I$(top_builddir)/SimulationRuntime/c/meta/gc $(CORBAINCL) $(GCINCLUDE) -I$(FMIINCLUDE) -I$(CJSONINCLUDE) -I$(GRAPHINCLUDE) -I$(SQLITE3INCLUDE) -I$(ZMQINCLUDE) -I"$(TOP_DIR)/3rdParty/zlib" -I"$(TOP_DIR)/3rdParty/libffi/install/include/" -DWIN32_LEAN_AND_MEAN override CXXFLAGS += -std=c++11 $(CFLAGS) include Makefile.common diff --git a/OMCompiler/Compiler/runtime/System_omc.c b/OMCompiler/Compiler/runtime/System_omc.c index d5b5d05383d..82c82678a0b 100644 --- a/OMCompiler/Compiler/runtime/System_omc.c +++ b/OMCompiler/Compiler/runtime/System_omc.c @@ -723,6 +723,13 @@ extern const char* System_modelicaPlatform() return CONFIG_MODELICA_SPEC_PLATFORM; } +/** + * @brief Returns platform OpenModelica is compiled for. + * + * Returns CONFIG_OPENMODELICA_SPEC_PLATFORM defined in omc_config.h + * + * @return const char* platform specifier + */ extern const char* System_openModelicaPlatform() { return CONFIG_OPENMODELICA_SPEC_PLATFORM; diff --git a/OMCompiler/Compiler/runtime/om_curl.c b/OMCompiler/Compiler/runtime/om_curl.c index fcd403c4fa8..af4d3e6f34d 100644 --- a/OMCompiler/Compiler/runtime/om_curl.c +++ b/OMCompiler/Compiler/runtime/om_curl.c @@ -9,6 +9,11 @@ #include "meta/meta_modelica.h" #include "util/omc_file.h" #include "errorext.h" +#include "omc_config.h" + +#define MAX_BUFFER_SIZE 2048 + +char* findCurlCABundleMsys(); typedef struct { const char *url; @@ -37,7 +42,7 @@ static void* addTransfer(CURLM *cm, void *urlPathList, int *result, int n) FILE *fout = omc_fopen(file, "wb"); if (fout == NULL) { - c_add_message(NULL, -1, ErrorType_runtime,ErrorLevel_error, "Failed to open file for writing: %s", &file, 1); + c_add_message(NULL, -1, ErrorType_runtime, ErrorLevel_error, "Failed to open file for writing: %s", &file, 1); *result = 0; return rest; } @@ -49,29 +54,13 @@ static void* addTransfer(CURLM *cm, void *urlPathList, int *result, int n) p->filename = MMC_CDR(first); p->tmpFilename = tmpFilename; #if defined(__MINGW32__) - { - /* mingw/windows horror, let's find the curl CA bundle! */ - char* ca_bundle_file = NULL; - const char* omhome = SettingsImpl__getInstallationDirectoryPath(); -#if defined(__MINGW64__) -#define CURL_CA_BUNDLE_SUFFIX "/tools/msys/mingw64/ssl/certs/ca-bundle.crt" -#else -#define CURL_CA_BUNDLE_SUFFIX "/tools/msys/mingw32/ssl/certs/ca-bundle.crt" -#endif - ca_bundle_file = (char*)malloc(sizeof(char*)*strlen(omhome) + strlen(CURL_CA_BUNDLE_SUFFIX) + 1); - sprintf(ca_bundle_file, "%s/%s", omhome, CURL_CA_BUNDLE_SUFFIX); - /* check if file exists */ - if (!SystemImpl__regularFileExists(ca_bundle_file)) - { - /* oh nooo, this is not an installation, is just a repo, try with OMDEV */ - free(ca_bundle_file); - omhome = getenv("OMDEV"); - ca_bundle_file = (char*)malloc(sizeof(char*)*strlen(omhome) + strlen(CURL_CA_BUNDLE_SUFFIX) + 1); - sprintf(ca_bundle_file, "%s/%s", omhome, CURL_CA_BUNDLE_SUFFIX); - } - curl_easy_setopt(eh, CURLOPT_CAINFO, ca_bundle_file); - free(ca_bundle_file); + char* ca_bundle_file = findCurlCABundleMsys(); + if (!ca_bundle_file) { + *result = 0; + return rest; } + curl_easy_setopt(eh, CURLOPT_CAINFO, ca_bundle_file); + free(ca_bundle_file); #endif curl_easy_setopt(eh, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(eh, CURLOPT_WRITEFUNCTION, writeDataCallback); @@ -159,3 +148,66 @@ int om_curl_multi_download(void *urlPathList, int maxParallel) return result; } + +#if defined(__MINGW32__) +/** + * @brief Try to find curl CA bundle file on msys + * + * Searching for ca-bundle.crt in: + * - $OPENMODELICAHOME/tools/msys/usr/ssl/certs/ + * - $OPENMODELICAHOME/tools/msys//ssl/certs/ + * - $OMDEV/tools/msys[64]/usr/ssl/certs/ + * - $OMDEV/tools/msys[64]//ssl/certs/ + * + * @return const char* Path to ca-bundle.crt file on success, NULL on failure. + */ +char* findCurlCABundleMsys() { + char* ca_bundle_file = NULL; + const char* omhome = SettingsImpl__getInstallationDirectoryPath(); + const char* omdev = getenv("OMDEV"); + const char* msys = "tools/msys"; + const char* environment = CONFIG_OPENMODELICA_SPEC_PLATFORM; + const char* curl_ca_bundle_suffix = "ssl/certs/ca-bundle.crt"; + char buffer[MAX_BUFFER_SIZE] = ""; + unsigned int length = 0; + ca_bundle_file = (char*) calloc(sizeof(char), strlen(omhome) + 1 + strlen(msys) + 1 + strlen(environment) + 1 + strlen(curl_ca_bundle_suffix) + 1 ); + + // Test $OPENMODELICAHOME/tools/msys/usr/ssl/certs/ca-bundle.crt + sprintf(ca_bundle_file, "%s/%s/usr/%s", omhome, msys, curl_ca_bundle_suffix); + length += snprintf(buffer+length, MAX_BUFFER_SIZE-length, "\t- %s\n", ca_bundle_file); + if (SystemImpl__regularFileExists(ca_bundle_file)) { + return ca_bundle_file; + } + + // Test $OPENMODELICAHOME/tools/msys//ssl/certs/ca-bundle.crt + sprintf(ca_bundle_file, "%s/%s/%s/%s", omhome, msys, environment, curl_ca_bundle_suffix); + length += snprintf(buffer+length, MAX_BUFFER_SIZE-length, "\t- %s\n", ca_bundle_file); + if (SystemImpl__regularFileExists(ca_bundle_file)) { + return ca_bundle_file; + } + + // Test $OMDEV/tools/msys/usr/ssl/certs/ca-bundle.crt + sprintf(ca_bundle_file, "%s/%s/usr/%s", omdev, msys, curl_ca_bundle_suffix); + length += snprintf(buffer+length, MAX_BUFFER_SIZE-length, "\t- %s\n", ca_bundle_file); + if (SystemImpl__regularFileExists(ca_bundle_file)) { + return ca_bundle_file; + } + + // Test $OMDEV/tools/msys//ssl/certs/ca-bundle.crt + sprintf(ca_bundle_file, "%s/%s/%s/%s", omdev, msys, environment, curl_ca_bundle_suffix); + length += snprintf(buffer+length, MAX_BUFFER_SIZE-length, "\t- %s\n", ca_bundle_file); + if (SystemImpl__regularFileExists(ca_bundle_file)) { + return ca_bundle_file; + } + + const char* tokens[1] = {buffer}; + c_add_message(NULL, -1, ErrorType_runtime, ErrorLevel_error, "Couldn't find ca-bundle.crt. Searched in:\n%s", tokens, 1); + + free(ca_bundle_file); + return NULL; +} +#else +char* findCurlCABundleMsys() { + return NULL; +} +#endif // defined(__MINGW32__) diff --git a/OMCompiler/Compiler/runtime/settingsimpl.h b/OMCompiler/Compiler/runtime/settingsimpl.h index 86f63e3336c..019bd2bd57d 100644 --- a/OMCompiler/Compiler/runtime/settingsimpl.h +++ b/OMCompiler/Compiler/runtime/settingsimpl.h @@ -30,12 +30,16 @@ #ifndef SETTINGSIMPL__H_ #define SETTINGSIMPL__H_ + #ifdef __cplusplus extern "C" { #endif + extern const char* SettingsImpl__getInstallationDirectoryPath(); extern const char* SettingsImpl__getTempDirectoryPath(); + #ifdef __cplusplus } #endif -#endif + +#endif // SETTINGSIMPL__H_ diff --git a/OMCompiler/Compiler/runtime/systemimpl.c b/OMCompiler/Compiler/runtime/systemimpl.c index 1ecf8ba32c9..78618d7b600 100644 --- a/OMCompiler/Compiler/runtime/systemimpl.c +++ b/OMCompiler/Compiler/runtime/systemimpl.c @@ -2970,12 +2970,18 @@ int SystemImpl__rename(const char *source, const char *dest) return (0 == omc_rename(source, dest)); } +/** + * @brief Convert unix time to string + * + * @param time Calendar time value (integer) + * @return char* Time string in format Www Mmm dd hh:mm:ss yyyy + */ char* SystemImpl__ctime(double time) { char buf[64] = {0}; /* needs to be >=26 char */ time_t t = (time_t) time; #if defined(__MINGW32__) || defined(_MSC_VER) - errno_t e = ctime_s(buf, 64, t); + errno_t e = ctime_s(buf, 64, &t); assert(e == 0 && "ctime_s returned an error"); return omc_alloc_interface.malloc_strdup(buf); #else diff --git a/OMCompiler/Compiler/scripts/Compile.bat b/OMCompiler/Compiler/scripts/Compile.bat index 4104fb2b4e5..5669cf04b58 100755 --- a/OMCompiler/Compiler/scripts/Compile.bat +++ b/OMCompiler/Compiler/scripts/Compile.bat @@ -2,7 +2,7 @@ REM Arguments REM 1 fileprefix REM 2 target (gcc|msvc) -REM 3 platform (mingw64|mingw32) +REM 3 platform (ucrt64|mingw64) REM 4 serial/parallel REM 5 linkType (dynamic|static) REM 6 number of processors @@ -20,7 +20,7 @@ set OLD_PATH=%PATH% call :CONVERT_OPENMODELICAHOME_TO_SHORT_PATH_NAME "%OPENMODELICAHOME%" set MINGW="%OPENMODELICAHOME%\tools\msys\%OM_PLATFORM%" set ADDITIONAL_ARGS= -REM If OMDEV is set, use MinGW from there instead of OPENMODELICAHOME +REM If OMDEV is set, use msys2-ucrt64 from there instead of OPENMODELICAHOME REM It is not certain that release OMC is installed if not %OMDEV%a==a set MINGW=%OMDEV%\tools\msys\%OM_PLATFORM% REM echo OPENMODELICAHOME = %OPENMODELICAHOME% >> %1.log 2>&1 diff --git a/OMCompiler/Compiler/scripts/Prompt.bat b/OMCompiler/Compiler/scripts/Prompt.bat index fb9992fb9a8..b4508b0453f 100644 --- a/OMCompiler/Compiler/scripts/Prompt.bat +++ b/OMCompiler/Compiler/scripts/Prompt.bat @@ -1,15 +1,15 @@ @echo off -REM %1 should be mingw32 or mingw64, if empty the latter is selected +REM %1 should be ucrt64, if empty ucrt64 is selected REM Clear all environment variables that may interfere during compile and link phases. set GCC_EXEC_PREFIX= set CPLUS_INCLUDE_PATH= set C_INCLUDE_PATH= set LIBRARY_PATH= set OLD_PATH=%PATH% -if not "%1"=="" (set OM_PLATFORM=%1) else (set OM_PLATFORM=mingw64) +if not "%1"=="" (set OM_PLATFORM=%1) else (set OM_PLATFORM=ucrt64) set MINGW="%OPENMODELICAHOME%\tools\msys\%OM_PLATFORM%" set ADDITIONAL_ARGS= -REM If OMDEV is set, use MinGW from there instead of OPENMODELICAHOME +REM If OMDEV is set, use Msys from there instead of OPENMODELICAHOME REM It is not certain that release OMC is installed if not %OMDEV%a==a set MINGW=%OMDEV%\tools\msys\%OM_PLATFORM% REM echo OPENMODELICAHOME = %OPENMODELICAHOME% >> %1.log 2>&1 diff --git a/OMCompiler/INSTALL.mingw.crosscompile.sh b/OMCompiler/INSTALL.mingw.crosscompile.sh deleted file mode 100755 index f9c55f84590..00000000000 --- a/OMCompiler/INSTALL.mingw.crosscompile.sh +++ /dev/null @@ -1,12 +0,0 @@ -# Some small directions to get compilation of Windows executables on Linux -# apt-get install gcc-mingw32 -# Note: This is still work in progress. ranlib is not called on the .a-files, wrong linking flags are used in the end. The wrong config.h is used -OMDEV=~/dev/OMDev -autoconf -./configure --host=i586-mingw32msvc AR=i586-mingw32msvc-ar "CPPFLAGS=-I$OMDEV/tools/mingw/include -I$OMDEV/lib/3rdParty/Sundials/include" "LDFLAGS=-L/usr/i586-mingw32msvc/lib/ -L$OMDEV/tools/mingw/lib -L$OMDEV/tools/mingw/mingw32/lib" --with-lapack="-llapack-mingw -lblas-mingw -lg2c" - -# Some old config lines; maybe still useful. Remove when everything is working -# ./configure AR=i586-mingw32msvc-ar CC=i586-mingw32msvc-cc CXX=i586-mingw32msvc-c++ "CPPFLAGS=-I$OMDEV/tools/mingw/include -I$OMDEV/lib/3rdParty/Sundials/include" "LDFLAGS=-L$OMDEV/tools/mingw/lib" --with-lapack="-llapack-mingw -lblas-mingw -lg2c" -#./configure --host=amd64-linux CC=i586-mingw32msvc-cc "CPPFLAGS=-I/usr/i686-w64-mingw32/include -I$OMDEV/tools/mingw/include -I$OMDEV/lib/3rdParty/Sundials/include" --with-lapack="-llapack-mingw -lblas-mingw -lg2c" -# For libgc; if stuff still fails... -# ./configure '--target=i586-mingw32msvc' '--enable-large-config' 'CC=i586-mingw32msvc-cc' 'CXX=i586-mingw32msvc-c++' 'CFLAGS=' 'CPPFLAGS=-I/home/martin/dev/OMDev/tools/mingw/include' LDFLAGS="-L/home/martin/dev/OMDev/tools/mingw/lib" 'target_alias=i586-mingw32msvc' --disable-threads --with-cross-host=i586-mingw32msvc --host=i586-mingw32msvc diff --git a/OMCompiler/Makefile.common b/OMCompiler/Makefile.common index 2afbd2748af..241efa0c444 100644 --- a/OMCompiler/Makefile.common +++ b/OMCompiler/Makefile.common @@ -51,7 +51,7 @@ $(builddir_doc)/omc/testmodels \ $(builddir_man)/man1/ # Silence unnecessary verbose install messages from CMAKE -CMAKE := $(CMAKE) -DCMAKE_INSTALL_MESSAGE=LAZY +CMAKE_FLAGS += -DCMAKE_INSTALL_MESSAGE=LAZY OMC_IPOPT_ROOT = 3rdParty/Ipopt-3.13.4 OMC_TBB_ROOT = 3rdParty/tbb @@ -182,8 +182,8 @@ ipopt-clean: suitesparse: mkdir -p 3rdParty/SuiteSparse-5.8.1/build - cd 3rdParty/SuiteSparse-5.8.1/build && $(CMAKE_NO_CHECK_UNDEFINED) .. -G \ - $(CMAKE_TARGET) -DCMAKE_VERBOSE_MAKEFILE:Bool=ON \ + cd 3rdParty/SuiteSparse-5.8.1/build && $(CMAKE_NO_CHECK_UNDEFINED) .. -G $(CMAKE_TARGET) \ + -DCMAKE_VERBOSE_MAKEFILE:Bool=ON \ -DCMAKE_INSTALL_PREFIX:PATH="$(OMBUILDDIR)" \ -DCMAKE_INSTALL_LIBDIR="$(LIB_OMC)" \ -DCMAKE_INSTALL_INCLUDEDIR="$(OMBUILDDIR)/include/omc/c/" \ diff --git a/OMCompiler/Makefile.in b/OMCompiler/Makefile.in index 2af80e43db3..ee3176a8635 100644 --- a/OMCompiler/Makefile.in +++ b/OMCompiler/Makefile.in @@ -97,7 +97,6 @@ endif include Makefile.common include Makefile.omsi.common -# We don't need OMDEV hacks, but using the same Makefile sure is nice! .testvariables: settings: @@ -155,16 +154,15 @@ emcc-simulationruntime: mkdir -p build/lib/omc/emcc/ $(MAKE) -C SimulationRuntime/c emcc -OMDEV_CMAKE="$(OMDEV)/bin/cmake/bin/cmake.exe" +CMAKE=cmake checkMSVCwine: - @echo 'Test for WINE, OMDEV, VS140COMNTOOLS env.vars' + @echo 'Test for WINE, VS140COMNTOOLS env.vars' env test ! -z "$(WINE)" - test ! -z "$(OMDEV)" test ! -z "$(VS140COMNTOOLS)" $(WINE) cl.exe - $(WINE) cmd /c "if not exist $(OMDEV_CMAKE) (exit 1)" + $(WINE) cmd /c "if not exist $(CMAKE) (exit 1)" # Remove wine-mono $(WINE) uninstaller --remove '{E45D8920-A758-4088-B6C6-31DBB276992E}' @@ -175,7 +173,7 @@ wine_fmil_msvc: .wine_fmil_msvc # Goto build msvc directory test -d 3rdParty/FMIL - (test -f $@ && test -d 3rdParty/FMIL/build_msvc && test -d 3rdParty/FMIL/install_msvc) || (rm -rf 3rdParty/FMIL/build_msvc && rm -rf 3rdParty/FMIL/install_msvc && mkdir -p 3rdParty/FMIL/build_msvc && cd 3rdParty/FMIL/build_msvc && $(WINE) "$(OMDEV_CMAKE)" -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DFMILIB_BUILD_TESTS=OFF -DFMILIB_BUILD_STATIC_LIB=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=../install_msvc ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile install) + (test -f $@ && test -d 3rdParty/FMIL/build_msvc && test -d 3rdParty/FMIL/install_msvc) || (rm -rf 3rdParty/FMIL/build_msvc && rm -rf 3rdParty/FMIL/install_msvc && mkdir -p 3rdParty/FMIL/build_msvc && cd 3rdParty/FMIL/build_msvc && $(WINE) "$(CMAKE)" -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DFMILIB_BUILD_TESTS=OFF -DFMILIB_BUILD_STATIC_LIB=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=../install_msvc ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile install) (cp -puf 3rdParty/FMIL/install_msvc/lib/fmilib_shared.dll $(OMBUILDDIR)/lib/omc/msvc/fmilib.dll) (cp -puf 3rdParty/FMIL/install_msvc/lib/fmilib_shared.lib $(OMBUILDDIR)/lib/omc/msvc/fmilib.lib) @@ -191,7 +189,7 @@ wine_sundials_msvc: .wine_sundials_msvc # Goto build msvc directory test -d 3rdParty/sundials-5.4.0 - (test -f $@ && test -d 3rdParty/sundials-5.4.0/build_msvc) || (rm -rf 3rdParty/sundials-5.4.0/build_msvc && mkdir -p 3rdParty/sundials-5.4.0/build_msvc && cd 3rdParty/sundials-5.4.0/build_msvc && $(WINE) "$(OMDEV_CMAKE)" -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DSUNDIALS_BUILD_STATIC_LIBS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=. ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile install) + (test -f $@ && test -d 3rdParty/sundials-5.4.0/build_msvc) || (rm -rf 3rdParty/sundials-5.4.0/build_msvc && mkdir -p 3rdParty/sundials-5.4.0/build_msvc && cd 3rdParty/sundials-5.4.0/build_msvc && $(WINE) "$(CMAKE)" -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DSUNDIALS_BUILD_STATIC_LIBS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=. ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile install) mkdir -p $(OMBUILDDIR)/include/omc/msvc/sundials (cp -pufr 3rdParty/sundials-5.4.0/build_msvc/include/* $(OMBUILDDIR)/include/omc/msvc/sundials) (cp -puf 3rdParty/sundials-5.4.0/build_msvc/lib/* $(OMBUILDDIR)/lib/omc/msvc/) @@ -203,7 +201,7 @@ wine_runc_msvc_release: .wine_runc_msvc_release mkdir -p $(OMBUILDDIR)/lib/omc/msvc/release echo 'Build the MSVC RELEASE' - (test -f $@ && test -d SimulationRuntime/c/build_msvc/) || (rm -rf SimulationRuntime/c/build_msvc && mkdir -p SimulationRuntime/c/build_msvc && cd SimulationRuntime/c/build_msvc && $(WINE) "$(OMDEV_CMAKE)" -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:String=$(OMBUILDDIR) ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile) + (test -f $@ && test -d SimulationRuntime/c/build_msvc/) || (rm -rf SimulationRuntime/c/build_msvc && mkdir -p SimulationRuntime/c/build_msvc && cd SimulationRuntime/c/build_msvc && $(WINE) "$(CMAKE)" -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:String=$(OMBUILDDIR) ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile) @echo 'Copy the .lib files (needed for compilation) and .pdb files (needed for debugging) to $(OMBUILDDIR)/lib/omc' (cd SimulationRuntime/c/build_msvc && find . -type f -path "*.lib" -exec cp {} $(OMBUILDDIR)/lib/omc/msvc/release/. \;) (cd SimulationRuntime/c/build_msvc && find . -type f -path "*.pdb" -exec cp {} $(OMBUILDDIR)/lib/omc/msvc/release/. \;) @@ -215,7 +213,7 @@ wine_runc_msvc_debug: .wine_runc_msvc_debug mkdir -p $(OMBUILDDIR)/lib/omc/msvc/debug echo 'Build the MSVC DEBUG' - (test -f $@ && test -d SimulationRuntime/c/build_msvc_debug/) || (rm -rf SimulationRuntime/c/build_msvc_debug && mkdir -p SimulationRuntime/c/build_msvc_debug && cd SimulationRuntime/c/build_msvc && $(WINE) "$(OMDEV_CMAKE)" -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:String=$(OMBUILDDIR) ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile) + (test -f $@ && test -d SimulationRuntime/c/build_msvc_debug/) || (rm -rf SimulationRuntime/c/build_msvc_debug && mkdir -p SimulationRuntime/c/build_msvc_debug && cd SimulationRuntime/c/build_msvc && $(WINE) "$(CMAKE)" -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX:String=$(OMBUILDDIR) ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile) @echo 'Copy the .lib files (needed for compilation) and .pdb files (needed for debugging) to $(OMBUILDDIR)/lib/omc' (cd SimulationRuntime/c/build_msvc_debug && find . -type f -path "*.lib" -exec cp {} $(OMBUILDDIR)/lib/omc/msvc/debug/. \;) (cd SimulationRuntime/c/build_msvc_debug && find . -type f -path "*.pdb" -exec cp {} $(OMBUILDDIR)/lib/omc/msvc/debug/. \;) @@ -226,7 +224,7 @@ wine_runc_msvc_gc: .wine_runc_msvc_gc # build gc as well, as it is needed for the msvc c runtime @echo 'Build gc (RelWithDebInfo)' - (test -f $@ && test -d 3rdParty/gc/build_msvc/) || (rm -rf 3rdParty/gc/build_msvc/ && mkdir -p 3rdParty/gc/build_msvc && cd 3rdParty/gc/build_msvc && $(WINE) "$(OMDEV_CMAKE)" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGC_BUILD_SHARED_LIBS=OFF ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile) + (test -f $@ && test -d 3rdParty/gc/build_msvc/) || (rm -rf 3rdParty/gc/build_msvc/ && mkdir -p 3rdParty/gc/build_msvc && cd 3rdParty/gc/build_msvc && $(WINE) "$(CMAKE)" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DGC_BUILD_SHARED_LIBS=OFF ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile) @echo 'Copy the .lib files (needed for compilation) and .pdb files (needed for debugging) to $(OMBUILDDIR)/lib/omc/msvc/' cp -u 3rdParty/gc/build_msvc/omcgc.* $(OMBUILDDIR)/lib/omc/msvc/ @touch $@ @@ -235,7 +233,7 @@ wine_run_omc_msvc: .wine_run_omc_msvc .wine_run_omc_msvc: checkMSVCwine @echo 'Build MSVC Compiler/runtime (RelWithDebInfo)' - (test -f $@ && test -d Compiler/runtime/build_msvc/) || (rm -rf Compiler/runtime/build_msvc/ && mkdir -p Compiler/runtime/build_msvc && cd Compiler/runtime/build_msvc && $(WINE) "$(OMDEV_CMAKE)" -DCMAKE_BUILD_TYPE=RelWithDebInfo ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile) + (test -f $@ && test -d Compiler/runtime/build_msvc/) || (rm -rf Compiler/runtime/build_msvc/ && mkdir -p Compiler/runtime/build_msvc && cd Compiler/runtime/build_msvc && $(WINE) "$(CMAKE)" -DCMAKE_BUILD_TYPE=RelWithDebInfo ../ -G "NMake Makefiles" && $(WINE) nmake /f Makefile) @echo 'Copy the .lib files (needed for compilation) and .pdb files (needed for debugging) to $(OMBUILDDIR)/lib/omc/msvc/' # cp -u Compiler/runtime/build_msvc/omcgc.* $(OMBUILDDIR)/lib/omc/msvc/ @touch $@ diff --git a/OMCompiler/Makefile.omdev.mingw b/OMCompiler/Makefile.omdev.mingw index df1e84914db..41e32cf82c8 100644 --- a/OMCompiler/Makefile.omdev.mingw +++ b/OMCompiler/Makefile.omdev.mingw @@ -14,6 +14,30 @@ endif override FCFLAGS +=-fallow-argument-mismatch +defaultMakefileTarget = Makefile.omdev.mingw +REALPATH = $(realpath .) +OMBUILDDIR=$(REALPATH)/build + +ifndef OMDEV +$(error Environment variable OMDEV not set!) +endif +#ifndef OMDEV_MSYS +#$(error Environment variable OMDEV_MSYS not set!) +#endif +ifndef MSYSTEM_PREFIX +$(error Environment variable MSYSTEM_PREFIX not set. Is this a msys2 shell?) +endif +OMDEV = $(shell cygpath $$OMDEV) +OMDEV_MSYS = $(shell cygpath $$OMDEV/tools/msys) +MSYSTEM_PREFIX = $(shell cygpath $$MSYSTEM_PREFIX) +OM_MSYS_ENV_DIR = $(MSYSTEM_PREFIX) + +# Define UCRT64 for omc_config.h +ifeq (ucrt64,$(findstring ucrt64,$(MSYSTEM_PREFIX))) +override CFLAGS += -DUCRT64 +endif + + # makefile for Windows MinGW OMDev all : .testvariables settings omc @@ -40,8 +64,6 @@ ifeq ($(BUILDTYPE),) BUILDTYPE=Debug endif -OMDEVMSYS=$(shell cygpath $$OMDEV) - prefix = ./build exec_prefix = ${prefix} bindir = ${exec_prefix}/bin @@ -52,24 +74,19 @@ docdir = ${prefix}/doc MSGPACK_CFLAGS = -march=i686 -CMAKE = CC="$(CC)" CXX="$(CXX)" FC="$(FC)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CPPFLAGS="$(CPPFLAGS)" FFLAGS="$(FCFLAGS)" LDFLAGS="$(LDFLAGS)" $(OMDEVMSYS)/bin/cmake/bin/cmake +CMAKE = CC="$(CC)" CXX="$(CXX)" FC="$(FC)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CPPFLAGS="$(CPPFLAGS)" FFLAGS="$(FCFLAGS)" LDFLAGS="$(LDFLAGS)" cmake.exe CMAKE_NO_CHECK_UNDEFINED = $(CMAKE) CMAKE_TARGET = "MSYS Makefiles" ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) - BOOST_PATH = $(OMDEVMSYS)/tools/msys/mingw32/include - IS_MINGW32 = -DIS_MINGW32=ON - IS_MINGW64 = -DIS_MINGW64=OFF - MINGW_FMIL_FLAGS=-DFMILIB_FMI_PLATFORM=win32 - LVE_EXE_SUFFIX=win32 -else # mingw64 - BOOST_PATH = $(OMDEVMSYS)/tools/msys/mingw64/include - IS_MINGW32 = -DIS_MINGW32=OFF - IS_MINGW64 = -DIS_MINGW64=ON - MINGW_FMIL_FLAGS=-DFMILIB_FMI_PLATFORM=win64 - LVE_EXE_SUFFIX=win64 +$(error "No 32-bit support") +else # 64-bit MSYS +BOOST_PATH = $(OM_MSYS_ENV_DIR)/include +IS_MINGW32 = -DIS_MINGW32=OFF +IS_MINGW64 = -DIS_MINGW64=ON +MINGW_FMIL_FLAGS=-DFMILIB_FMI_PLATFORM=win64 +LVE_EXE_SUFFIX=win64 endif -BOOST_PATH_MSVC = $(OMDEVMSYS)/lib/3rdParty/boost-1_55/ WROOT=$(shell cygpath $$SYSTEMROOT) OPENCL = Yes @@ -94,7 +111,7 @@ LD_LAPACK=-lopenblas GRAPHLIB=libmetis.a GRAPHINCLUDE=3rdParty/metis-5.1.0/include/ -DUSE_METIS -DUSE_GRAPH BOOTSTRAP_FMIL_DEP=fmil -IDLPYTHON = $(OMDEVMSYS)/lib/omniORB-4.2.0-msvc-10/bin/x86_win32/omniidl -bpython -Wbglobal=_OMCIDL -Wbpackage=OMPythonIDL +IDLPYTHON = $(OMDEV)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/omniidl -T -bcxx -Wbh=.h -Wbs=.cc -p../../lib/python -Wbdebug IDLPYTHONTARGET = $(builddir_share)/omc/scripts/PythonInterface/OMPythonIDL/omc_communication_idl.py IDLFILE=$(top_builddir)/Compiler/runtime/omc_communication.idl LIB_OMC=lib/omc @@ -127,8 +144,8 @@ CMINPACKLIB_SHARED = OFF CONFIG_REVISION = $(shell git describe --match "v*.*" --always) ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) -PLATFORM_ARCH = (32-bit) -else # mingw64 +$(error "No 32-bit support") +else # 64-bit MSYS PLATFORM_ARCH = (64-bit) endif @@ -150,11 +167,11 @@ else endif else $(eval VSCOMNTOOLS=$(VS120COMNTOOLS)) - $(eval BOOST_PATH_MSVC=$(OMDEVMSYS)/lib/3rdParty/boost-1_59/) + $(eval BOOST_PATH_MSVC=$$(OMDEV)/lib/3rdParty/boost-1_59/) endif else $(eval VSCOMNTOOLS=$(VS140COMNTOOLS)) - $(eval BOOST_PATH_MSVC=$(OMDEVMSYS)/lib/3rdParty/boost-1_59/) + $(eval BOOST_PATH_MSVC=$$(OMDEV)/lib/3rdParty/boost-1_59/) $(eval VCVARS_PARAMS='x86 8.1') endif else @@ -166,17 +183,21 @@ ifeq ($(VSVERSION),2012) else ifeq ($(VSVERSION),2013) $(eval VSCOMNTOOLS=$(VS120COMNTOOLS)) - $(eval BOOST_PATH_MSVC=$(OMDEVMSYS)/lib/3rdParty/boost-1_59/) + $(eval BOOST_PATH_MSVC=$$(OMDEV)/lib/3rdParty/boost-1_59/) else ifeq ($(VSVERSION),2015) $(eval VSCOMNTOOLS=$(VS140COMNTOOLS)) - $(eval BOOST_PATH_MSVC=$(OMDEVMSYS)/lib/3rdParty/boost-1_59/) + $(eval BOOST_PATH_MSVC=$$(OMDEV)/lib/3rdParty/boost-1_59/) $(eval VCVARS_PARAMS='x86 8.1') endif endif endif endif endif + echo 'VSCOMNTOOLS:$(VSCOMNTOOLS)/' + echo 'VCVARS_PARAMS: $(VCVARS_PARAMS)/' + echo 'BOOST_PATH_MSVC: $(BOOST_PATH_MSVC)/' + echo 'OMDEV: $(OMDEV)/' revision: @@ -209,7 +230,8 @@ endif settings: @echo Building OMC using OMDev with the following settings... - @echo Using OMDev: $(OMDEVMSYS) + @echo Using OMDev: $(OMDEV) + @echo Using OMDev_MSYS: $(OMDEV_MSYS) @echo Using Files: $(OMC_BUILD_FROM) @echo Using Path : '$(PATH)' @echo Current directory: `pwd` @@ -232,69 +254,35 @@ testlogwindows: omdev_extra_dlls: echo Copying needed .dlls to the $(OMBUILDDIR)/bin directory ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) - # build 32 bit libOpenCL.a - test ! -f $(WROOT)/SysWOW64/OpenCL.dll || gendef - $(WROOT)/SysWOW64/OpenCL.dll > $(builddir_lib)/omc/OpenCL.def || true - test ! -f $(WROOT)/SysWOW64/OpenCL.dll || dlltool -l $(builddir_lib)/omc/libOpenCL.a -d $(builddir_lib)/omc/OpenCL.def -A -k || true - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libgomp-1.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libwinpthread*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libtre-5.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libsystre-0.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libstdc++-6.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libquadmath-0.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libgcc_s_dw2-1.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libintl-8.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libiconv-2.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libgfortran*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libexpat-1.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libopenblas.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/zlib1.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libszip*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libhdf5-0.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libp11-kit*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libffi*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw32/bin/x86_win32/omniORB420_rt.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw32/bin/x86_win32/omnithread40_rt.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw32/bin/x86_win32/omniORB420_rt.dll $(builddir_lib)/omc/) - (cp -puf $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw32/bin/x86_win32/omnithread40_rt.dll $(builddir_lib)/omc/) - (cp -puf $(OMDEVMSYS)/lib/3rdParty/Sundials/lib/release/mingw/libsundials_kinsol.a $(builddir_lib)/omc/) - (cp -puf $(OMDEVMSYS)/lib/3rdParty/Sundials/lib/release/mingw/libsundials_nvecserial.a $(builddir_lib)/omc/) - test ! -f $(OMDEVMSYS)/tools/msys/mingw32/bin/libnghttp2-14.dll || cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libnghttp2-14.dll $(builddir_bin)/ - test ! -f $(OMDEVMSYS)/tools/msys/mingw32/bin/libunistring-2.dll || cp -puf $(OMDEVMSYS)/tools/msys/mingw32/bin/libunistring-2.dll $(builddir_bin)/ -else # mingw64 + $(error "No 32-bit support") +else # 64-bit MSYS # build 64 bit libOpenCL.a test ! -f $(WROOT)/system32/OpenCL.dll || gendef - $(WROOT)/system32/OpenCL.dll > $(builddir_lib)/omc/OpenCL.def || true test ! -f $(WROOT)/system32/OpenCL.dll || dlltool -l $(builddir_lib)/omc/libOpenCL.a -d $(builddir_lib)/omc/OpenCL.def -A -k || true - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libgomp-1.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libwinpthread*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libtre-5.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libsystre-0.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libstdc++-6.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libquadmath-0.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libgcc_s_seh-1.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libintl-8.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libiconv-2.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libgfortran*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libexpat-1.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libopenblas.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/zlib1.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libszip*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libhdf5-0.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libp11-kit*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libffi*.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/omniORB420_rt.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/omnithread40_rt.dll $(builddir_bin)/) - (cp -puf $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/omniORB420_rt.dll $(builddir_lib)/omc/) - (cp -puf $(OMDEVMSYS)/lib/omniORB-4.2.0-mingw64/bin/x86_win32/omnithread40_rt.dll $(builddir_lib)/omc/) - (cp -puf $(OMDEVMSYS)/lib/3rdParty/Sundials64/lib/release/mingw/libsundials_kinsol.a $(builddir_lib)/omc/) - (cp -puf $(OMDEVMSYS)/lib/3rdParty/Sundials64/lib/release/mingw/libsundials_nvecserial.a $(builddir_lib)/omc/) - test ! -f $(OMDEVMSYS)/tools/msys/mingw64/bin/libnghttp2-14.dll || cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libnghttp2-14.dll $(builddir_bin)/ - test ! -f $(OMDEVMSYS)/tools/msys/mingw64/bin/libunistring-2.dll || cp -puf $(OMDEVMSYS)/tools/msys/mingw64/bin/libunistring-2.dll $(builddir_bin)/ + + # This is rediculus! Just use CMake to install dependencies instead of copying random DLLs. + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libexpat-1.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libffi*.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libgcc_s_seh-1.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libgfortran*.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libgomp-1.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libhdf5-*.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libiconv-2.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libintl-8.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libopenblas.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libp11-kit*.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libquadmath-0.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libstdc++-6.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libsystre-0.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libszip*.dll $(builddir_bin)/) || (cp -puf $(OM_MSYS_ENV_DIR)/bin/libsz.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libtre-5.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/libwinpthread*.dll $(builddir_bin)/) + (cp -puf $(OM_MSYS_ENV_DIR)/bin/zlib1.dll $(builddir_bin)/) + + test ! -f $(OM_MSYS_ENV_DIR)/bin/libnghttp2-14.dll || cp -puf $(OM_MSYS_ENV_DIR)/bin/libnghttp2-14.dll $(builddir_bin)/ + test ! -f $(OM_MSYS_ENV_DIR)/bin/libunistring-2.dll || cp -puf $(OM_MSYS_ENV_DIR)/bin/libunistring-2.dll $(builddir_bin)/ endif - (cp -pf $(OMDEVMSYS)/lib/lapack-win32-msvc/blas_win32_MT.dll $(builddir_bin)/) - (cp -pf $(OMDEVMSYS)/lib/lapack-win32-msvc/lapack_win32_MT.dll $(builddir_bin)/) mkdir -p $(builddir_lib)/omc/libexec/ - (cp -pufr $(OMDEVMSYS)/tools/xsltproc $(builddir_lib)/omc/libexec/) - (cp -pufr $(OMDEVMSYS)/tools/gnuplot $(builddir_lib)/omc/libexec/) copycppmsvcheader: getMSVCversion echo Copying needed header files to the $(OMBUILDDIR)/include/omc/omsicpp/ directory @@ -332,7 +320,7 @@ $(LIBMODELICAZLIB_MSVC): getMSVCversion echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> $(ZLIB_DIR)/build_msvc/build.bat # Change into directory and run batch file cd ./$(ZLIB_DIR)/build_msvc; echo "change to $(ZLIB_DIR)/build_msvc";\ - cmd /c build.bat + cmd "/c build.bat" # copy dll to bin folder (cp -puf $(ZLIB_DIR)/install_msvc/lib/omc/zlib.lib $(OMBUILDDIR)/lib/omc/msvc/) @@ -361,7 +349,7 @@ $(OMBUILDDIR)/bin/msvc/fmilib_shared.dll: getMSVCversion zlib_msvc # Change into directory and run batch file cd ./3rdParty/FMIL/build_msvc; echo "change to 3rdParty/FMIL/build_msvc";\ - cmd /c build.bat + cmd "/c build.bat" # copy dll to bin folder mkdir -p $(OMBUILDDIR)/bin/msvc @@ -397,7 +385,7 @@ $(OMBUILDDIR)/lib/omc/msvc/cminpack.lib: getMSVCversion echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> 3rdParty/CMinpack/build_msvc/build.bat # Change into directory and run batch file cd ./3rdParty/CMinpack/build_msvc; echo "change to 3rdParty/CMinpack/build_msvc";\ - cmd /c build.bat + cmd "/c build.bat" # copy dll to bin folder (cp -puf 3rdParty/CMinpack/install_msvc/lib/cminpack.lib $(OMBUILDDIR)/lib/omc/msvc/) @@ -430,7 +418,7 @@ $(OMBUILDDIR)/lib/omc/msvc/umfpack.lib: getMSVCversion 3rdParty/SuiteSparse-5.8. # Change into directory and run batch file cd ./3rdParty/SuiteSparse-5.8.1/build_msvc; echo "change to 3rdParty/SuiteSparse-5.8.1/build_msvc";\ - cmd /c build.bat + cmd "/c build.bat" # build sundials # TODO: We need suitesparse_msvc as a dependency, but Make doesn't wait for suitesparse_msvc to be finishes @@ -466,7 +454,7 @@ $(OMBUILDDIR)/lib/omc/msvc/sundials_ida.dll: getMSVCversion 3rdParty/sundials-5. echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> 3rdParty/sundials-5.4.0/build_msvc/build.bat # Change into directory and run batch file cd ./3rdParty/sundials-5.4.0/build_msvc; echo "change to 3rdParty/sundials-5.4.0/build_msvc";\ - cmd /c build.bat + cmd "/c build.bat" # copy dll to lib and bin folder mkdir -p $(OMBUILDDIR)/include/omc/msvc/sundials (cp -pufr 3rdParty/sundials-5.4.0/build_msvc/include/* $(OMBUILDDIR)/include/omc/msvc/sundials) @@ -477,7 +465,7 @@ $(OMBUILDDIR)/lib/omc/msvc/sundials_ida.dll: getMSVCversion 3rdParty/sundials-5. omcCAPImsvcinstall: $(MAKE) -C SimulationRuntime/OMSICpp/ -f Makefile.omdev.mingw omcCAPImsvc OMBUILDDIR=$(OMBUILDDIR) -runtimeCPPmsvcinstall_old: +runtimeCPPmsvcinstall_old: getMSVCversion $(MAKE) -C SimulationRuntime/cpp/ -f Makefile.omdev.mingw runtimeCPPmsvc OMBUILDDIR=$(OMBUILDDIR) cp -p $(BOOST_PATH_MSVC)/lib/*vc*.dll $(OMBUILDDIR)/bin/ cp -p $(BOOST_PATH_MSVC)/lib/*vc*.lib $(OMBUILDDIR)/lib/omc/cpp/msvc @@ -520,7 +508,7 @@ simulationruntimecmsvc: getMSVCversion CMinpack_msvc fmil_msvc echo set MAKE= >> SimulationRuntime/build_c/build.bat echo set MAKEFLAGS= >> SimulationRuntime/build_c/build.bat echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile >> SimulationRuntime/build_c/build.bat - cd SimulationRuntime/build_c && cmd /c build.bat + cd SimulationRuntime/build_c && cmd "/c build.bat" echo 'Copy the .lib files (needed for compilation) and .pdb files (needed for debugging) to $(OMBUILDDIR)/lib/omc' (cd SimulationRuntime/build_c/ && find . -type f -path "*.lib" -exec cp {} $(OMBUILDDIR)/lib/omc/msvc/release/. \;) (cd SimulationRuntime/build_c/ && find . -type f -path "*.pdb" -exec cp {} $(OMBUILDDIR)/lib/omc/msvc/release/. \;) @@ -534,21 +522,21 @@ simulationruntimecmsvc: getMSVCversion CMinpack_msvc fmil_msvc echo set MAKE= >> SimulationRuntime/build_debug_c/build.bat echo set MAKEFLAGS= >> SimulationRuntime/build_debug_c/build.bat echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile >> SimulationRuntime/build_debug_c/build.bat - cd SimulationRuntime/build_debug_c && cmd /c build.bat + cd SimulationRuntime/build_debug_c && cmd "/c build.bat" echo 'Copy the .lib files (needed for compilation) and .pdb files (needed for debugging) to $(OMBUILDDIR)/lib/omc' (cd SimulationRuntime/build_debug_c/ && find . -type f -path "*.lib" -exec cp {} $(OMBUILDDIR)/lib/omc/msvc/debug/. \;) (cd SimulationRuntime/build_debug_c/ && find . -type f -path "*.pdb" -exec cp {} $(OMBUILDDIR)/lib/omc/msvc/debug/. \;) rm -rf SimulationRuntime/build_debug_c/ echo 'Copy the needed .lib/.dll files from OMDev to $(OMBUILDDIR)/lib/omc' - cp -p $(OMDEVMSYS)/lib/libf2c/*.lib $(OMBUILDDIR)/lib/omc/msvc/release/ - cp -p $(OMDEVMSYS)/lib/libf2c/debug/*.lib $(OMBUILDDIR)/lib/omc/msvc/debug/ - cp -p $(OMDEVMSYS)/lib/expat-win32-msvc/*.lib $(OMBUILDDIR)/lib/omc/msvc/ - cp -p $(OMDEVMSYS)/lib/lapack-win32-msvc/*.lib $(OMBUILDDIR)/lib/omc/msvc/ - cp -p $(OMDEVMSYS)/lib/lis/*.lib $(OMBUILDDIR)/lib/omc/msvc/ - cp -p $(OMDEVMSYS)/lib/pthread/*.* $(OMBUILDDIR)/lib/omc/msvc/ - cp -p $(OMDEVMSYS)/include/pthread/*.* $(OMBUILDDIR)/include/omc/msvc/ + cp -p $(OMDEV)/lib/libf2c/*.lib $(OMBUILDDIR)/lib/omc/msvc/release/ + cp -p $(OMDEV)/lib/libf2c/debug/*.lib $(OMBUILDDIR)/lib/omc/msvc/debug/ + cp -p $(OMDEV)/lib/expat-win32-msvc/*.lib $(OMBUILDDIR)/lib/omc/msvc/ + cp -p $(OMDEV)/lib/lapack-win32-msvc/*.lib $(OMBUILDDIR)/lib/omc/msvc/ + cp -p $(OMDEV)/lib/lis/*.lib $(OMBUILDDIR)/lib/omc/msvc/ + cp -p $(OMDEV)/lib/pthread/*.* $(OMBUILDDIR)/lib/omc/msvc/ + cp -p $(OMDEV)/include/pthread/*.* $(OMBUILDDIR)/include/omc/msvc/ echo 'Copy the needed .dll files from OMDev to $(OMBUILDDIR)/omc' - cp -p $(OMDEVMSYS)/lib/pthread/pthreadV*.dll $(OMBUILDDIR)/bin/ + cp -p $(OMDEV)/lib/pthread/pthreadV*.dll $(OMBUILDDIR)/bin/ # build gc as well, as it is needed for the msvc c runtime # echo 'Build gc (RelWithDebInfo)' # mkdir -p 3rdParty/gc/build_msvc @@ -559,7 +547,7 @@ simulationruntimecmsvc: getMSVCversion CMinpack_msvc fmil_msvc # echo set MAKE= >> 3rdParty/gc/build_msvc/build.bat # echo set MAKEFLAGS= >> 3rdParty/gc/build_msvc/build.bat # echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile >> 3rdParty/gc/build_msvc/build.bat - # cd 3rdParty/gc/build_msvc && cmd /c build.bat + # cd 3rdParty/gc/build_msvc && cmd "/c build.bat" # echo 'Copy the .lib files (needed for compilation) and .pdb files (needed for debugging) to $(OMBUILDDIR)/lib/omc/msvc/' # cp -u 3rdParty/gc/build_msvc/omcgc.* $(OMBUILDDIR)/lib/omc/msvc/ # rm -rf 3rdParty/gc/build_msvc/ diff --git a/OMCompiler/README.Windows.md b/OMCompiler/README.Windows.md index cef23567c87..398cfdd76f1 100644 --- a/OMCompiler/README.Windows.md +++ b/OMCompiler/README.Windows.md @@ -2,11 +2,12 @@ ## Table of content -- [1 OMDev Package](#1-omdev-package) +- [1 MSYS Environments](#1-msys-environments) - [1.1 General Notes](#11-general-notes) - - [1.2 Install OMDev](#12-install-omdev) - - [1.3 Install Additional Programs](#13-install-additional-programs) - - [1.4 Environment Variables](#14-environment-variables) + - [1.2 Install OMDev packages](#12-install-omdev) + - [1.3 Install MSYS2](#13-install-msys2) + - [1.4 Install Additional Programs](#14-install-additional-programs) + - [1.5 Environment Variables](#15-environment-variables) - [2 Compile OpenModelica](#2-compile-openmodelica) - [2.1 MSYS and CMake](#21-msys-and-cmake) - [2.2 MSYS and Make](#22-msys-and-make) @@ -14,23 +15,37 @@ - [4 Test Suite](#4-test-suite) - [5 Troubleshooting](#5-troubleshooting) -# 1 OMDev Package +# 1 MSYS Environments + +We use Linux tools provided by [MSYS2](https://www.msys2.org/) to compile OpenModelica on +Windows. + +You can install MSYS2 with UCRT64 yourself or use OMDev with an MSYS2 installation and +fixed package versions. If you are unsure what to pick or are building OpenModelica for +the first time use OMDev. + +> [!NOTE] +> If you have an older version of OMDev installed it's best to delete `OMDev` and start +> with a fresh clone following the below instructions. + + 1. OMDev package: MSYS2 with + [UCRT64 environment](https://www.msys2.org/docs/environments/). + Follow the instructions in [1.2 Install OMDev](#12-install-omdev). + 2. Installed [MSYS2](https://www.msys2.org/) with + [UCRT64 environment](https://www.msys2.org/docs/environments/). + Follow the instructions in [1.3 Install MSYS2](#13-install-msys2). -We use Linux tools to compile OpenModelica on Windows. For that you'll need to install the -OMDev package contains all prerequisites to compile OMC on Windows using -msys2, mingw32 and mingw64. ## 1.1 General Notes - Install Git for Windows https://git-scm.com/downloads + Do not install git using pacman in MSYS, it does not work correctly! - Make sure you git clone with the correct line endings, run in a (Git Bash) terminal: ```bash git config --global core.eol lf git config --global core.autocrlf input ``` - - Do not install git using pacman in msys, it does not work correctly! - ## 1.2 Install OMDev - Clone OMDev into a directory without any spaces in the path. We recommend to use @@ -39,49 +54,66 @@ msys2, mingw32 and mingw64. Run the following in a Git Bash: ```bash cd /c/ - git clone https://openmodelica.org/git/OMDev.git + git clone --depth 1 -b master --single-branch https://gitlab.liu.se/OpenModelica/OMDevUCRT.git OMDev ``` - Define a Windows environment variable `OMDEV` pointing to the OMDev directory. - Restart or logiut/login to make it available. + Restart or logout/login to make it available. - - Follow the instructions in the `C:\OMDev\INSTALL.txt` file. + - Follow the instructions in the `%OMDEV%\INSTALL.md` file. -If you encounter issues with OpenModelica compilation try updating OMDev (git pull). +## 1.4 Install Additional Programs -## 1.3 Install Additional Programs +Install the following programs: -Install the following programms and add them to your MSYS `PATH` + - [Git](https://git-scm.com/downloads) (should already be installed) + - [Java SE Development Kit](https://www.oracle.com/java/technologies/downloads/) (for javac) + - [TortoiseSVN](https://tortoisesvn.net/), SVN tool for Windows + - [CMake](https://cmake.org/download/) (>= v3.21) - - Git (should alread be installed) - - Java SE Development Kit (for javac) - - TortoiseSVN, SVN tool for Windows +## 1.5 Environment Variables -## 1.4 Environment Variables +Export the path to your tools: git, svn, java/javac and cmake. +Define environment variables pointing to your OMDev directory as well as the MSYS2 +root directory. -Start `$OMDEV\tools\msys\mingw64.exe` or `$OMDEV\tools\msys\mingw32.exe` and run: +> [!NOTE] +> Use Linux like path. E.g. `C:\Program Files\Git\bin` becomes `/c/Program Files/Git/bin` ```bash -# export the path to your tools: git, svn, java/javac -# note: if you have a space in your path to your tool you need to escape it, i.e.: /c/Program\ Files -export PATH=$PATH:/c/path/to/git/bin:/c/path/to/svn/tools/bin:/c/path/to/jdk/bin -export OPENMODELICAHOME="C:\\path\\to\\OpenModelica\\build" -export OPENMODELICALIBRARY="C:\\Users\\\\AppData\\Roaming\\.openmodelica\\libraries" +export PATH=$PATH:/c/path/to/git/bin:/c/path/to/svn/tools/bin:/c/path/to/jdk/bin:/c/path/to/cmake/bin +export OPENMODELICAHOME="/c/path/to/OpenModelica/build" +export OPENMODELICALIBRARY="/c/Users//AppData/Roaming/.openmodelica/libraries" +export OMDEV="/c/OMDev" ``` + You can add this to your `.bashrc` file -(usually in `C:\OMDev\tools\msys\home\\.bashrc`), to always have them in your +(usually in `%OMDEV%\tools\msys\home\\.bashrc`), to always have them in your `PATH`. +Additional remarks: + + - MSYS doesn't use the Windows PATH variable. + If you want to use it define a Windows environment variable called + `MSYS2_PATH_TYPE=inherit`. + But be very careful you don't have any MINGW directories in you Windows PATH, e.g. + coming from Git. + - MSYS doesn't use the Windows TEMP directory but `C:\OMDev\tools\msys\tmp` + You change this in `C:\OMDev\tools\msys\etc\profile`, but it can have unexpected side effects. + - If you want to use the msys shell from Windows command line make sure you set + environment variable `MSYSTEM=UCRT64` or call `C:\OMDev\tools\msys\ucrt64.exe`. + # 2 Compile OpenModelica -You can use msys2+mingw32 or msys2+mingw64 with the Makefiles or CMake. +You can use MSYS2 with environment UCRT64 with the Makefiles or CMake. It's also possible to build with Eclipse using the Makefiles. Follow the instructions in [MSYS and Make](#21-msys-and-make) or [Eclipse](#22-eclipse). ## 2.1 MSYS and CMake -Check [README.cmake.md](../README.cmake.md) for details, but in a nutshell start a MSYS -shell `$OMDEV\tools\msys\mingw64.exe` and run the following: +Check [README.cmake.md](../README.cmake.md) for details, but in a nutshell start a MSYS2 +shell `C:\OMDev\tools\msys\ucrt64.exe` (UCRT64) or `C:\OMDev\tools\msys\mingw64.exe` +(MINGW64) and run the following: ```bash cd /path/to/OpenModelica @@ -93,8 +125,8 @@ make -j install -Oline ## 2.2 MSYS and Make -Start MSYS terminal `$OMDEV\tools\msys\mingw64.exe` (64 bit) or -`$OMDEV\tools\msys\mingw32.exe` (32 bit) and run: +Start `C:\OMDev\tools\msys\ucrt64.exe` (UCRT64) or `C:\OMDev\tools\msys\mingw64.exe` +(MINGW64) and run: ```bash cd /path/to/OpenModelica @@ -102,8 +134,6 @@ cd /path/to/OpenModelica # build omc using number of cores, replace by your number of cores make -f Makefile.omdev.mingw -j -# to build the QT clients make sure you ran \path\to\OMDEV\SETUP_OMDEV_Qt5.bat first - # if you want to build only omedit then run: make -f Makefile.omdev.mingw -j omedit @@ -114,7 +144,8 @@ make -f Makefile.omdev.mingw -j qtclients # 3 Installer To build the OpenModelica releases and installer the Makefiles build and NSIS is used. -If you need to know more checkout [OpenModelicaSetup/BuildWindowsRelease.sh](https://github.com/OpenModelica/OpenModelicaSetup#readme) +If you need to know more checkout +[OpenModelicaSetup/BuildWindowsRelease.sh](https://github.com/OpenModelica/OpenModelicaSetup#readme) # 4 Test Suite @@ -137,15 +168,13 @@ cd testsuite/partests If something does not work check the following: -1. Is OMDev installed into `C:\OMDev`? - - Be sure you have directories `tools`, `bin` and `include` in `C:\OMDev`. - - Is environment variable `OMDEV` defined and pointing to it? - Right Click on My Computer->Properties->Advanced Tab->Environment Variables. - Add variable `OMDEV` and set the text to `C:\OMDev`. - Restarted or logout/login from Windows to make it available. - -For problems with OMDev package, contact Adrian Pop, adrian.pop@liu.se +1. Is OMDev removed? + We switched from a shipped version of OMDev containing an outdated version of MSYS2 + with MINGW64 to a user installed version of MSYS2 with UCRT64 environment. + They are not compatible. You need to re-configure and re-build everything. Throw in a + git clean for good measure (be aware that this can remove everything that isn't + committed...). -------------- -Last updated 2023-02-13. +Last updated 2023-08-11. diff --git a/OMCompiler/SimulationRuntime/OMSI/Makefile.omdev.mingw b/OMCompiler/SimulationRuntime/OMSI/Makefile.omdev.mingw index 65b2ec02b30..d6b481b2797 100644 --- a/OMCompiler/SimulationRuntime/OMSI/Makefile.omdev.mingw +++ b/OMCompiler/SimulationRuntime/OMSI/Makefile.omdev.mingw @@ -16,11 +16,13 @@ LIB_OMC=lib/omc OMBUILDDIR_WIN=$(shell cygpath -w $$OMBUILDDIR) -#use this call to use precompiled headers -#use this call if you want to debug the cpp runtime -CMAKE = $(OMDEVMSYS)/bin/cmake/bin/cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON +CMAKE = cmake # this doesn't seem to work: $(where cmake) -OMDEVMSYS=$(shell cygpath $$OMDEV) +ifndef OMDEV + @echo You have to set the OMDEV variabile pointing to your OMDev package root! Exiting.... + @echo See OpenModelica/OMCompiler/README.Windows.md + ABORT +endif ifeq ($(BUILDTYPE),) BUILDTYPE=$(BuildType) @@ -29,13 +31,7 @@ ifeq ($(BUILDTYPE),) BUILDTYPE=Debug endif -ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) - IS_MINGW32 = -DIS_MINGW32=ON - IS_MINGW64 = -DIS_MINGW64=OFF -else - IS_MINGW32 = -DIS_MINGW32=OFF - IS_MINGW64 = -DIS_MINGW64=ON -endif +IS_MINGW64 = -DIS_MINGW64=ON BOOST_STATIC_LINKING="false" ifeq ($(BOOST_STATIC_LINKING),"true") @@ -146,12 +142,12 @@ OMSIBaseMSVC: getMSVCversion #rm -rf Build_MSVC mkdir -p Build_MSVC echo call '"${VSCOMNTOOLS}\\..\\..\\VC\\vcvarsall.bat" ${VCVARS_PARAMS}' > Build_MSVC/build.bat - echo echo Running CMake from '%OMDEV%\\bin\\cmake\\bin\\cmake' for OMSI base build >> Build_MSVC/build.bat - echo '%OMDEV%\\bin\\cmake\\bin\\cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DPLATFORM="static" $(CMAKE_FLAGS) -DIS_MINGW32=OFF -DIS_MINGW64=OFF -DCMAKE_INSTALL_PREFIX:PATH=./tmp -DLIB_OMC=$(LIB_OMC) -DOMBUILDDIR=$(OMBUILDDIR) -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe" ../' >> Build_MSVC/build.bat + echo echo Running CMake from '$(CMAKE)' for OMSI base build >> Build_MSVC/build.bat + echo '$(CMAKE) -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DPLATFORM="static" $(CMAKE_FLAGS) -DIS_MINGW32=OFF -DIS_MINGW64=OFF -DCMAKE_INSTALL_PREFIX:PATH=./tmp -DLIB_OMC=$(LIB_OMC) -DOMBUILDDIR=$(OMBUILDDIR) -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe" ../' >> Build_MSVC/build.bat # for some reason, the environment variable 'MAKEFLAGS' was set to 'w' on my and Niklas' machine?! echo set MAKEFLAGS="" >> Build_MSVC/build.bat echo echo Running NMake JOM >> Build_MSVC/build.bat echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> Build_MSVC/build.bat - cd ./Build_MSVC && cmd /c build.bat + cd ./Build_MSVC && cmd "/c build.bat" diff --git a/OMCompiler/SimulationRuntime/OMSI/solver/CMakeLists.txt b/OMCompiler/SimulationRuntime/OMSI/solver/CMakeLists.txt index 7ba36c96dcd..a608801bb41 100644 --- a/OMCompiler/SimulationRuntime/OMSI/solver/CMakeLists.txt +++ b/OMCompiler/SimulationRuntime/OMSI/solver/CMakeLists.txt @@ -13,16 +13,9 @@ GET_FILENAME_COMPONENT(OMCTRUNCHOME "${OMCTRUNCHOME}" ABSOLUTE) ############################ # Find BLAS and LAPACK ############################ -IF(IS_MINGW32) - SET(LAPACK_MINGW $ENV{OMDEV}/tools/msys/mingw32/bin/libopenblas.dll) - SET(LAPACK_LIBRARIES ${LAPACK_MINGW}) -ELSEIF(IS_MINGW64) - SET(LAPACK_MINGW $ENV{OMDEV}/tools/msys/mingw64/bin/libopenblas.dll) - SET(LAPACK_LIBRARIES ${LAPACK_MINGW}) -ELSE() - FIND_PACKAGE(BLAS) - FIND_PACKAGE(LAPACK) -ENDIF() + +FIND_PACKAGE(BLAS) +FIND_PACKAGE(LAPACK) IF (BLAS_FSOUND STREQUAL "NOTFOUND") MESSAGE(FATAL_ERROR "Error: Blas Libraries not found!") diff --git a/OMCompiler/SimulationRuntime/OMSICpp/CMakeLists.txt b/OMCompiler/SimulationRuntime/OMSICpp/CMakeLists.txt index 2b1458f211b..d89186635f5 100644 --- a/OMCompiler/SimulationRuntime/OMSICpp/CMakeLists.txt +++ b/OMCompiler/SimulationRuntime/OMSICpp/CMakeLists.txt @@ -166,7 +166,7 @@ SET(LibZName zlib) # only static version SET(SimulationSettings ${LIBPREFIX}SimulationSettings${LIBSUFFIX}) SET(SimControllerName ${LIBPREFIX}SimController${LIBSUFFIX}) SET(CVodeName ${LIBPREFIX}CVode${LIBSUFFIX}) -SET(ARKodeName ${LIBPREFIX}ARKode${LIBSUFFIX}) +#SET(ARKodeName ${LIBPREFIX}ARKode${LIBSUFFIX}) SET(IDAName ${LIBPREFIX}IDA${LIBSUFFIX}) SET(PeerName ${LIBPREFIX}Peer${LIBSUFFIX}) SET(CppDASSLName ${LIBPREFIX}CppDASSL${LIBSUFFIX}) @@ -322,31 +322,41 @@ ENDIF(OMC_BUILD) # - On windows boost,blas,lapack and sundial solvers from omdev are used else the installed versions are used IF(WIN32) SET(Boost_DEBUG 1) - MESSAGE(STATUS "MINGW:") - MESSAGE(STATUS ${IS_MINGW32}) MESSAGE(STATUS ${IS_MINGW64}) - IF(IS_MINGW32) - SET(BOOST_ROOT $ENV{OMDEV}"/tools/mingw32/") - ELSEIF(IS_MINGW64) - SET(BOOST_ROOT $ENV{OMDEV}"/tools/mingw64/") - ELSE() - if(MSVC_VERSION GREATER 1800) - MESSAGE(STATUS "USE MSVC 2015 and greater:") - #SET(Boost_COMPILER "-vc142") - SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_59/") - #SET(Boost_COMPILER "-vc142") - elseif(MSVC_VERSION GREATER 1700) - SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_59/") - else() - SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_55/") - endif() + + # Check environment variables + if(NOT DEFINED ENV{OMDEV}) + message(FATAL_ERROR "Environment variable \"OMDEV\" is not set.") + endif() + if(NOT DEFINED ENV{MSYSTEM_PREFIX}) + message(FATAL_ERROR "Environment variable \"MSYSTEM_PREFIX\" is not set.") + endif() + string(REPLACE "\\" "/" OMDEV_ESCAPED "$ENV{OMDEV}") + string(REPLACE "\\" "/" OMDEV_MSYS_ESCAPED "$ENV{OMDEV}/tools/msys") + string(REPLACE "\\" "/" MSYSTEM_PREFIX_ESCAPED "$ENV{MSYSTEM_PREFIX}") + + if(IS_MINGW64) + SET(BOOST_ROOT ${MSYSTEM_PREFIX_ESCAPED}) + elseif(IS_MINGW632) + MESSAGE(FATAL_ERROR "32-bit version not supported") + else() + if(MSVC_VERSION GREATER 1800) + MESSAGE(STATUS "USE MSVC 2015 and greater:") + #SET(Boost_COMPILER "-vc142") + SET(BOOST_ROOT ${OMDEV_ESCAPED}"/lib/3rdParty/boost-1_59/") + #SET(Boost_COMPILER "-vc142") + elseif(MSVC_VERSION GREATER 1700) + SET(BOOST_ROOT ${OMDEV_ESCAPED}"/lib/3rdParty/boost-1_59/") + else() + SET(BOOST_ROOT ${OMDEV_ESCAPED}"/lib/3rdParty/boost-1_55/") + endif() ENDIF(IS_MINGW32) MESSAGE(STATUS "Boost root for omsicpp runtime:") MESSAGE(STATUS ${BOOST_ROOT} ) - SET(BLAS_blas_LIBRARY $ENV{OMDEV}/lib/3rdParty/Lapack/Lib/blas_win32.dll CACHE FILEPATH "Blas library") - SET(LAPACK_lapack_LIBRARY $ENV{OMDEV}/lib/3rdParty/Lapack/Lib/lapack_win32.dll CACHE FILEPATH "Lapack library") - SET(BLAS_DIRY "$ENV{OMDEV}/lib/3rdParty/Lapack/Lib/" CACHE LOCATION "where was yarp built?") + SET(BLAS_blas_LIBRARY ${OMDEV_ESCAPED}/lib/3rdParty/Lapack/Lib/blas_win32.dll CACHE FILEPATH "Blas library") + SET(LAPACK_lapack_LIBRARY ${OMDEV_ESCAPED}/lib/3rdParty/Lapack/Lib/lapack_win32.dll CACHE FILEPATH "Lapack library") + SET(BLAS_DIRY "${OMDEV_ESCAPED}/lib/3rdParty/Lapack/Lib/" CACHE LOCATION "where was yarp built?") # Disable Optimization for RelWithDebInfo on Windows IF(MSVC) @@ -357,8 +367,8 @@ IF(WIN32) ENDIF(MSVC) #set mico paths - SET(MICO_LIB_HOME $ENV{OMDEV}/lib/mico-msys-mingw/) - SET(MICO_INCLUDE_HOME $ENV{OMDEV}/include/mico-msys-mingw/) + SET(MICO_LIB_HOME ${OMDEV_ESCAPED}/lib/mico-msys-mingw/) + SET(MICO_INCLUDE_HOME ${OMDEV_ESCAPED}/include/mico-msys-mingw/) SET(INSTALL_OMDEV_LIBS OFF) ENDIF(WIN32) @@ -438,6 +448,13 @@ ENDIF(PAPI_FOUND) # Find Boost +# If MSVC, we do not want to use MSYS/MingGW installed boost's CMake config files for locating Boost +# We have a manually provided boost already specified using BOOST_ROOT. +# This is essentialy saying we do not want any help from boost itself in finding its libraries and setup. +# Let CMake do it alone the old way by just finding the files it knows. +IF(MSVC) + SET(Boost_NO_BOOST_CMAKE ON) +ENDIF(MSVC) # - The optional boost libraries must be searched separately, otherwise no library is found if just one is missing. # - Additionaly the Boost_LIBRARIES variable is overwritten each time find_package(Boost ...) is called, thus it must be rescued FIND_PACKAGE(Boost COMPONENTS log log_setup) @@ -495,28 +512,16 @@ MESSAGE(STATUS "Boost Libraries for omsicpp runtime") MESSAGE(STATUS ${Boost_LIBRARIES}) # Find Lapack and Blas -FIND_PACKAGE(BLAS) -FIND_PACKAGE(LAPACK) - IF(MSVC) #workaround because cmake does not find the lapack libraries for Visual Studio 10 - SET(LAPACK_MSVC_10 $ENV{OMDEV}/lib/3rdParty/Lapack/Lib/lapack_win32.lib ) - SET(BLAS_MSVC_10 $ENV{OMDEV}/lib/3rdParty/Lapack/Lib/blas_win32.lib ) + SET(LAPACK_MSVC_10 ${OMDEV_ESCAPED}/lib/3rdParty/Lapack/Lib/lapack_win32.lib ) + SET(BLAS_MSVC_10 ${OMDEV_ESCAPED}/lib/3rdParty/Lapack/Lib/blas_win32.lib ) SET(LAPACK_LIBRARIES ${LAPACK_MSVC_10} ${BLAS_MSVC_10} ) -ELSEIF(IS_MINGW32) - SET(LAPACK_MINGW $ENV{OMDEV}/tools/msys/mingw32/bin/libopenblas.dll ) - SET(LAPACK_LIBRARIES ${LAPACK_MINGW} ) -ELSEIF(IS_MINGW64) - SET(LAPACK_MINGW $ENV{OMDEV}/tools/msys/mingw64/bin/libopenblas.dll ) - SET(LAPACK_LIBRARIES ${LAPACK_MINGW} ) +ELSE() + FIND_PACKAGE(BLAS) + FIND_PACKAGE(LAPACK) ENDIF(MSVC) -FIND_LIBRARY(mkl_rt mkl_rt) -IF (mkl_rt) - #workaround because find_package(lapack)-command returns the wrong libraries on Taurus (ZIH-TU Dresden) - SET(LAPACK_LIBRARIES ${mkl_rt}) -ENDIF(mkl_rt) - LIST(LENGTH LAPACK_LIBRARIES LAPACKVARCOUNT) IF(LAPACKVARCOUNT GREATER 0) LIST(GET LAPACK_LIBRARIES 0 LAPACKLISTHEAD) @@ -524,8 +529,7 @@ IF(LAPACKVARCOUNT GREATER 0) SET(LAPACK_LIBS "${LAPACKLISTHEAD}") ENDIF() -MESSAGE(STATUS "Lapack Libraries") -MESSAGE(STATUS ${LAPACK_LIBRARIES}) +MESSAGE(STATUS "LAPACK Libraries: ${LAPACK_LIBRARIES}") IF(REDUCE_DAE) @@ -706,7 +710,7 @@ IF(USE_OMSI) MESSAGE(STATUS "OSI linear and nonlinear solver interface enabled") #set exapat lib for visual studio compiler used by omsi xml and json parser IF(MSVC) - INCLUDE_DIRECTORIES($ENV{OMDEV}/lib/expat-win32-msvc) + INCLUDE_DIRECTORIES(${OMDEV_ESCAPED}/lib/expat-win32-msvc) ENDIF(MSVC) diff --git a/OMCompiler/SimulationRuntime/OMSICpp/Makefile.omdev.mingw b/OMCompiler/SimulationRuntime/OMSICpp/Makefile.omdev.mingw index b13d33ec83b..802976f1b74 100644 --- a/OMCompiler/SimulationRuntime/OMSICpp/Makefile.omdev.mingw +++ b/OMCompiler/SimulationRuntime/OMSICpp/Makefile.omdev.mingw @@ -18,9 +18,7 @@ OMBUILDDIR_WIN=$(shell cygpath -w $$OMBUILDDIR) #use this call to use precompiled headers #use this call if you want to debug the cpp runtime -CMAKE = $(OMDEVMSYS)/bin/cmake/bin/cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON - -OMDEVMSYS=$(shell cygpath $$OMDEV) +CMAKE = $(OMDEV)/bin/cmake/bin/cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON ifeq ($(BUILDTYPE),) BUILDTYPE=$(BuildType) @@ -147,7 +145,7 @@ runtimeCpp: omcCAPIinstall $(foreach PLATFORM, $(PLATFORMS), \ mkdir -p Build_$(PLATFORM); \ (cd ./Build_$(PLATFORM); echo "change to Build_$(PLATFORM)"; \ - cmake -G "MSYS Makefiles" -DPLATFORM=$(PLATFORM) -DLIB_OMC=$(LIB_OMC) $(CMAKE_FLAGS) $(IS_MINGW32) $(IS_MINGW64) -DCMAKE_INSTALL_PREFIX:PATH="$(OMBUILDDIR)" MAKE_CXX_COMPILER=g++ ../; \ + cmake -G "MSYS Makefiles" -DPLATFORM=$(PLATFORM) -DLIB_OMC=$(LIB_OMC) $(CMAKE_FLAGS) $(IS_MINGW32) $(IS_MINGW64) -DCMAKE_INSTALL_PREFIX:PATH="$(OMBUILDDIR)" ../; \ $(MAKE));) omcCAPImsvc: getMSVCversion @@ -167,7 +165,7 @@ omcCAPImsvc: getMSVCversion echo echo Running NMake JOM >> Build_CAPI_MSVC/build.bat echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> Build_CAPI_MSVC/build.bat cd ./Build_CAPI_MSVC; echo "change to Build_CAPI_MSVC";\ - cmd /c build.bat + cmd "/c build.bat" runtimeCPPmsvc: getMSVCversion test -f """${VSCOMNTOOLS}/../../VC/vcvarsall.bat""" echo 'Build the cppRuntime with MSVC' buildtype: $(BUILDTYPE) @@ -183,7 +181,7 @@ runtimeCPPmsvc: getMSVCversion echo echo Running NMake JOM >> Build_MSVC/build.bat echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> Build_MSVC/build.bat cd ./Build_MSVC; echo "change to Build_MSVC";\ - cmd /c build.bat + cmd "/c build.bat" echo 'Build cppRuntime (static) with MSVC' #rm -rf Build_MSVC_static @@ -198,7 +196,7 @@ runtimeCPPmsvc: getMSVCversion echo echo Running NMake JOM >> Build_MSVC_static/build.bat echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> Build_MSVC_static/build.bat cd ./Build_MSVC_static; echo "change to Build_MSVC_static";\ - cmd /c build.bat + cmd "/c build.bat" # move folder to build dir #cp -R --verbose Build_MSVC/tmp/* $(builddir_build) @@ -208,7 +206,7 @@ omcCAPIinstall: mkdir -p Build_CAPI; (cd ./Build_CAPI; echo "change to Build_CAPI"; \ mkdir -p tmp; \ - cmake -G "MSYS Makefiles" -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE $(IS_MINGW32) $(IS_MINGW64) -DCMAKE_BUILD_TYPE=$(BUILDTYPE) -DBUILD_SHARED_LIBS=TRUE -DPLATFORM=$(PLATFORM) -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DLIB_OMC=$(LIB_OMC) -DOMC_PATH="$(OMBUILDDIR)" -DCMAKE_INSTALL_PREFIX:PATH="./tmp" -DOMCAPI_ROOT="../../Build_CAPI/tmp" MAKE_CXX_COMPILER=g++ ../omcWrapper/; \ + cmake -G "MSYS Makefiles" -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=TRUE $(IS_MINGW32) $(IS_MINGW64) -DCMAKE_BUILD_TYPE=$(BUILDTYPE) -DBUILD_SHARED_LIBS=TRUE -DPLATFORM=$(PLATFORM) -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DLIB_OMC=$(LIB_OMC) -DOMC_PATH="$(OMBUILDDIR)" -DCMAKE_INSTALL_PREFIX:PATH="./tmp" -DOMCAPI_ROOT="../../Build_CAPI/tmp" ../omcWrapper/; \ $(MAKE) install; ) (cp -puf Build_CAPI/tmp/lib/*.dll* $(OMBUILDDIR)/bin/) @@ -219,13 +217,6 @@ omcCAPIinstall: install: runtimeCpp $(foreach PLATFORM, $(PLATFORMS), \ (cd Build_$(PLATFORM); $(MAKE) install);) - cp -p $(OMDEVMSYS)/lib/3rdParty/boost-1_55/lib/*.dll $(builddir_bin)/. -ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) - (cd Build; cp -p $(OMDEVMSYS)/tools/msys/mingw32/bin/libboost*.dll $(builddir_bin)/.) -else - (cd Build; cp -p $(OMDEVMSYS)/tools/msys/mingw64/bin/libboost*.dll $(builddir_bin)/.) -endif - clean: $(foreach PLATFORM, $(PLATFORMS), \ diff --git a/OMCompiler/SimulationRuntime/OMSICpp/omcWrapper/omcZeroMQ/CMakeLists.txt b/OMCompiler/SimulationRuntime/OMSICpp/omcWrapper/omcZeroMQ/CMakeLists.txt index 0153bb36f4f..654b8cc5415 100644 --- a/OMCompiler/SimulationRuntime/OMSICpp/omcWrapper/omcZeroMQ/CMakeLists.txt +++ b/OMCompiler/SimulationRuntime/OMSICpp/omcWrapper/omcZeroMQ/CMakeLists.txt @@ -3,25 +3,35 @@ project(${OMCZeroMQName} VERSION 0.1) - + set(Boost_DEBUG 1) MESSAGE(STATUS "MINGW:") -MESSAGE(STATUS ${IS_MINGW32}) MESSAGE(STATUS ${IS_MINGW64}) +# Check environment variables +IF(WIN32) + if(NOT DEFINED ENV{OMDEV}) + message(FATAL_ERROR "Environment variable \"OMDEV\" is not set.") + endif() + if(NOT DEFINED ENV{MSYSTEM_PREFIX}) + message(FATAL_ERROR "Environment variable \"MSYSTEM_PREFIX\" is not set.") + endif() + string(REPLACE "\\" "/" OMDEV_ESCAPED "$ENV{OMDEV}") + string(REPLACE "\\" "/" MSYSTEM_PREFIX_ESCAPED "$ENV{MSYSTEM_PREFIX}") +ENDIF() IF(IS_MINGW32) - SET(BOOST_ROOT $ENV{OMDEV}"/tools/mingw32/") + MESSAGE(FATAL_ERROR "32-bit version not supported") ELSEIF(IS_MINGW64) - SET(BOOST_ROOT $ENV{OMDEV}"/tools/mingw64/") + SET(BOOST_ROOT ${MSYSTEM_PREFIX_ESCAPED}) ELSE() if(MSVC_VERSION GREATER 1800) MESSAGE(STATUS "USE MSVC 2015 and greater:") SET(Boost_COMPILER "-vc142") elseif(MSVC_VERSION GREATER 1700) - SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_59/") + SET(BOOST_ROOT ${OMDEV_ESCAPED}"/lib/3rdParty/boost-1_59/") else() - SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_55/") + SET(BOOST_ROOT ${OMDEV_ESCAPED}"/lib/3rdParty/boost-1_55/") endif() ENDIF(IS_MINGW32) MESSAGE(STATUS "Boost root for omc - zeromq:") @@ -78,8 +88,8 @@ MESSAGE(STATUS "omc c api library: ${OMCCAPIName} includ dir: ${OMCCAPI_INCLUDE include_directories(${cppzmq_INCLUDE_DIR} ${ZeroMQ_INCLUDE_DIR} ${OMCCAPI_INCLUDE_DIR} ${Boost_INCLUDE_DIR} include/) ADD_EXECUTABLE(${OMCZeroMQName} src/omc.cpp src/omcZeromqTask.cpp) - - + + #link with gc lib #target_link_libraries(${OMCZeroMQName} ${ZeroMQ_LIB} ${OMCCAPIName} ${Boost_LIBRARIES} ${OMCGC_LIB} ) #target_link_libraries(${OMCZeroMQName} ${ZeroMQ_LIBRARY} ${OMCCAPIName} ${Boost_LIBRARIES} ) diff --git a/OMCompiler/SimulationRuntime/OMSICpp/omsi/CMakeLists.txt b/OMCompiler/SimulationRuntime/OMSICpp/omsi/CMakeLists.txt index c79a4f8ca3d..3c5e2978356 100644 --- a/OMCompiler/SimulationRuntime/OMSICpp/omsi/CMakeLists.txt +++ b/OMCompiler/SimulationRuntime/OMSICpp/omsi/CMakeLists.txt @@ -12,15 +12,15 @@ include_directories ("${CMAKE_SOURCE_DIR}/../../3rdParty/FMIL/ThirdParty/FMI/def MESSAGE(STATUS "${OMSIBASE_LIB}") #Removed this library because the omsicpp code generation is skipped at the moment which used this library - #add_library(${OSUName} STATIC src/fmi2/omsi_fmi2_me.cpp src/fmi2/detail/omsi_fmi2_log.cpp src/fmi2/detail/omsi_fmi2_wrapper.cpp src/omsi_factory.cpp src/omsi_global_settings.cpp ) - #IF(WIN32) - #target_link_libraries(${OSUName} ${OMCFactoryName} ${SimControllerName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} wsock32 ws2_32) - #ELSE(WIN32) - #target_link_libraries(${OSUName} ${OMCFactoryName} ${SimControllerName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS}) - #ENDIF(WIN32) + #add_library(${OSUName} STATIC src/fmi2/omsi_fmi2_me.cpp src/fmi2/detail/omsi_fmi2_log.cpp src/fmi2/detail/omsi_fmi2_wrapper.cpp src/omsi_factory.cpp src/omsi_global_settings.cpp ) + #IF(WIN32) + #target_link_libraries(${OSUName} ${OMCFactoryName} ${SimControllerName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} wsock32 ws2_32) + #ELSE(WIN32) + #target_link_libraries(${OSUName} ${OMCFactoryName} ${SimControllerName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS}) + #ENDIF(WIN32) - #install(TARGETS ${OSUName} DESTINATION ${LIBINSTALLEXT}) + #install(TARGETS ${OSUName} DESTINATION ${LIBINSTALLEXT}) IF(BUILD_SHARED_LIBS) @@ -33,26 +33,36 @@ IF(BUILD_SHARED_LIBS) add_executable(${OSUSimName} src/omsi.cpp ) IF(WIN32) - target_link_libraries(${OSUSimName} ${OMCFactoryName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} wsock32 ws2_32) + target_link_libraries(${OSUSimName} ${OMCFactoryName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} wsock32 ws2_32) #Removed this library because the omsicpp code generation is skipped at the moment which used this library - #target_link_libraries(${OSUName} ${OMCFactoryName} ${SimControllerName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} wsock32 ws2_32) - ELSE(WIN32) - target_link_libraries(${OSUSimName} ${OMCFactoryName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS}) + #target_link_libraries(${OSUName} ${OMCFactoryName} ${SimControllerName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} wsock32 ws2_32) + ELSE(WIN32) + target_link_libraries(${OSUSimName} ${OMCFactoryName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS}) #Removed this library because the omsicpp code generation is skipped at the moment which used this library - #target_link_libraries(${OSUName} ${OMCFactoryName} ${SimControllerName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ) + #target_link_libraries(${OSUName} ${OMCFactoryName} ${SimControllerName} ${ExtensionUtilitiesName} ${ModelicaUtilitiesName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ) ENDIF(WIN32) #Removed this library because the omsicpp code generation is skipped at the moment which used this library - #set_target_properties(${OSUName} PROPERTIES COMPILE_DEFINITIONS "RUNTIME_STATIC_LINKING;ENABLE_SUNDIALS_STATIC") + #set_target_properties(${OSUName} PROPERTIES COMPILE_DEFINITIONS "RUNTIME_STATIC_LINKING;ENABLE_SUNDIALS_STATIC") IF(MSVC) install(FILES $ DESTINATION bin OPTIONAL) #install(FILES $ DESTINATION ${LIBINSTALLEXT} OPTIONAL) ENDIF(MSVC) -install(TARGETS ${OSUSimName} DESTINATION bin) +if(win32) + # Escape the environment variable path + if(NOT DEFINED ENV{MSYSTEM_PREFIX}) + message(FATAL_ERROR "Environment variable \"MSYSTEM_PREFIX\" is not set.") + endif() + string(REPLACE "\\" "/" MSYSTEM_PREFIX_ESCAPED "$ENV{MSYSTEM_PREFIX}") + + install(TARGETS ${OSUSimName} + RUNTIME_DEPENDENCIES + DIRECTORIES ${MSYSTEM_PREFIX_ESCAPED}/bin + PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" + POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" + DESTINATION bin) +else() + install(TARGETS ${OSUSimName} DESTINATION bin) +endif() ENDIF(BUILD_SHARED_LIBS) - - - - - diff --git a/OMCompiler/SimulationRuntime/OMSICpp/runtime/src/Core/Modelica/CMakeLists.txt b/OMCompiler/SimulationRuntime/OMSICpp/runtime/src/Core/Modelica/CMakeLists.txt index 324e8b48e41..9132cc931ce 100644 --- a/OMCompiler/SimulationRuntime/OMSICpp/runtime/src/Core/Modelica/CMakeLists.txt +++ b/OMCompiler/SimulationRuntime/OMSICpp/runtime/src/Core/Modelica/CMakeLists.txt @@ -112,16 +112,23 @@ IF(CMAKE_BUILD_TYPE) ENDIF(CMAKE_BUILD_TYPE) IF(WIN32) + + # Check environment variables + if(NOT DEFINED ENV{MSYSTEM_PREFIX}) + message(FATAL_ERROR "Environment variable \"MSYSTEM_PREFIX\" is not set.") + endif() + string(REPLACE "\\" "/" MSYSTEM_PREFIX_ESCAPED "$ENV{MSYSTEM_PREFIX}") + IF(MSVC) - SET(Boost_LIBS_ "$(OMHOME)/bin/msvc") - ELSE(MSVC) - SET(Boost_LIBS_ "$(OMHOME)/bin") - ENDIF(MSVC) + SET(Boost_LIBS_ "$(OMHOME)/bin/msvc") + ELSE(MSVC) + SET(Boost_LIBS_ "$(OMHOME)/bin") + ENDIF(MSVC) IF(MSVC) SET(Boost_INCLUDE_ "$(OMHOME)/include/omc/omsicpp/3rdParty/boost/msvc/") ELSE(MSVC) - SET(Boost_INCLUDE_ "$(OMHOME)/tools/msys/mingw64/include/") + SET(Boost_INCLUDE_ "$(MSYSTEM_PREFIX_ESCAPED)/include/") ENDIF(MSVC) SET(SUNDIALS_LIBS_ "$(OMHOME)/bin") diff --git a/OMCompiler/SimulationRuntime/ParModelica/auto/Makefile.omdev.mingw b/OMCompiler/SimulationRuntime/ParModelica/auto/Makefile.omdev.mingw index 7f0bc5d7c5c..ba3c3fe61d0 100644 --- a/OMCompiler/SimulationRuntime/ParModelica/auto/Makefile.omdev.mingw +++ b/OMCompiler/SimulationRuntime/ParModelica/auto/Makefile.omdev.mingw @@ -1,3 +1,9 @@ +ifndef OMDEV + @echo You have to set the OMDEV variabile pointing to your OMDev package root! Exiting.... + @echo See OpenModelica/OMCompiler/README.Windows.md + ABORT +endif + TOP_BUILDDIR = $(realpath ../../../../)/build OMCOMPILER_ROOT = $(realpath ../../../) diff --git a/OMCompiler/SimulationRuntime/c/Makefile.omdev.mingw b/OMCompiler/SimulationRuntime/c/Makefile.omdev.mingw index 735d4e96904..9c5dfc657a0 100644 --- a/OMCompiler/SimulationRuntime/c/Makefile.omdev.mingw +++ b/OMCompiler/SimulationRuntime/c/Makefile.omdev.mingw @@ -1,10 +1,10 @@ -# Adrian Pop, adrpo@ida.liu.se, 2006-02-01 -# Makefile for compilation of OMC using OMDev-mingw -# OMDev-mingw: http://www.ida.liu.se/~adrpo/omc/omdev/ +# Makefile for Compiler/runtime compilation of OMC using MSYS UCRT -# The path to the OMDev-mingw package MUST BE SET! -#OMDEV=$OMDEV -# Test if the needed variables are there... +ifndef OMDEV + @echo You have to set the OMDEV variabile pointing to your OMDev package root! Exiting.... + @echo See OpenModelica/OMCompiler/README.Windows.md + ABORT +endif top_builddir = ../.. builddir_bin=$(OMBUILDDIR)/bin diff --git a/OMCompiler/SimulationRuntime/c/util/omc_file.c b/OMCompiler/SimulationRuntime/c/util/omc_file.c index 098bb86328e..1f504bae6fa 100644 --- a/OMCompiler/SimulationRuntime/c/util/omc_file.c +++ b/OMCompiler/SimulationRuntime/c/util/omc_file.c @@ -193,8 +193,9 @@ int omc_stat(const char *filename, omc_stat_t* statbuf) wchar_t* unicodeFilename = omc_multibyte_to_wchar_str(filename); wchar_t* unicodeLongFileName = longabspath(unicodeFilename); - int res; - res = _wstat(unicodeLongFileName, statbuf); + // _wstat not working on MINGW64 with \\?\, because it links to the MSVCRT (Microsoft Visual C++ Runtime) + // We need to use UCRT64, which links to UCRT (Universal C Runtime) + int res = _wstat(unicodeLongFileName, statbuf); free(unicodeLongFileName); free(unicodeFilename); diff --git a/OMCompiler/SimulationRuntime/cpp/CMakeLists.txt b/OMCompiler/SimulationRuntime/cpp/CMakeLists.txt index 1a231414090..a1c06261220 100644 --- a/OMCompiler/SimulationRuntime/cpp/CMakeLists.txt +++ b/OMCompiler/SimulationRuntime/cpp/CMakeLists.txt @@ -187,10 +187,6 @@ IF(MSVC) ENDIF(MSVC) INCLUDE(${CMAKE_SOURCE_DIR}/PrecompiledHeader.cmake) -#IF(IS_MINGW32 OR IS_MINGW64) -# SET(USE_CPP_03 ON) -#ENDIF(IS_MINGW32 OR IS_MINGW64) - # Check C++11 IF(NOT(USE_CPP_03)) IF(MSVC) @@ -327,29 +323,36 @@ ELSEIF(SIMSTER_BUILD) ADD_DEFINITIONS(-DSIMSTER_BUILD) ENDIF(OMC_BUILD) - -# Handle OMDEV -# - On windows boost,blas,lapack and sundial solvers from omdev are used else the installed versions are used +# Handle Boost +# - On windows boost from MSYS are used else the installed versions are used IF(WIN32) MESSAGE(STATUS "MINGW:") - MESSAGE(STATUS ${IS_MINGW32}) MESSAGE(STATUS ${IS_MINGW64}) - IF(IS_MINGW32) - SET(BOOST_ROOT $ENV{OMDEV}"/tools/mingw32/") - ELSEIF(IS_MINGW64) - SET(BOOST_ROOT $ENV{OMDEV}"/tools/mingw64/") - ELSE() + + # Check environment variables + if(NOT DEFINED ENV{OMDEV}) + message(FATAL_ERROR "Environment variable \"OMDEV\" is not set.") + endif() + if(NOT DEFINED ENV{MSYSTEM_PREFIX}) + message(FATAL_ERROR "Environment variable \"MSYSTEM_PREFIX\" is not set.") + endif() + string(REPLACE "\\" "/" OMDEV_ESCAPED "$ENV{OMDEV}") + string(REPLACE "\\" "/" MSYSTEM_PREFIX_ESCAPED "$ENV{MSYSTEM_PREFIX}") + + IF(IS_MINGW64) + SET(BOOST_ROOT ${MSYSTEM_PREFIX_ESCAPED}) + ELSEIF(IS_MINGW32) + MESSAGE(FATAL_ERROR "32-bit version not supported") + ELSEIF(MSVC) IF(MSVC_VERSION GREATER 1700) - SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_59/") + SET(BOOST_ROOT ${OMDEV_ESCAPED}/lib/3rdParty/boost-1_59/) ELSE(MSVC_VERSION GREATER 1700) - SET(BOOST_ROOT $ENV{OMDEV}"/lib/3rdParty/boost-1_55/") + SET(BOOST_ROOT ${OMDEV_ESCAPED}/lib/3rdParty/boost-1_55/) ENDIF(MSVC_VERSION GREATER 1700) - ENDIF(IS_MINGW32) - MESSAGE(STATUS "Boost root for cpp runtime:") - MESSAGE(STATUS ${BOOST_ROOT}) - SET(BLAS_blas_LIBRARY $ENV{OMDEV}/lib/3rdParty/Lapack/Lib/blas_win32.dll CACHE FILEPATH "Blas library") - SET(LAPACK_lapack_LIBRARY $ENV{OMDEV}/lib/3rdParty/Lapack/Lib/lapack_win32.dll CACHE FILEPATH "Lapack library") - SET(BLAS_DIRY "$ENV{OMDEV}/lib/3rdParty/Lapack/Lib/" CACHE LOCATION "where was yarp built?") + ELSE() + MESSAGE(FATAL_ERROR "CPPRuntime does not know how to handle boost in this configuration") + ENDIF() + MESSAGE(STATUS "Boost root for cpp runtime: ${BOOST_ROOT}") # Disable Optimization for RelWithDebInfo on Windows IF(MSVC) @@ -360,8 +363,10 @@ IF(WIN32) ENDIF(MSVC) #set mico paths - SET(MICO_LIB_HOME $ENV{OMDEV}/lib/mico-msys-mingw/) - SET(MICO_INCLUDE_HOME $ENV{OMDEV}/include/mico-msys-mingw/) + IF(USE_MICO) + SET(MICO_LIB_HOME ${OMDEV_ESCAPED}/lib/mico-msys-mingw/) + SET(MICO_INCLUDE_HOME ${OMDEV_ESCAPED}/include/mico-msys-mingw/) + endif() SET(INSTALL_OMDEV_LIBS OFF) ENDIF(WIN32) @@ -438,8 +443,14 @@ ELSE(PAPI_FOUND) SET(USE_PAPI_ "OFF") ENDIF(PAPI_FOUND) - # Find Boost +# If MSVC, we do not want to use MSYS/MingGW installed boost's CMake config files for locating Boost +# We have a manually provided boost already specified using BOOST_ROOT. +# This is essentialy saying we do not want any help from boost itself in finding its libraries and setup. +# Let CMake do it alone the old way by just finding the files it knows. +IF(MSVC) + SET(Boost_NO_BOOST_CMAKE ON) +ENDIF(MSVC) # - The optional boost libraries must be searched separately, otherwise no library is found if just one is missing. # - Additionaly the Boost_LIBRARIES variable is overwritten each time find_package(Boost ...) is called, thus it must be rescued FIND_PACKAGE(Boost COMPONENTS log log_setup) @@ -482,12 +493,12 @@ IF(FMU_TARGET AND NOT MSVC) ENDIF(FMU_TARGET AND NOT MSVC) IF(WIN32) -SET(CPPTHREADS_LIBRARY) -SET(CPPTHREADS_LIBRARY_FLAG) + SET(CPPTHREADS_LIBRARY) + SET(CPPTHREADS_LIBRARY_FLAG) ELSE(WIN32) -find_package(Threads REQUIRED) -SET(CPPTHREADS_LIBRARY Threads::Threads) -SET(CPPTHREADS_LIBRARY_FLAG ${CMAKE_THREAD_LIBS_INIT}) + find_package(Threads REQUIRED) + SET(CPPTHREADS_LIBRARY Threads::Threads) + SET(CPPTHREADS_LIBRARY_FLAG ${CMAKE_THREAD_LIBS_INIT}) ENDIF(WIN32) SET(Boost_LIBRARIES_TMP ${Boost_LIBRARIES_TMP} ${Boost_LIBRARIES}) @@ -496,37 +507,22 @@ MESSAGE(STATUS "Boost Libraries for cpp runtime") MESSAGE(STATUS ${Boost_LIBRARIES}) # Find Lapack and Blas -FIND_PACKAGE(BLAS) -FIND_PACKAGE(LAPACK) - IF(MSVC) #workaround because cmake does not find the lapack libraries for Visual Studio 10 - SET(LAPACK_MSVC_10 $ENV{OMDEV}/lib/3rdParty/Lapack/Lib/lapack_win32.lib ) - SET(BLAS_MSVC_10 $ENV{OMDEV}/lib/3rdParty/Lapack/Lib/blas_win32.lib ) - SET(LAPACK_LIBRARIES ${LAPACK_MSVC_10} ${BLAS_MSVC_10} ) -ELSEIF(IS_MINGW32) - SET(LAPACK_MINGW $ENV{OMDEV}/tools/msys/mingw32/bin/libopenblas.dll ) - SET(LAPACK_LIBRARIES ${LAPACK_MINGW} ) -ELSEIF(IS_MINGW64) - SET(LAPACK_MINGW $ENV{OMDEV}/tools/msys/mingw64/bin/libopenblas.dll ) - SET(LAPACK_LIBRARIES ${LAPACK_MINGW} ) + SET(LAPACK_MSVC_10 ${OMDEV_ESCAPED}/lib/3rdParty/Lapack/Lib/lapack_win32.lib ) + SET(BLAS_MSVC_10 ${OMDEV_ESCAPED}/lib/3rdParty/Lapack/Lib/blas_win32.lib ) + SET(LAPACK_LIBRARIES ${LAPACK_MSVC_10} ${BLAS_MSVC_10} ) +ELSE() + FIND_PACKAGE(BLAS) + FIND_PACKAGE(LAPACK) + if(LAPACK_FOUND AND BLAS_FOUND) + MESSAGE(STATUS "LAPACK and BLAS found") + else() + message(FATAL_ERROR "Couldn't find LAPACK and BLAS.") + endif() ENDIF(MSVC) -FIND_LIBRARY(mkl_rt mkl_rt) -IF (mkl_rt) - #workaround because find_package(lapack)-command returns the wrong libraries on Taurus (ZIH-TU Dresden) - SET(LAPACK_LIBRARIES ${mkl_rt}) -ENDIF(mkl_rt) - -LIST(LENGTH LAPACK_LIBRARIES LAPACKVARCOUNT) -IF(LAPACKVARCOUNT GREATER 0) - LIST(GET LAPACK_LIBRARIES 0 LAPACKLISTHEAD) - GET_FILENAME_COMPONENT(LAPACKLISTHEAD "${LAPACKLISTHEAD}" PATH) - SET(LAPACK_LIBS "${LAPACKLISTHEAD}") -ENDIF() - -MESSAGE(STATUS "Lapack Libraries") -MESSAGE(STATUS ${LAPACK_LIBRARIES}) +MESSAGE(STATUS "LAPACK Libraries: ${LAPACK_LIBRARIES}") MESSAGE(STATUS "use reduce dae method: ${REDUCE_DAE} - " ) IF(REDUCE_DAE) @@ -751,8 +747,10 @@ include_directories ("Include") IF(USE_DGESV) ADD_SUBDIRECTORY(Solver/Dgesv) - GET_TARGET_PROPERTY(libDgesv ${DgesvName} LOCATION) - GET_FILENAME_COMPONENT(libDgesvName ${libDgesv} NAME) + IF(DGESV_FOUND) + GET_TARGET_PROPERTY(libDgesv ${DgesvName} LOCATION) + GET_FILENAME_COMPONENT(libDgesvName ${libDgesv} NAME) + ENDIF() ENDIF(USE_DGESV) # add base definitions for generating a target @@ -965,21 +963,6 @@ configure_file ( "${PROJECT_BINARY_DIR}/LibrariesConfig.h" ) -if(INSTALL_OMDEV_LIBS) - #if(USE_SUNDIALS) - # install (FILES "${SUNDIALS_NVECSERIAL_LIB}" "${SUNDIALS_IDAS_LIB}" "${SUNDIALS_IDA_LIB}" "${SUNDIALS_CVODES_LIB}" DESTINATION bin) - #endif(USE_SUNDIALS) - - if(USE_MICO) - install (FILES "${MICO_LIBRARY}" DESTINATION bin) - endif() - - install (FILES "${LAPACK_lapack_LIBRARY}" DESTINATION bin) - install (FILES "${BLAS_blas_LIBRARY}" DESTINATION bin) - #install (FILES "${BOOST_SERIALIZATION_LIBRARY_RELEASE}" DESTINATION bin) -endif() - - MACRO(INSTALL_HEADERS_WITH_DIRECTORY HEADER_LIST) FOREACH(HEADER ${${HEADER_LIST}}) diff --git a/OMCompiler/SimulationRuntime/cpp/Core/Modelica/CMakeLists.txt b/OMCompiler/SimulationRuntime/cpp/Core/Modelica/CMakeLists.txt index fa228ae9f7f..33a5f91c9d0 100644 --- a/OMCompiler/SimulationRuntime/cpp/Core/Modelica/CMakeLists.txt +++ b/OMCompiler/SimulationRuntime/cpp/Core/Modelica/CMakeLists.txt @@ -113,10 +113,14 @@ ENDIF(CMAKE_BUILD_TYPE) IF(WIN32) SET(Boost_LIBS_ "$(OMHOME)/bin") + if(NOT DEFINED ENV{MSYSTEM_PREFIX}) + message(FATAL_ERROR "Environment variable \"MSYSTEM_PREFIX\" is not set.") + endif() + string(REPLACE "\\" "/" MSYSTEM_PREFIX_ESCAPED "$ENV{MSYSTEM_PREFIX}") IF(MSVC) SET(Boost_INCLUDE_ "$(OMHOME)/include/omc/omsicpp/3rdParty/boost/msvc/") ELSE(MSVC) - SET(Boost_INCLUDE_ "$(OMHOME)/tools/msys/mingw64/include/") + SET(Boost_INCLUDE_ "${MSYSTEM_PREFIX_ESCAPED}/include/") ENDIF(MSVC) SET(SUNDIALS_LIBS_ "$(OMHOME)/bin") diff --git a/OMCompiler/SimulationRuntime/cpp/Makefile.omdev.mingw b/OMCompiler/SimulationRuntime/cpp/Makefile.omdev.mingw index 6c38466f2d4..f2c325873a1 100644 --- a/OMCompiler/SimulationRuntime/cpp/Makefile.omdev.mingw +++ b/OMCompiler/SimulationRuntime/cpp/Makefile.omdev.mingw @@ -15,11 +15,18 @@ builddir_inc=$(OMBUILDDIR)/include/omc OMBUILDDIR_WIN=$(shell cygpath -w $$OMBUILDDIR) -#use this call to use precompiled headers -#use this call if you want to debug the cpp runtime -CMAKE = $(OMDEVMSYS)/bin/cmake/bin/cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON +CMAKE = cmake # this doesn't seem to work! $(where cmake) -OMDEVMSYS=$(shell cygpath $$OMDEV) +ifndef OMDEV + @echo You have to set the OMDEV variabile pointing to your OMDev package root! Exiting.... + @echo See OpenModelica/OMCompiler/README.Windows.md + ABORT +endif +ifndef MSYSTEM_PREFIX +$(error Environment variable MSYSTEM_PREFIX not set. Is this a msys2 shell?) +endif +OMDEV = $(shell cygpath $$OMDEV) +MSYSTEM_PREFIX = $(shell cygpath $$MSYSTEM_PREFIX) ifeq ($(BUILDTYPE),) BUILDTYPE=$(BuildType) @@ -155,16 +162,16 @@ omcCAPImsvc: getMSVCversion mkdir -p Build_CAPI_MSVC echo call '"${VSCOMNTOOLS}\\..\\..\\VC\\vcvarsall.bat" ${VCVARS_PARAMS}' > Build_CAPI_MSVC/build.bat - echo echo Running CMake from '%OMDEV%\\bin\\cmake\\bin\\cmake' >> Build_CAPI_MSVC/build.bat + echo echo Running CMake from '$(CMAKE)' >> Build_CAPI_MSVC/build.bat echo echo using omc libraries from "$(OMBUILDDIR)" >> Build_CAPI_MSVC/build.bat - echo '%OMDEV%\\bin\\cmake\\bin\\cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DOMC_PATH="$(OMBUILDDIR)/build" -DCMAKE_INSTALL_PREFIX:PATH=./tmp ../omcCAPI/ -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe"' >> Build_CAPI_MSVC/build.bat + echo '$(CMAKE) -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DOMC_PATH="$(OMBUILDDIR)/build" -DCMAKE_INSTALL_PREFIX:PATH=./tmp ../omcCAPI/ -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe"' >> Build_CAPI_MSVC/build.bat # for some reason, the environment variable 'MAKEFLAGS' was set to 'w' on my and Niklas' machine?! echo set MAKEFLAGS="" >> Build_CAPI_MSVC/build.bat echo echo Running NMake JOM >> Build_CAPI_MSVC/build.bat echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> Build_CAPI_MSVC/build.bat cd ./Build_CAPI_MSVC; echo "change to Build_CAPI_MSVC";\ - cmd /c build.bat + cmd "/c build.bat" runtimeCPPmsvc: getMSVCversion test -f """${VSCOMNTOOLS}/../../VC/vcvarsall.bat""" echo 'Build the cppRuntime with MSVC' buildtype: $(BUILDTYPE) @@ -172,30 +179,30 @@ runtimeCPPmsvc: getMSVCversion mkdir -p Build_MSVC echo call '"${VSCOMNTOOLS}\\..\\..\\VC\\vcvarsall.bat" ${VCVARS_PARAMS}' > Build_MSVC/build.bat - echo echo Running CMake from '%OMDEV%\\bin\\cmake\\bin\\cmake' >> Build_MSVC/build.bat - echo '%OMDEV%\\bin\\cmake\\bin\\cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DPLATFORM="dynamic" $(CMAKE_FLAGS) -DIS_MINGW32=OFF -DIS_MINGW64=OFF -DCMAKE_INSTALL_PREFIX:PATH=./tmp ../ -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe"' >> Build_MSVC/build.bat + echo echo Running CMake from '$(CMAKE)' >> Build_MSVC/build.bat + echo '$(CMAKE) -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DPLATFORM="dynamic" $(CMAKE_FLAGS) -DIS_MINGW32=OFF -DIS_MINGW64=OFF -DCMAKE_INSTALL_PREFIX:PATH=./tmp ../ -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe"' >> Build_MSVC/build.bat # for some reason, the environment variable 'MAKEFLAGS' was set to 'w' on my and Niklas' machine?! echo set MAKEFLAGS="" >> Build_MSVC/build.bat echo echo Running NMake JOM >> Build_MSVC/build.bat echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> Build_MSVC/build.bat cd ./Build_MSVC; echo "change to Build_MSVC";\ - cmd /c build.bat + cmd "/c build.bat" echo 'Build cppRuntime (static) with MSVC' #rm -rf Build_MSVC_static mkdir -p Build_MSVC_static echo call '"${VSCOMNTOOLS}\\..\\..\\VC\\vcvarsall.bat" ${VCVARS_PARAMS}' > Build_MSVC_static/build.bat - echo echo Running CMake from '%OMDEV%\\bin\\cmake\\bin\\cmake' >> Build_MSVC_static/build.bat - echo '%OMDEV%\\bin\\cmake\\bin\\cmake -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DPLATFORM="static" $(CMAKE_FLAGS) -DIS_MINGW32=OFF -DIS_MINGW64=OFF -DCMAKE_INSTALL_PREFIX:PATH=./tmp ../ -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe"' >> Build_MSVC_static/build.bat + echo echo Running CMake from '$(CMAKE)' >> Build_MSVC_static/build.bat + echo '$(CMAKE) -DCMAKE_VERBOSE_MAKEFILE:Bool=ON -DPLATFORM="static" $(CMAKE_FLAGS) -DIS_MINGW32=OFF -DIS_MINGW64=OFF -DCMAKE_INSTALL_PREFIX:PATH=./tmp ../ -G "NMake Makefiles JOM" -D"CMAKE_MAKE_PROGRAM:PATH=%OMDEV%\\tools\\jom\\jom.exe"' >> Build_MSVC_static/build.bat # for some reason, the environment variable 'MAKEFLAGS' was set to 'w' on my and Niklas' machine?! echo set MAKEFLAGS="" >> Build_MSVC_static/build.bat echo echo Running NMake JOM >> Build_MSVC_static/build.bat echo %OMDEV%\\tools\\jom\\jom.exe /f Makefile install >> Build_MSVC_static/build.bat cd ./Build_MSVC_static; echo "change to Build_MSVC_static";\ - cmd /c build.bat + cmd "/c build.bat" # move folder to build dir cp -R Build_MSVC/tmp/* $(builddir_build) @@ -212,13 +219,7 @@ omcCAPIinstall: install: runtimeCpp $(foreach PLATFORM, $(PLATFORMS), \ (cd Build_$(PLATFORM); $(MAKE) install);) - cp -p $(OMDEVMSYS)/lib/3rdParty/boost-1_55/lib/*.dll $(builddir_bin)/. -ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) - (cd Build; cp -p $(OMDEVMSYS)/tools/msys/mingw32/bin/libboost*.dll $(builddir_bin)/.) -else - (cd Build; cp -p $(OMDEVMSYS)/tools/msys/mingw64/bin/libboost*.dll $(builddir_bin)/.) -endif - + cp -p $(MSYSTEM_PREFIX)/bin/libboost*.dll $(builddir_bin)/. clean: $(foreach PLATFORM, $(PLATFORMS), \ diff --git a/OMCompiler/SimulationRuntime/cpp/Solver/ARKode/CMakeLists.txt b/OMCompiler/SimulationRuntime/cpp/Solver/ARKode/CMakeLists.txt index 64573c5252e..e1447839bc7 100644 --- a/OMCompiler/SimulationRuntime/cpp/Solver/ARKode/CMakeLists.txt +++ b/OMCompiler/SimulationRuntime/cpp/Solver/ARKode/CMakeLists.txt @@ -11,7 +11,9 @@ endif(NOT BUILD_SHARED_LIBS) target_link_libraries(${ARKodeName} ${SolverName} ${ExtensionUtilitiesName} ${Boost_LIBRARIES} ${SUNDIALS_LIBRARIES}) add_precompiled_header(${ARKodeName} Core/Modelica.h) -install(FILES $ DESTINATION ${LIBINSTALLEXT} OPTIONAL) +if(MSVC) + install(FILES $ DESTINATION ${LIBINSTALLEXT} OPTIONAL) +endif() install(TARGETS ${ARKodeName} DESTINATION ${LIBINSTALLEXT}) install(FILES diff --git a/OMCompiler/SimulationRuntime/cpp/Solver/Dgesv/CMakeLists.txt b/OMCompiler/SimulationRuntime/cpp/Solver/Dgesv/CMakeLists.txt index 2d839f411f5..081c1908985 100644 --- a/OMCompiler/SimulationRuntime/cpp/Solver/Dgesv/CMakeLists.txt +++ b/OMCompiler/SimulationRuntime/cpp/Solver/Dgesv/CMakeLists.txt @@ -8,8 +8,11 @@ IF(DGESV_FOUND) add_library(${DgesvName}_static STATIC ${DGESV_SRCS}) install(TARGETS ${DgesvName}_static DESTINATION ${LIBINSTALLEXT}) install(FILES ${DGESV_HEADERS} DESTINATION include/omc/cpp/Solver/Dgesv) - GET_TARGET_PROPERTY(libDgesvLocation ${DgesvName}_static LOCATION) - GET_FILENAME_COMPONENT(libDgesvExt ${libDgesvLocation} EXT CACHE) + if(MSVC) + # TODO: This is not allowed: cmake --help-policy CMP0026 + GET_TARGET_PROPERTY(libDgesvLocation ${DgesvName}_static LOCATION) + GET_FILENAME_COMPONENT(libDgesvExt ${libDgesvLocation} EXT CACHE) + endif() add_library(${DgesvSolverName} DgesvSolver.cpp DgesvSolverSettings.cpp FactoryExport.cpp) @@ -20,7 +23,9 @@ IF(DGESV_FOUND) target_link_libraries(${DgesvSolverName} ${SolverName} ${ExtensionUtilitiesName} ${Boost_LIBRARIES} ${LAPACK_LIBRARIES} ${ModelicaName}) add_precompiled_header(${DgesvSolverName} Core/Modelica.h) - install(FILES $ DESTINATION ${LIBINSTALLEXT} OPTIONAL) + if(MSVC) + install(FILES $ DESTINATION ${LIBINSTALLEXT} OPTIONAL) + endif() install(TARGETS ${DgesvSolverName} DESTINATION ${LIBINSTALLEXT}) install(FILES diff --git a/OMCompiler/SimulationRuntime/opc/da/Makefile.omdev.mingw b/OMCompiler/SimulationRuntime/opc/da/Makefile.omdev.mingw index 980008b1e2e..c0c5f2ba895 100644 --- a/OMCompiler/SimulationRuntime/opc/da/Makefile.omdev.mingw +++ b/OMCompiler/SimulationRuntime/opc/da/Makefile.omdev.mingw @@ -1,6 +1,10 @@ -# The path to the OMDev-mingw package MUST BE SET! -#OMDEV=$OMDEV -# Test if the needed variables are there... + +# Test if OMDEV is set +ifndef OMDEV + @echo You have to set the OMDEV variabile pointing to your OMDev package root! Exiting.... + @echo See OpenModelica/OMCompiler/README.Windows.md + ABORT +endif top_builddir = ../../.. builddir_bin=$(OMBUILDDIR)/bin diff --git a/OMCompiler/configure.ac b/OMCompiler/configure.ac index 44b9d3a28d3..8ae8a7012b2 100644 --- a/OMCompiler/configure.ac +++ b/OMCompiler/configure.ac @@ -164,9 +164,9 @@ AC_PROG_FC AC_ARG_WITH(msys, [ --with-msys[=no] Point to an msys installation, to setup CPPFLAGS, etc automatically.], [ if echo $host_cpu | grep -q x86_64; then - MINGWNUM=mingw64 + MINGWNUM=ucrt64 else - MINGWNUM=mingw32 + error "No 32-bit support" fi CPPFLAGS="$CPPFLAGS -I$withval/$MINGWNUM/include -I$withval/$MINGWNUM/include/tre" LDFLAGS="$LDFLAGS -L$withval/$MINGWNUM/lib" diff --git a/OMCompiler/omc_config.h b/OMCompiler/omc_config.h index 4bb48b10690..01688e7c66f 100644 --- a/OMCompiler/omc_config.h +++ b/OMCompiler/omc_config.h @@ -1,28 +1,33 @@ /* * This file is part of OpenModelica. * - * Copyright (c) 1998-2013, Linköpings University, - * Department of Computer and Information Science, + * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC), + * c/o Linköpings universitet, Department of Computer and Information Science, * SE-58183 Linköping, Sweden. * * All rights reserved. * - * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THIS OSMC PUBLIC - * LICENSE (OSMC-PL). ANY USE, REPRODUCTION OR DISTRIBUTION OF - * THIS PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THE OSMC - * PUBLIC LICENSE. + * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR + * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. + * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES + * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL + * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. * - * The OpenModelica software and the Open Source Modelica - * Consortium (OSMC) Public License (OSMC-PL) are obtained - * from Linköpings University, either from the above address, - * from the URL: http://www.ida.liu.se/projects/OpenModelica + * The OpenModelica software and the OSMC (Open Source Modelica Consortium) + * Public License (OSMC-PL) are obtained from OSMC, either from the above + * address, from the URLs: + * http://www.openmodelica.org or + * https://github.com/OpenModelica/ or + * http://www.ida.liu.se/projects/OpenModelica, * and in the OpenModelica distribution. * - * This program is distributed WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS + * GNU AGPL version 3 is obtained from: + * https://www.gnu.org/licenses/licenses.html#GPL + * + * This program is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH - * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS - * OF OSMC-PL. + * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. * * See the full OSMC Public License conditions for more details. * @@ -39,7 +44,16 @@ #if !defined(MSYS2_AUTOCONF) && (defined(__MINGW32__) || defined(_MSC_VER)) /* Windows */ -#if defined(__MINGW64__) +#if defined(__MINGW64__) && defined(UCRT64) // MSYS with UCRT64 + +// TODO: I don't like this. +// It's too easy to forget to define UCRT64 and end up with super strange errors. +#define CONFIG_MODELICA_SPEC_PLATFORM "win64" +#define CONFIG_OPENMODELICA_SPEC_PLATFORM "ucrt64" +#define CONFIG_GCC_DUMPMACHINE "x86_64-w64-mingw32" +#define CONFIG_GCC_VERSION __VERSION__ + +#elif defined(__MINGW64__) // MSYS with MINGW64 #define CONFIG_MODELICA_SPEC_PLATFORM "win64" #define CONFIG_OPENMODELICA_SPEC_PLATFORM "mingw64" @@ -88,7 +102,7 @@ #define CONFIG_TRIPLE "" /* adrpo: add -loleaut32 as is used by ExternalMedia */ -#define DEFAULT_LDFLAGS "-fopenmp -Wl,-Bstatic -lregex -ltre -lintl -liconv -lexpat -lpthread -loleaut32 -limagehlp -lhdf5 -lz -lszip -Wl,-Bdynamic" +#define DEFAULT_LDFLAGS "-fopenmp -Wl,-Bstatic -lregex -ltre -lintl -liconv -lexpat -lpthread -loleaut32 -limagehlp -lhdf5 -lz -lsz -Wl,-Bdynamic" #define CONFIG_WITH_OPENMP 1 diff --git a/OMCompiler/omc_config.unix.h.in b/OMCompiler/omc_config.unix.h.in index f68248aba63..0e4900cbacf 100644 --- a/OMCompiler/omc_config.unix.h.in +++ b/OMCompiler/omc_config.unix.h.in @@ -1,3 +1,38 @@ +/* + * This file is part of OpenModelica. + * + * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC), + * c/o Linköpings universitet, Department of Computer and Information Science, + * SE-58183 Linköping, Sweden. + * + * All rights reserved. + * + * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR + * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. + * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES + * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL + * VERSION 3, ACCORDING TO RECIPIENTS CHOICE. + * + * The OpenModelica software and the OSMC (Open Source Modelica Consortium) + * Public License (OSMC-PL) are obtained from OSMC, either from the above + * address, from the URLs: + * http://www.openmodelica.org or + * https://github.com/OpenModelica/ or + * http://www.ida.liu.se/projects/OpenModelica, + * and in the OpenModelica distribution. + * + * GNU AGPL version 3 is obtained from: + * https://www.gnu.org/licenses/licenses.html#GPL + * + * This program is distributed WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH + * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL. + * + * See the full OSMC Public License conditions for more details. + * + */ + /* @configure_input@ */ #define CONFIGURE_COMMANDLINE "Configured @date@ using arguments: '@CONFIGURE_ARGS@'" #define CONFIG_DLL_EXT "@SHREXT@" diff --git a/OMEdit/Makefile.omdev.mingw b/OMEdit/Makefile.omdev.mingw index c0c77303159..7f8113178fb 100644 --- a/OMEdit/Makefile.omdev.mingw +++ b/OMEdit/Makefile.omdev.mingw @@ -5,8 +5,6 @@ endif buildbin=$(OMBUILDDIR)/bin buildlib=$(OMBUILDDIR)/lib/omc -OMDEVMSYS=$(shell cygpath $$OMDEV) - all: omedit CC = gcc @@ -16,7 +14,7 @@ ifeq (gcc,$(findstring gcc,$(CC))) override CFLAGS +=-falign-functions -fstack-protector-all endif AR = ar -CMAKE = cmake # $(OMDEVMSYS)/bin/cmake/bin/cmake +CMAKE = cmake CMAKE_TARGET = "MSYS Makefiles" QMAKE=qmake @@ -25,7 +23,10 @@ builddir_lib=$(OMBUILDDIR)/lib/omc builddir_share=$(OMBUILDDIR)/share/ resourcedir=./OMEditLIB/Resources/nls/ CONFIG_DEFAULT_OPENMODELICAHOME = "$(OMBUILDDIR)/" -LSB_RELEASE = $(shell cmd /c "ver") +# Ugly hack because calling cmd "/c ver" doesn't close the command prompt on some version of MSYS2 +# Automatic path conversion is converting /c to C:\\ +# See https://github.com/msys2/MSYS2-packages/issues/2310 +LSB_RELEASE = $(shell MSYS2_ARG_CONV_EXCL=/c cmd "/c ver") NAME=OMEdit EXE=.exe diff --git a/OMEdit/OMEditGUI/CMakeLists.txt b/OMEdit/OMEditGUI/CMakeLists.txt index 9b13697b404..4f34b91b833 100644 --- a/OMEdit/OMEditGUI/CMakeLists.txt +++ b/OMEdit/OMEditGUI/CMakeLists.txt @@ -18,103 +18,51 @@ if(APPLE) set_target_properties(OMEdit PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist) endif() -install(TARGETS OMEdit - BUNDLE DESTINATION ${OM_MACOS_INSTALL_BUNDLEDIR}) - - -# Install the runtime dependency dlls if we are on MSYS/MinGW. if(OM_OMEDIT_INSTALL_RUNTIME_DLLS AND MINGW) # Escape the environment variable path if(NOT DEFINED ENV{OMDEV}) message(FATAL_ERROR "Environment variable \"OMDEV\" is not set.") endif() - string(REPLACE "\\" "/" OMDEV_ESCAPED "$ENV{OMDEV}") - - # Check if 64 bit if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(MINGWDIR ${OMDEV_ESCAPED}/tools/msys/mingw64/) + string(REPLACE "\\" "/" OMDEV_MSYS_ESCAPED "$ENV{OMDEV}\\tools\\msys") + set(UCRT_DIR "${OMDEV_MSYS_ESCAPED}/ucrt64") + message(STATUS "MSYS environment UCRT64: ${OMDEV}\\tools\\msys") else() - set(MINGWDIR ${OMDEV_ESCAPED}/tools/msys/mingw32/) + message(FATAL_ERROR "No 32-bit version of UCRT available!") + endif() + if(NOT DEFINED ENV{MSYSTEM_PREFIX}) + message(FATAL_ERROR "Environment variable \"MSYSTEM_PREFIX\" is not set.") endif() + string(REPLACE "\\" "/" MSYSTEM_PREFIX_ESCAPED "$ENV{MSYSTEM_PREFIX}") - # Install the Qt plugins directories. Note the slash at the end. - install(DIRECTORY ${MINGWDIR}/share/qt5/plugins/ + # Install the Qt plugins directories + message(STATUS "Installing QT5 plugins from ${MSYSTEM_PREFIX_ESCAPED}/share/qt5/plugins/") + install(DIRECTORY ${MSYSTEM_PREFIX_ESCAPED}/share/qt5/plugins/ # Note the slash at the end! TYPE BIN) - # Install the runtime dlls to the binary folder. + # TODO: This is stupid, but I can't get install with RUNTIME_DEPENDENCIES to run. + # It needs to link to libs that are isntalled to ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}, + # but if I add that to DIRECTORIES it will throw errors on the second run. + set(OMPLOT_LIB_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}OMPlot/OMPlot/OMPlotGUI ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}OMPlot/qwt/src) + set(OMSIMULATOR_LIB_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}OMSimulator/src/OMSimulatorLib) + set(OMCOMPILER_LIB_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}OMCompiler/Compiler/bin) + set(SIMULATION_RUNTIME_LIB_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}OMCompiler/SimulationRuntime/c) + set(GC_RUNTIME_LIB_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}OMCompiler/3rdParty/gc) + set(RUNTIME_LIB_DIRS ${OMPLOT_LIB_DIR} ${OMSIMULATOR_LIB_DIR} ${OMCOMPILER_LIB_DIR} ${SIMULATION_RUNTIME_LIB_DIR} ${GC_RUNTIME_LIB_DIR}) + message(STATUS "install will search for OMEdit runtime dependencies in ${RUNTIME_LIB_DIRS}") + + # TODO: OMPlot should add this? Or OMEdit needs to link to it directly? install(FILES - ${MINGWDIR}/bin/libbrotlicommon.dll - ${MINGWDIR}/bin/libbrotlidec.dll - ${MINGWDIR}/bin/libbz2-1.dll - ${MINGWDIR}/bin/libcrypto-1_1-x64.dll - ${MINGWDIR}/bin/libcurl-4.dll - ${MINGWDIR}/bin/libdouble-conversion.dll - ${MINGWDIR}/bin/libexpat-1.dll - ${MINGWDIR}/bin/libfontconfig-1.dll - ${MINGWDIR}/bin/libfreetype-6.dll - ${MINGWDIR}/bin/libgcc_s_seh-1.dll - ${MINGWDIR}/bin/libgfortran-5.dll - ${MINGWDIR}/bin/libglib-2.0-0.dll - ${MINGWDIR}/bin/libgraphite2.dll - ${MINGWDIR}/bin/libharfbuzz-0.dll - ${MINGWDIR}/bin/libiconv-2.dll - ${MINGWDIR}/bin/libicudt67.dll - ${MINGWDIR}/bin/libicudtd67.dll - ${MINGWDIR}/bin/libicuin67.dll - ${MINGWDIR}/bin/libicuuc67.dll - ${MINGWDIR}/bin/libicuucd67.dll - ${MINGWDIR}/bin/libidn2-0.dll - ${MINGWDIR}/bin/libintl-8.dll - ${MINGWDIR}/bin/libjpeg-8.dll - ${MINGWDIR}/bin/liblzma-5.dll - ${MINGWDIR}/bin/libnghttp2-14.dll - ${MINGWDIR}/bin/libopenblas.dll - ${MINGWDIR}/bin/libOpenThreads.dll - ${MINGWDIR}/bin/libosg.dll - ${MINGWDIR}/bin/libosgDB.dll - ${MINGWDIR}/bin/libosgGA.dll - ${MINGWDIR}/bin/libosgText.dll - ${MINGWDIR}/bin/libosgUtil.dll - ${MINGWDIR}/bin/libosgViewer.dll - ${MINGWDIR}/bin/libpcre-1.dll - ${MINGWDIR}/bin/libpcre2-16-0.dll - ${MINGWDIR}/bin/libpng16-16.dll - ${MINGWDIR}/bin/libpsl-5.dll - ${MINGWDIR}/bin/libquadmath-0.dll - ${MINGWDIR}/bin/libsqlite3-0.dll - ${MINGWDIR}/bin/libssh2-1.dll - ${MINGWDIR}/bin/libssl-1_1-x64.dll - ${MINGWDIR}/bin/libstdc++-6.dll - ${MINGWDIR}/bin/libsystre-0.dll - ${MINGWDIR}/bin/libtre-5.dll - ${MINGWDIR}/bin/libunistring-2.dll - ${MINGWDIR}/bin/libwebp-7.dll - ${MINGWDIR}/bin/libwinpthread-1.dll - ${MINGWDIR}/bin/libwoff2common.dll - ${MINGWDIR}/bin/libwoff2dec.dll - ${MINGWDIR}/bin/libxml2-2.dll - ${MINGWDIR}/bin/libxslt-1.dll - ${MINGWDIR}/bin/libzstd.dll - ${MINGWDIR}/bin/Qt5Core.dll - ${MINGWDIR}/bin/Qt5Gui.dll - ${MINGWDIR}/bin/Qt5Multimedia.dll - ${MINGWDIR}/bin/Qt5MultimediaWidgets.dll - ${MINGWDIR}/bin/Qt5Network.dll - ${MINGWDIR}/bin/Qt5OpenGL.dll - ${MINGWDIR}/bin/Qt5Positioning.dll - ${MINGWDIR}/bin/Qt5PrintSupport.dll - ${MINGWDIR}/bin/Qt5Qml.dll - ${MINGWDIR}/bin/Qt5QmlModels.dll - ${MINGWDIR}/bin/Qt5Quick.dll - ${MINGWDIR}/bin/Qt5Sensors.dll - ${MINGWDIR}/bin/Qt5Svg.dll - ${MINGWDIR}/bin/Qt5WebChannel.dll - ${MINGWDIR}/bin/Qt5WebKit.dll - ${MINGWDIR}/bin/Qt5WebKitWidgets.dll - ${MINGWDIR}/bin/Qt5Widgets.dll - ${MINGWDIR}/bin/Qt5Xml.dll - ${MINGWDIR}/bin/Qt5XmlPatterns.dll - ${MINGWDIR}/bin/zlib1.dll + ${MSYSTEM_PREFIX_ESCAPED}/bin/Qt5OpenGL.dll TYPE BIN) + + install(TARGETS OMEdit + RUNTIME_DEPENDENCIES + DIRECTORIES ${MSYSTEM_PREFIX_ESCAPED}/bin ${RUNTIME_LIB_DIRS} + PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" + POST_EXCLUDE_REGEXES ".*system32/.*\\.dll") +else() + install(TARGETS OMEdit + BUNDLE DESTINATION ${OM_MACOS_INSTALL_BUNDLEDIR}) endif() diff --git a/OMEdit/OMEditGUI/OMEditGUI.win.config.pri b/OMEdit/OMEditGUI/OMEditGUI.win.config.pri index e33c7673f50..c38b5ef0134 100644 --- a/OMEdit/OMEditGUI/OMEditGUI.win.config.pri +++ b/OMEdit/OMEditGUI/OMEditGUI.win.config.pri @@ -31,11 +31,20 @@ OPENMODELICAHOME = $$(OMBUILDDIR) # define used for OpenModelica C-API DEFINES += IMPORT_INTO=1 -# win32 vs. win64 -contains(QT_ARCH, i386) { # 32-bit - QMAKE_LFLAGS += -Wl,--stack,16777216,--enable-auto-import,--large-address-aware -} else { # 64-bit - QMAKE_LFLAGS += -Wl,--stack,33554432,--enable-auto-import +QMAKE_LFLAGS += -Wl,--stack,33554432,--enable-auto-import + +LIBS += -L$$(OMBUILDDIR)/../OMEdit/OMEditLIB/Debugger/Parser -lGDBMIParser \ + -L$$(OMBUILDDIR)/lib/omc -L$$(OMBUILDDIR)/../OMParser/install/lib -Wl,-Bstatic -lOMParser -lantlr4-runtime -Wl,-Bdynamic -lomantlr3 -lOMPlot -lomqwt -lomopcua -lzmq \ + -lOpenModelicaCompiler -lOpenModelicaRuntimeC -lfmilib -lomcgc -lpthread -lshlwapi \ + -lws2_32 \ + -L$$(OMBUILDDIR)/bin -lOMSimulator + +# libbdf links differently on newer MSYS2, e.g. when using UCRT64 +msystem_prefix = $$(MSYSTEM_PREFIX) +contains(msystem_prefix, .*ucrt64.*) { + BFD_LIBS = -lbfd -lintl -liberty -lsframe -lzstd -lzlib +} else { + BFD_LIBS = -lbfd -lintl -liberty -lzlib } CONFIG(release, debug|release) { # release @@ -45,25 +54,10 @@ CONFIG(release, debug|release) { # release # -s will remove all symbol table and relocation information from the executable. QMAKE_CXXFLAGS += -g -DUA_DYNAMIC_LINKING QMAKE_LFLAGS_RELEASE = - # win32 vs. win64 - contains(QT_ARCH, i386) { # 32-bit - LIBS += -L$$(OMDEV)/tools/msys/mingw32/lib/binutils -L$$(OMDEV)/tools/msys/mingw32/bin - INCLUDEPATH += $$(OMDEV)/tools/msys/mingw32/include/binutils - } else { # 64-bit - LIBS += -L$$(OMDEV)/tools/msys/mingw64/lib/binutils -L$$(OMDEV)/tools/msys/mingw64/bin - INCLUDEPATH += $$(OMDEV)/tools/msys/mingw64/include/binutils - } - LIBS += -limagehlp -lbfd -lintl -liberty -llibosg.dll -llibosgViewer.dll -llibOpenThreads.dll -llibosgDB.dll -llibosgGA.dll + LIBS += -L$$(MSYSTEM_PREFIX)/lib/binutils -L$$(MSYSTEM_PREFIX)/bin + INCLUDEPATH += $$(MSYSTEM_PREFIX)/include/binutils + LIBS += -limagehlp $$BFD_LIBS -llibosg.dll -llibosgViewer.dll -llibOpenThreads.dll -llibosgDB.dll -llibosgGA.dll } else { # debug - contains(QT_ARCH, i386) { # 32-bit - LIBS += -L$$(OMDEV)/tools/msys/mingw32/bin - } else { # 64-bit - LIBS += -L$$(OMDEV)/tools/msys/mingw64/bin - } + LIBS += -L$$(MSYSTEM_PREFIX)/bin LIBS += -llibosg.dll -llibosgViewer.dll -llibOpenThreads.dll -llibosgDB.dll -llibosgGA.dll } -LIBS += -L$$(OMBUILDDIR)/../OMEdit/OMEditLIB/Debugger/Parser -lGDBMIParser \ - -L$$(OMBUILDDIR)/lib/omc -L$$(OMBUILDDIR)/../OMParser/install/lib -Wl,-Bstatic -lOMParser -lantlr4-runtime -Wl,-Bdynamic -lomantlr3 -lOMPlot -lomqwt -lomopcua -lzmq \ - -lOpenModelicaCompiler -lomcruntime -lOpenModelicaRuntimeC -lfmilib -lzlib -lomcgc -lpthread -lshlwapi \ - -lws2_32 \ - -L$$(OMBUILDDIR)/bin -lOMSimulator diff --git a/OMEdit/OMEditGUI/main.cpp b/OMEdit/OMEditGUI/main.cpp index 4af49a329b4..f2187125870 100644 --- a/OMEdit/OMEditGUI/main.cpp +++ b/OMEdit/OMEditGUI/main.cpp @@ -48,7 +48,9 @@ extern "C" { #include #ifdef QT_NO_DEBUG + #if defined(_WIN32) + #include "CrashReport/backtrace.h" static char *g_output = NULL; @@ -60,7 +62,7 @@ LONG WINAPI exceptionFilter(LPEXCEPTION_POINTERS info) struct output_buffer ob; output_init(&ob, g_output, BUFFER_MAX); if (!SymInitialize(GetCurrentProcess(), 0, TRUE)) { - output_print(&ob,"Failed to init symbol context\n"); + output_print(&ob, "Failed to init symbol context\n"); } else { bfd_init(); struct bfd_set *set = (bfd_set*)calloc(1,sizeof(*set)); @@ -72,8 +74,11 @@ LONG WINAPI exceptionFilter(LPEXCEPTION_POINTERS info) CrashReportDialog *pCrashReportDialog = new CrashReportDialog(QString(g_output)); pCrashReportDialog->exec(); exit(1); + return EXCEPTION_CONTINUE_SEARCH; } + #else // Unix + #include #include @@ -121,12 +126,14 @@ void signalHandler(int signalNumber) } free(symbollist); } + // show the CrashReportDialog CrashReportDialog *pCrashReportDialog = new CrashReportDialog(stackTrace); pCrashReportDialog->exec(); exit(signalNumber); } #endif // #if defined(_WIN32) + #endif // #ifdef QT_NO_DEBUG void printOMEditUsage() @@ -150,10 +157,26 @@ int main(int argc, char *argv[]) { MMC_INIT(); MMC_TRY_TOP() - /* Do not use the signal handler OR exception filter if user is building a debug version. Perhaps the user wants to use gdb. */ + // if user asks for --help + for(int i = 1; i < argc; i++) { + if (strcmp(argv[i], "--help") == 0) { + printOMEditUsage(); + return 0; + } + } + Q_INIT_RESOURCE(resource_omedit); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif + OMEditApplication a(argc, argv, threadData); + +// Do not use the signal handler OR exception filter if user is building a debug version. +// Perhaps the user wants to use gdb. +// moved the setting of the handler *after* OMEditApplication application definition +// as otherwise it did not work with msys2-ucrt64 #ifdef QT_NO_DEBUG #if defined(_WIN32) - SetUnhandledExceptionFilter(exceptionFilter); + LPTOP_LEVEL_EXCEPTION_FILTER top_filter = SetUnhandledExceptionFilter(exceptionFilter); #else /* Abnormal termination (abort) */ signal(SIGABRT, signalHandler); @@ -165,18 +188,7 @@ int main(int argc, char *argv[]) signal(SIGFPE, signalHandler); #endif // #ifdef WIN32 #endif // #ifdef QT_NO_DEBUG - // if user asks for --help - for(int i = 1; i < argc; i++) { - if (strcmp(argv[i], "--help") == 0) { - printOMEditUsage(); - return 0; - } - } - Q_INIT_RESOURCE(resource_omedit); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); -#endif - OMEditApplication a(argc, argv, threadData); + return a.exec(); MMC_CATCH_TOP(return execution_failed()); diff --git a/OMEdit/OMEditLIB/MainWindow.cpp b/OMEdit/OMEditLIB/MainWindow.cpp index 8a95ae12628..89f3924e890 100644 --- a/OMEdit/OMEditLIB/MainWindow.cpp +++ b/OMEdit/OMEditLIB/MainWindow.cpp @@ -5221,6 +5221,11 @@ AboutOMEditDialog::AboutOMEditDialog(MainWindow *pMainWindow) pOMContributorsScrollArea->setFrameShape(QFrame::NoFrame); pOMContributorsScrollArea->setWidgetResizable(true); pOMContributorsScrollArea->setWidget(mpOMContributorsLabel); + // crash test button + QPushButton *pCrashTestButton = new QPushButton(Helper::crashTest); + pCrashTestButton->setAutoDefault(false); + pCrashTestButton->setToolTip("Tests if the crash report functionality works properly"); + connect(pCrashTestButton, SIGNAL(clicked()), SLOT(crashTest())); // report button QPushButton *pReportButton = new QPushButton(Helper::reportIssue); pReportButton->setAutoDefault(false); @@ -5231,6 +5236,7 @@ AboutOMEditDialog::AboutOMEditDialog(MainWindow *pMainWindow) connect(pCloseButton, SIGNAL(clicked()), SLOT(reject())); // create buttons box QDialogButtonBox *pButtonBox = new QDialogButtonBox(Qt::Horizontal); + pButtonBox->addButton(pCrashTestButton, QDialogButtonBox::ActionRole); pButtonBox->addButton(pReportButton, QDialogButtonBox::ActionRole); pButtonBox->addButton(pCloseButton, QDialogButtonBox::ActionRole); // logo label @@ -5292,6 +5298,21 @@ void AboutOMEditDialog::showReportIssue() pCrashReportDialog->exec(); } +/*! + * \brief AboutOMEditDialog::crashTest + * Attempts to crash OMEdit to test the crash test reporting feature. + */ +void AboutOMEditDialog::crashTest() +{ + struct crash { + int a; + void *b; + }; + struct crash *x = NULL; + fprintf(stderr, "%d %p\n", x->a, x->b); +} + + /*! * \class MessageTab * \brief Creates a tab that mimicks the tab of Message Browser. diff --git a/OMEdit/OMEditLIB/MainWindow.h b/OMEdit/OMEditLIB/MainWindow.h index 318f96bdd73..64eae733f95 100644 --- a/OMEdit/OMEditLIB/MainWindow.h +++ b/OMEdit/OMEditLIB/MainWindow.h @@ -637,6 +637,7 @@ class AboutOMEditDialog : public QDialog Label *mpOMContributorsLabel; public slots: void showReportIssue(); + void crashTest(); private slots: void readOMContributors(QNetworkReply *pNetworkReply); }; diff --git a/OMEdit/OMEditLIB/OMEditLIB.pro b/OMEdit/OMEditLIB/OMEditLIB.pro index da26c80ec61..af5cfc23c92 100644 --- a/OMEdit/OMEditLIB/OMEditLIB.pro +++ b/OMEdit/OMEditLIB/OMEditLIB.pro @@ -86,11 +86,8 @@ equals(_OM_ENABLE_ENCRYPTION, yes) { # On older msys the include directory for binutils is in binutils # On recent (November 2022) MSYS2 this is no longer needed. -contains(QT_ARCH, i386) { # 32-bit - INCLUDEPATH += $$(OMDEV)/tools/msys/mingw32/include/binutils -} else { # 64-bit - INCLUDEPATH += $$(OMDEV)/tools/msys/mingw64/include/binutils -} + INCLUDEPATH += $$(OMDEV)/tools/msys/include/binutils + OPENMODELICAHOME = $$(OMBUILDDIR) host_short = diff --git a/OMEdit/OMEditLIB/Simulation/SimulationOutputWidget.cpp b/OMEdit/OMEditLIB/Simulation/SimulationOutputWidget.cpp index 1dd57e8aad5..602225a9f28 100644 --- a/OMEdit/OMEditLIB/Simulation/SimulationOutputWidget.cpp +++ b/OMEdit/OMEditLIB/Simulation/SimulationOutputWidget.cpp @@ -56,6 +56,10 @@ #include #include +extern "C" { +extern const char* System_openModelicaPlatform(); +} + /*! * \class SimulationOutputTree * \brief A tree based structure for simulation output messages. @@ -572,15 +576,10 @@ void SimulationOutputWidget::compileModel() if (OptionsDialog::instance()->getSimulationPage()->getUseStaticLinkingCheckBox()->isChecked()) { linkType = "static"; } -#if defined(__MINGW32__) && defined(__MINGW64__) /* on 64 bit */ - const char* omPlatform = "mingw64"; -#else - const char* omPlatform = "mingw32"; -#endif SimulationPage *pSimulationPage = OptionsDialog::instance()->getSimulationPage(); args << mSimulationOptions.getOutputFileName() << pSimulationPage->getTargetBuildComboBox()->itemData(pSimulationPage->getTargetBuildComboBox()->currentIndex()).toString() - << omPlatform << "parallel" << linkType << numProcs << "0"; + << System_openModelicaPlatform() << "parallel" << linkType << numProcs << "0"; QString compilationProcessPath = QString(Helper::OpenModelicaHome) + "/share/omc/scripts/Compile.bat"; writeCompilationOutput(QString("%1 %2\n").arg(compilationProcessPath).arg(args.join(" ")), Qt::blue); mpCompilationProcess->start(compilationProcessPath, args); diff --git a/OMEdit/OMEditLIB/Util/Helper.cpp b/OMEdit/OMEditLIB/Util/Helper.cpp index e90c3a202e4..3cfefefcc8f 100644 --- a/OMEdit/OMEditLIB/Util/Helper.cpp +++ b/OMEdit/OMEditLIB/Util/Helper.cpp @@ -354,6 +354,7 @@ QString Helper::stepReturn; QString Helper::attachToRunningProcess; QString Helper::attachToRunningProcessTip; QString Helper::reportIssue; +QString Helper::crashTest; QString Helper::parsingFailedJson; QString Helper::expandAll; QString Helper::collapseAll; @@ -662,6 +663,7 @@ void Helper::initHelperVariables() Helper::attachToRunningProcess = tr("Attach to Running Process"); Helper::attachToRunningProcessTip = tr("Attach the debugger to running process"); Helper::reportIssue = tr("Report Issue"); + Helper::crashTest = tr("Crash Test"); Helper::parsingFailedJson = tr("Parsing of JSON file failed"); Helper::expandAll = tr("Expand All"); Helper::collapseAll = tr("Collapse All"); diff --git a/OMEdit/OMEditLIB/Util/Helper.h b/OMEdit/OMEditLIB/Util/Helper.h index 08e887dda0e..eb6943e0e81 100644 --- a/OMEdit/OMEditLIB/Util/Helper.h +++ b/OMEdit/OMEditLIB/Util/Helper.h @@ -356,6 +356,7 @@ class Helper : public QObject static QString attachToRunningProcess; static QString attachToRunningProcessTip; static QString reportIssue; + static QString crashTest; static QString parsingFailedJson; static QString expandAll; static QString collapseAll; diff --git a/OMEdit/OMEditLIB/Util/Utilities.cpp b/OMEdit/OMEditLIB/Util/Utilities.cpp index 2ed89f56d30..82ac584a9a2 100644 --- a/OMEdit/OMEditLIB/Util/Utilities.cpp +++ b/OMEdit/OMEditLIB/Util/Utilities.cpp @@ -53,6 +53,10 @@ #include #include +extern "C" { +extern const char* System_openModelicaPlatform(); +} + SplashScreen *SplashScreen::mpInstance = 0; SplashScreen *SplashScreen::instance() @@ -973,19 +977,24 @@ QGenericMatrix<3,3, double> Utilities::getRotationMatrix(QGenericMatrix<3,1,doub QString Utilities::getGDBPath() { #if defined(_WIN32) -#if defined(__MINGW32__) && !defined(__MINGW64__) - const char *sgdb = "/tools/msys/mingw32/bin/gdb.exe"; -#endif -#if defined(__MINGW64__) - const char *sgdb = "/tools/msys/mingw64/bin/gdb.exe"; -#endif const char *OMDEV = getenv("OMDEV"); - if (QString(OMDEV).isEmpty()) { - return QString(Helper::OpenModelicaHome).append(sgdb); - } else { + const char *MSYSTEM_PREFIX = getenv("MSYSTEM_PREFIX"); + const char* msysEnv = System_openModelicaPlatform(); /* "ucrt64" or "mingw64" */ + + // MSYSTEM_PREFIX is set: /bin/gdb.exe + if (!QString(MSYSTEM_PREFIX).isEmpty()) { + QString qMSYSTEM_PREFIX = QString(MSYSTEM_PREFIX).replace("\\", "/"); + return QString(qMSYSTEM_PREFIX) + QString("/bin/gdb.exe"); + } + + // OMDEV is set: /tools/msys//bin/gdb.exe + if (!QString(OMDEV).isEmpty()) { QString qOMDEV = QString(OMDEV).replace("\\", "/"); - return QString(qOMDEV).append(sgdb); + return QString(qOMDEV) + QString("/tools/msys/") + QString(msysEnv) + QString("/bin/gdb.exe"); } + + // Default: /tools/msys//bin/gdb.exe + return QString(Helper::OpenModelicaHome) + QString("/tools/msys/") + QString(msysEnv) + QString("bin/gdb.exe"); #else return "gdb"; #endif diff --git a/OMNotebook/OMNotebook/OMNotebookGUI/Makefile.omdev.mingw b/OMNotebook/OMNotebook/OMNotebookGUI/Makefile.omdev.mingw index c9846aedd85..75519fb5af2 100644 --- a/OMNotebook/OMNotebook/OMNotebookGUI/Makefile.omdev.mingw +++ b/OMNotebook/OMNotebook/OMNotebookGUI/Makefile.omdev.mingw @@ -8,7 +8,7 @@ resourcedir=./Resources/nls/ CONFIG_DEFAULT_OPENMODELICAHOME = "$(OMBUILDDIR)/" GIT_SHA = $(shell git describe --match "v*.*" --always) -LSB_RELEASE = $(shell cmd /c "ver") +LSB_RELEASE = $(shell cmd "/c ver") ifeq (MINGW32,$(findstring MINGW32,$(shell uname))) PLATFORM_ARCH = (32-bit) diff --git a/OMNotebook/README.md b/OMNotebook/README.md index 3a6aba9bb63..dc75105aa27 100644 --- a/OMNotebook/README.md +++ b/OMNotebook/README.md @@ -17,8 +17,7 @@ Follow the instructions matching your OS: If you used MSYS Makefiles to compile OpenModelica you need one additional step: -Start a MSYS terminal `$OMDEV\tools\msys\mingw64.exe` (64 bit) or -`$OMDEV\tools\msys\mingw32.exe` (32 bit) and run: +Start a MSYS terminal `$OMDEV\tools\msys\ucrt64.exe` and run: ```bash $ cd /path/to/OpenModelica diff --git a/OMPlot/README.md b/OMPlot/README.md index 79f62ddf053..452e78e46be 100644 --- a/OMPlot/README.md +++ b/OMPlot/README.md @@ -16,8 +16,7 @@ Follow the instructions matching your OS: If you used MSYS Makefiles to compile OpenModelica you need one additional step: -Start a MSYS terminal `$OMDEV\tools\msys\mingw64.exe` (64 bit) or -`$OMDEV\tools\msys\mingw32.exe` (32 bit) and run: +Start a MSYS terminal `$OMDEV\tools\msys\ucrt64.exe` and run: ```bash $ cd /path/to/OpenModelica diff --git a/OMSens b/OMSens index 8216eaefbb4..0d804d597bc 160000 --- a/OMSens +++ b/OMSens @@ -1 +1 @@ -Subproject commit 8216eaefbb4ea2ff0c7a17a3487dcc2a8a17667d +Subproject commit 0d804d597bc385686856d453cc830fad4923fa3e diff --git a/OMShell/README.md b/OMShell/README.md index 9ab72e65f9f..27c0835dbbd 100644 --- a/OMShell/README.md +++ b/OMShell/README.md @@ -16,8 +16,7 @@ Follow the instructions matching your OS: If you used MSYS Makefiles to compile OpenModelica you need one additional step: -Start a MSYS terminal `$OMDEV\tools\msys\mingw64.exe` (64 bit) or -`$OMDEV\tools\msys\mingw32.exe` (32 bit) and run: +Start a MSYS terminal `$OMDEV/tools/msys/ucrt64.exe` and run: ```bash $ cd /path/to/OpenModelica diff --git a/README.cmake.md b/README.cmake.md index 1c1be26bcb1..f86cf201de7 100644 --- a/README.cmake.md +++ b/README.cmake.md @@ -12,7 +12,7 @@ - [3.3.1.2 Homebrew](#3312-homebrew) - [3.3.2 Building](#332-building) - [3.3.3 Common macOS issues](#333-common-macos-issues) - - [3.4. Windows MSYS/MinGW](#34-windows-msysmingw) + - [3.4. Windows MSYS/UCRT64](#34-windows-msysucrt64) - [4. Configuration Options.](#4-configuration-options) - [4.1. OpenModelica Specific Configuration Options](#41-openmodelica-specific-configuration-options) - [4.1.1. OpenModelica Options](#411-openmodelica-options) @@ -62,9 +62,8 @@ MetaModelica compilation involves a lot of recompilation of unmodified C files b new time stamps for generated header files. ccache will practically reduce the cost of these types of recompilations to a no-op. -It is available for linux (of course) and, fortunatelly, for MSYS/MinGW as well -(mingw-w64-x86_64-ccache and mingw-w64-i686-ccache). It is not part of OMDev at the moment -but it will be in the next iteration. +It is available for Linux (of course) and, fortunately, for MSYS/UCRT64 as well +(mingw-w64-ucrt-x86_64-ccache). # 3. Usage ## 3.1. General Notes @@ -236,9 +235,9 @@ If you encounter some errors while configuring, building, or simulating-with Ope export PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH ``` -## 3.4. Windows MSYS/MinGW +## 3.4. Windows MSYS/UCRT64 -There is nothing special about MSYS/MinGW if you are familiar with it. Just a few hints: +There is nothing special about MSYS/UCRT64 if you are familiar with it. Just a few hints: - The generator should be "MSYS Makefiles". This is not what CMake chooses by default for Windows. @@ -316,15 +315,7 @@ support with Ipopt. Enabling this requires having a working Fortran compiler. `OM_OMEDIT_ENABLE_TESTS` Enable testing and build the OMEdit Testsuite. `OM_OMEDIT_INSTALL_RUNTIME_DLLS` allows you to enable/disable the installation of the -required runtime DLLs for MSYS/MinGW builds. - -You should disable this if you are either - - - using OMDev but plan to start/launch all the GUI executables exclusively from a - MSYS/MinGW shell and never from the Windows explorer. - - - Using OMDev or other MSYS/MinGW setup and have specified the MSYS/MinGW system - directories as your CMake install directory. +required runtime DLLs for MSYS/UCRT64 builds. ### 4.1.4. OpenModelica/OMShell Options diff --git a/cmake/modules/Findbinutils.cmake b/cmake/modules/Findbinutils.cmake index 50cbb82c02f..35e774c8d57 100644 --- a/cmake/modules/Findbinutils.cmake +++ b/cmake/modules/Findbinutils.cmake @@ -1,27 +1,39 @@ -# This small module finds and sets up -# libbfd from binutils which is need for providing backtrace support for OMEdit. -# The library is not installed in the standard location on MinGW. It is in -# lib/binutils. This module makes sure that it can be found. -# It exports an imported target 'binutils::bfd' for the library -# which brings in the dependency 'libiberty' (binutils::iberty) library with it. +# This small module (which is not as 'proper' as it should be) finds and sets up +# libbfd from binutils. libbfd is need for providing crash reporting backtrace +# support for OMEdit on Windows (OMDev/MinGW). Unfortunately neither CMake nor +# the binutils people provide a CMake module or config files to set up the libraries. + +# This small module tries to find libbfd as well as its dependencies. Currently these +# are libiberty, libsframe, libzstd and libintl. The first two are part of the binutils packages +# so we manually manage the finding here. + +# zstd is a separate package and comes with its own CMake config files +# (at least on recent versions) so we use that. That is perfect. + +# libintl is also a separate package and a find module is provided by CMake +# itself for now (albeit old style, i.e, no imported targets) + +# Finally this module exports an imported targets 'binutils::bfd', 'binutils::iberty' and +# binutils::sframe to be used as needed. if(binutils_FOUND) return() endif() find_library(LIBBFD_LIBRARY - NAMES libbfd.a - PATH_SUFFIXES binutils) + NAMES libbfd.a) find_library(LIBIBERTY_LIBRARY - NAMES libiberty.a - PATH_SUFFIXES binutils) + NAMES libiberty.a) + +find_library(LIBSFRAME_LIBRARY + NAMES libsframe.a) + if(MINGW) find_path(BINUTILS_INCLUDE_DIR bfd.h - PATHS include - PATH_SUFFIXES binutils) + PATHS include) endif() include (FindPackageHandleStandardArgs) @@ -29,22 +41,28 @@ include (FindPackageHandleStandardArgs) # handle the QUIETLY and REQUIRED arguments and set binutils_FOUND to TRUE if all listed variables are TRUE find_package_handle_standard_args(binutils - REQUIRED_VARS LIBBFD_LIBRARY LIBIBERTY_LIBRARY BINUTILS_INCLUDE_DIR + REQUIRED_VARS LIBBFD_LIBRARY LIBIBERTY_LIBRARY LIBSFRAME_LIBRARY BINUTILS_INCLUDE_DIR HANDLE_COMPONENTS) -mark_as_advanced(LIBBFD_LIBRARY LIBIBERTY_LIBRARY BINUTILS_INCLUDE_DIR) +mark_as_advanced(LIBBFD_LIBRARY LIBIBERTY_LIBRARY LIBSFRAME_LIBRARY BINUTILS_INCLUDE_DIR) if(binutils_FOUND) find_package(Intl REQUIRED) + find_package(zstd CONFIG REQUIRED) add_library(binutils::iberty STATIC IMPORTED) set_target_properties(binutils::iberty PROPERTIES IMPORTED_LOCATION ${LIBIBERTY_LIBRARY}) + add_library(binutils::sframe STATIC IMPORTED) + set_target_properties(binutils::sframe PROPERTIES IMPORTED_LOCATION ${LIBSFRAME_LIBRARY}) + add_library(binutils::bfd STATIC IMPORTED) set_target_properties(binutils::bfd PROPERTIES IMPORTED_LOCATION ${LIBBFD_LIBRARY}) set_target_properties(binutils::bfd PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${BINUTILS_INCLUDE_DIR}) target_link_libraries(binutils::bfd INTERFACE binutils::iberty) + target_link_libraries(binutils::bfd INTERFACE binutils::sframe) + target_link_libraries(binutils::bfd INTERFACE zstd::libzstd_static) target_link_libraries(binutils::bfd INTERFACE ${Intl_LIBRARIES}) endif() diff --git a/common/config.guess b/common/config.guess index dc0a6b29976..c88cfbc859d 100644 --- a/common/config.guess +++ b/common/config.guess @@ -887,10 +887,10 @@ EOF i*:CYGWIN*:*) echo "$UNAME_MACHINE"-pc-cygwin exit ;; - *:MINGW64*:*) + *:MINGW64*:*) echo "$UNAME_MACHINE"-pc-mingw64 exit ;; - *:MINGW*:*) + *:MINGW*:*) echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) diff --git a/omsimulator.cmake b/omsimulator.cmake new file mode 100644 index 00000000000..7de7cc1bd76 --- /dev/null +++ b/omsimulator.cmake @@ -0,0 +1,133 @@ + +set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME omsimulator) + + +include(ExternalProject) +include(ProcessorCount) +ProcessorCount(NUM_PROCESSPRS) + + +ExternalProject_Add(OMSimulator_external + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator + PREFIX OMSimulator + #--Configure step------------- + CONFIGURE_COMMAND COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator + -j${NUM_PROCESSPRS} + config-3rdParty + BUILD_TYPE=${CMAKE_BUILD_TYPE} + CERES=OFF + OMTLM=OFF + host_short=${CMAKE_LIBRARY_ARCHITECTURE} + CMAKE="${CMAKE_COMMAND}" + COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator + -j${NUM_PROCESSPRS} + config-OMSimulator + OMTLM=OFF + BUILD_TYPE=${CMAKE_BUILD_TYPE} + OMSYSIDENT=OFF + OMBUILDDIR=${CMAKE_CURRENT_BINARY_DIR}/OMSimulator + host_short=${CMAKE_LIBRARY_ARCHITECTURE} + CMAKE="${CMAKE_COMMAND}" + #--Build step----------------- + BUILD_ALWAYS 1 + BUILD_COMMAND COMMAND ${CMAKE_MAKE_PROGRAM} -C ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator + -j${NUM_PROCESSPRS} + OMSimulator + OMTLM=OFF + BUILD_TYPE=${CMAKE_BUILD_TYPE} + OMBUILDDIR=${CMAKE_CURRENT_BINARY_DIR}/OMSimulator + host_short=${CMAKE_LIBRARY_ARCHITECTURE} + CMAKE="${CMAKE_COMMAND}" + #--Install step--------------- + INSTALL_COMMAND "" +) + +set_target_properties(OMSimulator_external PROPERTIES EXCLUDE_FROM_ALL TRUE) + + +add_library(libOMSimulator SHARED IMPORTED) +add_dependencies(libOMSimulator OMSimulator_external) + +# The location where the lib is located and whether it comes with an import lib, depends on the OS/Env. +if(MINGW) + set_target_properties(libOMSimulator PROPERTIES + IMPORTED_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/bin/libOMSimulator.dll + # The dll.a import lib. It is located in the same dir as the dll right now. + IMPORTED_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/bin/libOMSimulator.dll.a + ) + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/bin/ + DESTINATION ${CMAKE_INSTALL_BINDIR} + # There is a libOMSimulator.dll.a in the bin dir. It should go in lib. + PATTERN *.dll.a EXCLUDE) + + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/lib/ + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + # There is a libOMSimulator.dll.a in the bin dir. It should go in lib. + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/bin/libOMSimulator.dll.a + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/share/ + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}) + +elseif(MSVC) + # For now print error and bail out. It should be the same as Mingw except we need to check where the .lib file is located. + message(FATAL_ERROR "Importing of OMSimulator is not implemented correctly for MSVC. Adjust the MINGW implementation to where the dll and lib files are expected.") +else() + + # if host_short (= CMAKE_LIBRARY_ARCHITECTURE) is empty (e.g on Arch Linux systems or macOS), OMSimulator does not + # add the omc/ part to the library location. (See OMSimulator/Makefile:88-93) + if(CMAKE_LIBRARY_ARCHITECTURE) + set(OMSIMULATORLIB_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/lib/${CMAKE_LIBRARY_ARCHITECTURE}/omc/) + else() + set(OMSIMULATORLIB_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/lib/) + endif() + + set(LIB_OMSIMULATOR_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}OMSimulator${CMAKE_SHARED_LIBRARY_SUFFIX}) + + set_target_properties(libOMSimulator PROPERTIES + IMPORTED_LOCATION ${OMSIMULATORLIB_LOCATION}/${LIB_OMSIMULATOR_NAME} + ) + + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/bin/ + DESTINATION ${CMAKE_INSTALL_BINDIR} + USE_SOURCE_PERMISSIONS) + + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + + install(DIRECTORY ${OMSIMULATORLIB_LOCATION} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + + # There is another folder called OMSimulator inside the lib (just lib/ not lib//..) folder that + # contains some python files as well some duplicate shared libs. + # I am guessing the python files are expected to be in /OMSimulator/. + # So copy them there (only the python files though. No point in having duplicate shared libs) + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/lib/OMSimulator/ + DESTINATION ${CMAKE_INSTALL_LIBDIR}/OMSimulator + FILES_MATCHING + PATTERN "*.py" + # # if ${CMAKE_LIBRARY_ARCHITECTURE} is not an empty string OMSimulator will create a dedicated + # # folder for the shared libs. We have excluded them with the *.py pattern so avoid creating the + # # empty directory on install. + ## Unfortunately, when it is actually empty this will result in an invalid CMake command. + # PATTERN ${CMAKE_LIBRARY_ARCHITECTURE} EXCLUDE + ) + + + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/OMSimulator/share/ + DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}) + + +endif() + +set_target_properties(libOMSimulator PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/OMSimulator/src/OMSimulatorLib +)