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

CPM in CMake scripts: define_property command is not scriptable #541

Open
gerhardol opened this issue Feb 29, 2024 · 0 comments
Open

CPM in CMake scripts: define_property command is not scriptable #541

gerhardol opened this issue Feb 29, 2024 · 0 comments

Comments

@gerhardol
Copy link
Contributor

gerhardol commented Feb 29, 2024

fetchContent can be used in CMake scripts (cmake -P)
However, cpm.cmake manipulates some properties so this is not possible as a script.
Any way this can be fixed? (I tried commenting out setting of properties but it still fails).

The workaround I see is to define a dummy project to do the downloading, then use the path.

CMake Error at /usr/local/src/cmake-3.28.3/share/cmake-3.28/Modules/FetchContent.cmake:1188 (define_property):
  define_property command is not scriptable
Call Stack (most recent call first):
  /usr/local/src/cmake-3.28.3/share/cmake-3.28/Modules/FetchContent.cmake:1366:EVAL:1 (__FetchContent_declareDetails)
  /usr/local/src/cmake-3.28.3/share/cmake-3.28/Modules/FetchContent.cmake:1366 (cmake_language)
  util/CMakeConfig/cpm/CPM.cmake:929 (FetchContent_Declare)
  util/CMakeConfig/cpm/CPM.cmake:805 (cpm_declare_fetch)
  util/CMakeConfig/compiler_env.cmake:16 (cpmaddpackage)

Background:
cpm.cmake is a nice way to get dependencies, the handling of a cache outside of the build/ folder is easier to handle.
Some compilers fits in Docker, there are several variants of some other that makes it inconvenient to handle them in Docker.

So it is the natural step to try using cpm.cmake to distribute the compilers as packages (other tools are already handled).
Unfortunately, our compilers require some environment variables to be set and I have not got that working using cpm "from within" CMake configure. (Env var in CMake are not used by subshells).
The compiler must be fetched with a separate step and source the setup before the CMake configure call for the actual project.
This is actually also required for some products that are not using CMake at all, just the compiler.

The natural way would be to use a CMake script to fetch the package, source setup and then start the build.
I guess that it would be possible to use a dummy CMakeLists.txt and only run the configure phase as a workaround.

--
Edit:
Additional information: CMake 3.28.3
I get the same error with FetchContent_MakeAvailable() directly, so it may not be a CPM issue.

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