CMake configuration support for OpenModelica/OMCompiler (#6737)
* [cmake] Initial cmake configuration support.
* [cmake] Add OMParser to compilation.
- Uses two macros for generating the C files from the antlr sources. One is used for antlr files that depend on base_modelica_lexer. The other is used for only Modelica.g right now.
* [cmake] Move the antlr target macros new file.
- They clutter things in the main cmake file.
* [cmake] Add CMake support for OMCompiler/runtime.
- OMCompiler/runtime cannow be compiled using cmake. - Right now there is missing symbols from dgsev. I am not sure yet where to add them. Maybe dgsev can be added to simulationRuntime/c libraries. Other than that OMCompiler/runtime can be compiled with all symbols found at the moment.
- We now use proper qualified names for libraries, e.g. omc::3rd::gc for the gc-lib in 3rdParty/gc. These names are added as aliases to the actual library. Use these everywhere. There should not be a single use of the actual library names.
* [cmake] Update 3rdParty submodule.
- Changes have been made to the submodule on mahge/cmake_config. It is mostly some minor fixes and a 3rdParty top level CMakeLists.txt
* [cmake] Add prefixes to 3rdParty cmake options.
- CMinPack shared library option is prefixed so that it does not conflict with other libraries build types. - BUILD_SHARED_LIBS -> CMINPACK_BUILD_SHARED_LIBS
- Sundials options are prefixed so that they do not conflict with other libraries. - KLU_ENABLE -> SUNDIALS_KLU_ENABLE - LAPACK_ENABLE -> SUNDIALS_LAPACK_ENABLE
* [cmake] Add Susan to MetaModelica compilation.
- A macro is added for compiling a given susan template file to a MetaModelica .mo file using omc.
For convenience, a list of all the generated mo files is added to the cmake variable `TPL_OUTPUT_MO_FILES` by the macro.
- There is an inteface include directory defined for `fmilib` in `3rdParty/CMakeLists.txt`. That means we do not need to explicitly add the include directory here. Until FMIL sorts out their configuration usage we can deal with it like this.
- 3rdParty module is updated.
* [cmake] Remove the temporary template target.
- It was added just for testing whiled developing.
- The generated mo files are now used by the libOpenModelica target. So the tpl files will be translated to mo if the mo files are missing.
* [cmake] Add alias target for libomparse
- OMCompiler/Parser (omparse) -> omc::parser
* [CMake] Add runtime/omcgraphstream.
- Add compilation for libomcgraphstream. Links to 3rdParty/graphstream libnetstream.a
* [cmake] Clarify BootstrappingHeader inclusion.
- We include OpenModelicaBootstrappingHeader.h with a relative path now.
- If OMC_BOOTSTRAPPING is defined it is included from Compiler/boot/tarball-include. Otherwise include it from Compiler/.
We can, of course, give `OMCompiler/Compiler` dir as an include directory to the libraries in runtime. However, there is an `omc_fil.h` in Compiler/Util (it should not be there but it is there for now) there is also an `omc_file.h` in SimulationRuntime/c/util.
We link to OpenModelicaRuntime which is built in `SimulationRuntime/c/` and we automatically provide `SimulationRuntime/c/` as an include dir for things that link to this library. This means for example runtime/`omcruntime.a` will get `SimulationRuntime/c/` as an include dir automatically when linking to `OpenModelicaRuntime`.
If we give both `Compiler/` and `SimulationRuntime/c/` we essentially have two files that can be reached as `#include "util/omc_file.h"`. We should try to avoid manually adding target_include dirs anyway. for this reason OMCompiler/Compiler/ is not given as an include dir now. It was only needed for `OpenModelicaBootstrappingHeader.h`. `OpenModelicaBootstrappingHeader.h` is now included by relative path.
- Fix OpenModelicaBootstrappingHeader inclusion on Parser/. If OMC_BOOTSTRAPPING is defined include it from Compiler/boot/tarball-include. Otherwise include it from Compiler/.
- Some target_include_directories are not needed anymore. include directory propagation is managed by what libraries a target links to, i.e., cmake will automatically propagate the public include directories of a given library when the library is linked to some other target.
* [cmake] Link omcruntime to blas.
- I am not sure which blas we are supposed to use. There are some sources in 3rdParty/dgesv. I will check later if they need to be used somewhere.
* [cmake] Do not report antlr analysis.
- There is no need to report antlr grammar info every time the files are recompiled. The information just clutters the output.
* [cmake] Move CMake related files to a subdirectory
* [cmake] Add missing susan template targets.
- Some susan template files were not being translated to MetaModelica because they were not added to the cmake file. They are added now.
* [cmake] Remove non-existing package from TypeView.
- There was a definition for a package named 'Connect' in DAEDumpTV.mo. There is no package named 'Connect' in the MetaModelica sources. There is one nested in DAE package (DAE.Connect). This was not detected as error because the package is not used in DAEDumpTpl.tpl anyway. So I guess the remove-unused-packages scrip removed it anyway.
* [cmake] Define OMC_BOOTSTRAPPING for bootstrapping.
- OMC_BOOTSTRAPPING is defined when compiling the runtime libs for bootstrapping. This define is used to pick the correct OpenModelicaBootstrappingHeader.h.
* [cmake] Fix the directory where file is expected.
* [cmake] Reduce info printed during configure step.
* [cmake] Cleanup unused files.
- The compilation of susan template targets is now handled by the CMakeLists file in OMCompiler.
* [cmake] Move compilation out of boot folder
- We used to configure and compile the MetaModelica files from the perspective of the Compiler/boot folder. this was done just to simplify things at the begining since it made it easier to compare things with the old approach which works from that folder.
Now MetaModelica related compilations are done from the perspective of the Compiler/ folder. This is more logical.
* [cmake] Selectively include old/new cmake source.
- The CMakeLists.txt in SimulationRuntime/c is actually used for compilation of simulationruntimemsvc library. Therefor we need to keep it for now.
To do this we include one of the old or new cmake sources in the main CMakelists.tx file in c/ folder based on a variable that is either defined or undefined depening on which compilation (new cmake or makefile.omdev.mingw) is used.
* [cmake] Update 3rdParty.
- The CMake related changes to 3rdParty are now moved to a separate branch - CMakeBuildSupport. This points to that branch now.
* [cmake] Prefix sundials cmake variables.
- BUILD_STATIC_LIBS -> SUNDIALS_BUILD_STATIC_LIBS
This is to avoid conflicts with other libraries.
* [cmake] Update find_package for CURL
* [cmake] Being the remote developer robot
- Just adding what mahge told me
* [cmake] Corba support for omniORB on MinGW/OMdev.
- Corba support for MinGW/OMDev is enabled by the variable OMC_USE_CORBA
- The file omdev_omniorb_setup.cmake sets up the omniORB libraries and idl compiler for use with CMake.
- The file omc_omniorb_corba_target.cmake provided a macro for conveniently adding corba targets.
* [cmake] Disallow implicit function declaration.
- implicit function declaration should be forbidden for all C source files. We want to be strict with include headers and directories. If implicit declaration is allowed for C sources it messes things up and makes it difficult to track what comes from where.
* [cmake] Link to static fmilib
- We link to the static fmilib instead of fmilib_shared.
* [cmake] Add omc.exe compilation.
- We can now build omc.exe. - libOpenModelicaCompiler is built as a static library. Building it as a shared library should also work except that Boehm GC is creating problems as always. The omc.exe that is built from a shared libOpenModelicaCompiler starts but does not do anything and just hangs.
There is some proper configuration that needs to be used to compile and also USE Boehm GC correctly with CMake. In the meantime a static libOpenModelicaCompiler and a statically linked omc.exe should be just fine.
* [cmake] Update 3rdParty.
- We now use fmillib static version. - We build lpsolve55 as a static library.
* [cmake] Fix Boehm GC CMake Compilation.
- This now fixes the Boehm GC issues. It should be possible to build and use static or shared libOpenModelicaCompiler either in debug or release builds without problems.
- We use an updated CMakeLists.txt from https://github.com/ivmai/bdwgc/ @981fd405777a6fc8f80d723943e5bf3045cd9dc0
- - The old CMakeLists.txt was really not usable. The new one seems to be a lot improved and all options are handled properly as they are for the autoconf configuration.
- This now requires CMake 3.1. I guess this is okay because there is no way anyone was using the old CMakeLists anyway.
- GC_BUILD_SHARED_LIBS is used to set a new variable GC_LIBRARY_BUILD_TYPE to either SHARED or STATIC. This way we can choose how to build gc lib.
* [cmake] Rename libgc to libomcgc
- libgc is renamed to libomcgc. This was done for the library built by autotools config. So we will do it here as well.
I am guessing this is done so that we would not link to installed gc inadvertently.
- Previously there was no problem since the gcc and MSVC builds of OpenModelica libraries used the autotools and CMake builds of 3rdParty/gc respectively. So they used the different names omcgc and gc-lib for the library built from the same code.
Now we are trying to unify things to CMake which means the names need to be consistent.
- Check the 3rdParty commit for more changes.
- By default, the new CMake config for 3rdParty/gc builds shared libs. OpenModelica MSVC targets expects static libs. The option GC_BUILD_SHARED_LIBS is set to OFF for those builds.
* [cmake] Look for LAPACK instead of BLAS.
- We want LAPACK libs in addition to just BLAS. - FindLapack will find both.
* [cmake] Fix implicit function declaration flag.
- Apply -Werror=implicit-function-declaration only to our code. There are some libs (e.g. FMI Zlib on Linux builds) that fail to set up things properly and end up using implicit declaration. Until those get fixed upstream we require it only for our own code.
- Also require it only for C code. Recent gcc versions complains about it being used on C++ sources.
- Comment out cmake -E cat command. "cat" for cmake script mode is not available until CMake 3.18.
- Remove locale=en. Was pushed in by mistake.
* [cmake] Make corba actually optional.
- There was an option to disable corba already. However, compilation was just supposed to fail if there was no corba support. Now it is fixed.
- Corba support is now disabled by default. -> OMC_USE_CORBA is OFF by default.
* [cmake] Change Intl linkage approach.
- libintl can be part of GNU libc in Linux. Then a linking command like "-lintl" would not work since there is no intl.
- So instead use the old cmake way specifying ${INTL_LIBRARIES} which can be just empty.
- Until we get a namespaced version like Intl::Intl that can be empty when libintl does not exist we can be happy with this.
* [cmake] Fix Windows/MinGW only link libraries.
* [cmake] A quick fix for uuid linkage.
- On Windows uuid.lib is added to every exe or dll linkage by cmake. - On other systems we need to link it explicitly. - There is no cmake module for finding uuid yet. I will add one later but for now jsut find_library should suffice assuming that the uuid headers will be in the system include directories.
* [CMAKE] Update gitignore and UUID lib
* [CMake] Fixing missing $
* [cmake] Add missing MM dependency updater.
- If a MM source is modfied and its interface has changed then the MM source files that depend on it need to be retranslated.
There is a tiny cmake script added to instigate this. It reads the reverse dependencies (dependees) of the modified MM file and touches their "stamps" so that they get translated again.
Note right now they are not checked for interface "change". There might be a need to have this, but we will see if it is so as we go.
This was left for later while I fix the other CMake issues.
* [cmake] Fix include path and wrong file extension.
* [cmake] Set default build type to Debug.
* [cmake] expat as subdirectory instead of external.
- Add expat as a subdirectory instead of as an external project. There is no need, as far as I can see, to have it as an external project. It has a cmake configuration support and that is what is used when building it as external project. It can just be added as a subdirectory instead.
- The main problem was that it the way exapt was setup as the external project and then imported library added some dependencies on non-existing target (that the external project needs to build first). This creates a problem for strict build systems like "Ninja".
- See the commit on the 3rdParty submodule for more changes.
* [cmake] Install omc and libOpenModelicaCompiler.
- Install omc executable to the RUNTIME (default bin) directory. - Install libOpenModelica compiler to the LIBRARY (lib) directory. - Install ModelicaBuiltin files to the <LIBRARY>/omlibrary (lib/omlibrary) directory.
- Set the <install_prefix>/lib as an rpath dir to installed components.
- There are some fixes done to 3rdParty FMIL and CMinPack projects. FMI is adjusted to use CMAKE_INSTALL_PREFIX instead of its own fixed FMILIB_INSTALL_PREFIX. The decision where to install should be left to the user.
Check the 3rdParty submodule logs for more info.
* [cmake] Add a separate installation component.
- So we now have separate install component "compiler". This allows to install just omc and its runtime dependencies. You can, for example, specify this component as follows:
- CMake will install everything built by default. If you build just omc and then try to `make install` it will start building everything first.
* [cmake] Add default installation folder.
- To avoid installing into system folder like /usr or /usr/local we add a default install dir as:
`<Project_root>/install_cmake`
if the user has not specified an installation directory (i.e. has not set CMAKE_INSTALL_PREFIX when configuring)
* [cmake] Fixes for libzmq-static linking.
- Add the transitively needed libraries when linking to libzq-static. - See the commit/diff on 3rdParty submodule for details.
* [cmake] Add new file UnorderedSet to compilation.
* [cmake] Remove unnecessary package_list file.
- The list of MM filenames part of the compilation is now generated by cmake itself during build system generation. The file contains a list of just the filenames (no path, no extension) to be read by the simple dep_scanner executable.
- Add some comments to the CMakeLists file. There needs to be more. Maybe writing a whole standalone documentation can even be better as soon as this is stable.
* [cmake] Use ccache if asked to and is available.
- ccache can speedup compilation quite a bit since we handle dependencies at MM level and usually will recompile C files even when not needed because a MM file (which the MM of our C file depends on) has been modified without changing its interface.
- As a bonus you will also not have to recompile C/C++ sources so much when you switch between branches with git.
* [cmake] Build Boehm GC as a static library as well
- We now build gc as a static lib. This means there are no more shared libraries in compilation of omc (except libOpenModelicaCompiler itself if needed, of course.)
- This also means there is no need to install gc with omc for using just omc.
- See referenced 3rdParty commit for changes.
* [cmake] Add initial README from PR description.
- This will be updated as we go.
* [cmake] Add a custom install target 'install_omc'.
- This target builds and installs just omc. It is provided just for convenience to allow people to use something similar to what they are used to do , that is issue 'make install_omc', instead of having to run CMake's separate installation script.
* [cmake] Update documentation.
* [cmake] Add new MetaModelica sources to the list.
* Update 3rdParty.
- Changes from the cmake branch in 3rdParty have been merged to master.
submodule 3rdParty head is now tip of 3rdparty/master.
@mahge Refactor and format Compiler/runtime/CMakeLists 5d30aa0
@mahge Rename generated interface base file to .stamp. 6db7ddd
- It is used as a baseline for checking if interface of MM file is changed. Its timestamp is also used to signify that the interface has been checked since the MM file was modified. So stamp is a more appropriate extension.
@mahge Add the generated directory as include directory. a6743d1
- The antrl generated files go into a folder in the build tree. This was not added to include before. It was working only because the normal (autotools, non-cmake) build generated those files in the source directory and the header was picked.
- We add them before the current source directory to make sure that they are included even if there are files generated by the normal autotools build.
@mahge Refactor and format Parser/CMakeLists 0f08730
- The file containing macros is now moved to .cmake directory. - macros have been prefixed with omc_
@mahge Export compile commands from configuration. 2264e0c
- This file can be used by editors helps editors (e.g. vscode, emacs) to have a more accurate code navigation and intellisense. e.g. includes can be pinpointed instead of using glob expressions to parse everything.
@mahge Write out a compiler detection header. 285b8dc
- We will use this for portability purposes. E.g. functions that differ in naming or usage can be normalized to omc_ functions using this header as a base.
- Hopefully we can update our sources without breaking much to use the defines in this file instead of bare _MSC_VER like checks.
@mahge Refactor and format SimulationRuntime/c cmakefile. ad5970c
- Provide and use aliases for libraries in built in SimulationRuntime/c.
- Remove the option to build these libraries as shared. There is no point in building our runtime libs as shared libs.
@mahge Remove source files removed by #6771. be0b08f
- Replace : subscripts with 1:size subscripts. - Fill out connector crefs with : subscripts such that all dimensions are subscripted. - Pad the maps for each connector so they all have the same dimensions.