Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration of ThirdParty/Expat #6

Open
mahge opened this issue Sep 21, 2020 · 0 comments
Open

Configuration of ThirdParty/Expat #6

mahge opened this issue Sep 21, 2020 · 0 comments

Comments

@mahge
Copy link

mahge commented Sep 21, 2020

Configuring fmi-library currently prints a few CMake warnings. One of these warnings is

CMake Warning (dev) at Config.cmake/fmixml.cmake:185 (add_dependencies):
  Policy CMP0046 is not set: Error on non-existent dependency in
  add_dependencies.  Run "cmake --help-policy CMP0046" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  The dependency target "/home/mahge/fmi-library/build_cmake/CMakeCache.txt"
  of target "expatex" does not exist.

Due to this line

add_dependencies(expatex ${CMAKE_BINARY_DIR}/CMakeCache.txt ${FMILIBRARYHOME}/CMakeLists.txt)

The external project is setup at build time. This seems to be no problem for some generators like GNU Makefiles. However, for some strict build systems like "Ninja" the will trigger an error at the start of build because the dependency does not exist yet.. This means any project that adds fmi-library as a sub-project can not use these generators.

As far as I can see, expat can be added as a sub-directory instead of an external project. It has support for CMake configuration. If there is no other reason to keep it configuring/building as an external project, it should be switched.

I will create a pull request with the respective changes.

Edit

Up on further investigation, the cause for the Ninja build failure is not that specific warning. The exact error message is

ninja: error: 'ExpatEx/libexpat.a', needed by '3rdParty/FMIL/fmilib_dummy.c', missing and no known rule to make it

As far as I can see fmilib_dummy.c depends on expat.

add_custom_command(
OUTPUT ${dummyfile}
COMMAND ${CMAKE_COMMAND} -E copy ${dummyfile}.base ${dummyfile}
DEPENDS ${libs} ${extrafiles})

and merge_static_libs is invoked with ${libs} as ${FMILIB_SUBLIBS} and that list contains expat. Plus expat depends explicitly on expatex

set_target_properties(
expat PROPERTIES
IMPORTED_LOCATION "${expatlib}"
)
add_dependencies(expat expatex)

I am not very familiar with the inter-workings of ExternalProject but I guess the issue lies somewhere here in the interaction of imported targets, imported llibrary locations, and explicit add_dependency() calls.

There is also quite a heave usage of CMAKE_BINARY_DIRECTORY in this part of the code, which is fine when fmi-libray is a standalone project. However, if it is a subproject it might be writing and reading things from places that were not intentional. Not to mention it pollutes the parent projects space.

The linked PR should still remove the issue, even though I am not sure yet what is causing it here.

beutlich pushed a commit to fmi-tools/fmi-library that referenced this issue Apr 1, 2021
…3_clause_bsd_license

Explicitly state license is 3-Clause BSD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant