Open xmirabel opened 1 year ago
@xmirabel maybe the fixes in https://github.com/modelon-community/fmi-library/pull/7 work for you as well. That is how I solved issues with expat. IIRC we encountered your issue at some point as well. fmil
probably has more issues with Ninja so one suggestion is to look at the OpenModelica's FMIL modifications and port them to your project.
Dear M. @mahge, the fix #7 is on expat-2.1.0. At the moment, I have just tried on the latest version downloaded: expat-2.4.8, and the CMakelist have changed a lot. So I am not able to adapt it (I am not at all a fine blade in cmake configuration).
I think it should be fine. You just need to adjust it a bit
first delete all these lines: https://github.com/modelon-community/fmi-library/blob/master/Config.cmake/fmixml.cmake#L188-L257
and add this where the lines used to be
### Set the options of expat and add it as subdirectory.
option(EXPAT_BUILD_TOOLS "build the xmlwf tool for expat library" OFF)
option(EXPAT_BUILD_EXAMPLES "build the examples for expat library" OFF)
option(EXPAT_BUILD_TESTS "build the tests for expat library" OFF)
option(EXPAT_SHARED_LIBS "build a shared expat library" OFF)
option(EXPAT_DTD "Define to make parameter entity parsing functionality available" OFF)
option(EXPAT_NS "Define to make XML Namespaces functionality available" OFF)
add_subdirectory(ThirdParty/Expat/expat-2.4.8)
set(EXPAT_INCLUDE_DIRS ThirdParty/Expat/expat-2.4.8)
then try recompiling and hopefully it should go fine.
If you have no specific reason for choosing fmi-library
, I suggest you take a look at https://github.com/robbr48/fmi4c. It should be easier to build and is generally more lightweight.
I have just tried the OpenModelica's FMIL modifications.
First, it seems that OpenModelica/OMCompiler-3rdParty root CMakeLists.txt uses Open Modelica specific extensions: "omc_add_subdirectory". I do not know how to make them compatible with ninja?
Second, if I open OpenModelica/OMCompiler-3rdParty/FMIL directory with Visual Studio Pro 2022 with WSL:Ubuntu + Linux Debug configuration (automatic CMakePresets.json) a certain number of errors occurs:
Group of errors 1: install DIRECTORY given no DESTINATION. Solution: add "TYPE INCLUDE" before DESTINATION:
in FMIL/CMakeLists.txt install(FILES "${FMILibrary_BINARY_DIR}/fmilib_config.h" "${FMILibrary_BINARY_DIR}/fmilib.h" TYPE INCLUDE DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(DIRECTORY ${FMIIMPORTDIR}/include/ ${JMUTILDIR}/include/ TYPE INCLUDE DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${FMILIB_FMI_STANDARD_HEADERS}/FMI1 ${FMILIB_FMI_STANDARD_HEADERS}/FMI2 TYPE INCLUDE DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h")
And in expat-2.1.0/CMakeLists.txt:
install(FILES lib/expat.h lib/expat_external.h TYPE INCLUDE DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
I think this might work for you. I mentioned the OpenModelica code just as reference to cross-check changes and get some ideas from. I don' think it can be directly copied. Check the comment above and I will try to help you as much as I can.
I have another group of errors in runtime_test.cmake: file COPY cannot find "/home/xmirabel/.vs/FMIL/Test/try_to_uncompress_this_file.zip": No such file or directory.
concerned lines: file(COPY "${UNCOMPRESSED_DUMMY_FILE_PATH_SRC}" DESTINATION "${UNCOMPRESSED_DUMMY_FOLDER_PATH_DIST}")
and
file(COPY "${COMPRESS_DUMMY_FILE_PATH_SRC}" DESTINATION "${COMPRESS_DUMMY_FOLDER_PATH_DIST}")
I have to investigate
I solved it by setting the cache variable : "FMILIB_BUILD_TESTS" to "false"
Now, I built: error: "unable to find source file "zlib.h". I have to investigate which variable to set?
I have just read your message now and tried it:
first delete all these lines: [...] and add this where the lines used to be [...] then try recompiling and hopefully it should go fine.
Then the compilation on WSL: Ubuntu + Linux Release is building and installing fine! Many thankx.
PS: And it continues to build and install on Windows.
If you have no specific reason for choosing fmi-library, I suggest you [...]
In fact, I have a good reason to use it. I want to be able to compile libcosim from Open Simulation Platform. But I would like to use vcpkg and MS Visual Studio Pro 2022 with Linux workload and WSL2, instead of conan like they do.
That is why I have another question: how does it works to update vcpkg with a new fmilib version?
Contexts of compilation:
a/ Windows 10 mode:
b/ Linux mode:
CMake Error: Running '/usr/bin/ninja' '-C' '/home/xmirabel/.vs/fmi-library-master/out/build/linux-debug' '-t' 'recompact' failed with: ninja: error: build.ninja:4558: multiple rules generate ExpatEx/libexpat.a [-w dupbuild=err] C:\R\fmi-library-master\ ninja
How can I solve it, please?