-
Notifications
You must be signed in to change notification settings - Fork 96
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
FairRootConfig.cmake should find relevant dependencies #1545
Comments
Thank you for this issue. We intentionally do not use the Basically, what you do in the consuming project, is: find_package(FairCMakeModules 1.0 QUIET REQUIRED)
include(FairFindPackage2)
find_package2(PUBLIC FairRoot VERSION 19 REQUIRED)
# put your own direct dependencies here via `find_package2()`
find_package2_implicit_dependencies()
# optional, from `FairSummary` module
fair_summary_package_dependencies() For detailed docs see: In cases, where your project shares a direct dependency with FairRoot, Note beside: When choosing to use That said, as most of the CMake community tends to go the find_package(FairRoot 20 COMPONENTS WITH_FIND_DEPENDENCY) or similar. |
Thanks for your comment. Does this work only for the latest version (jan24) of FairSoft? I'm trying with nov22p1. It seems |
|
It does nothing. No output and no dependency packages installed. I also checked the FairCMakeModules installed in the system. It also has no I will try to use the latest version of FairSoft. Is it possible to include find_dependecy(FairCMakeModules 1.0)
include(FairFindPackage2) into FairRootConfig.cmake? Then user can just deal with one dependency instead of two: # probably find_package2 should also be called in the config file
find_package(PUBLIC FairRoot VERSION 19 REQUIRED)
find_package2_implicit_dependencies()
fair_summary_package_dependencies() If this is not possible, it shows
It's much easier to break the build system if we need to deal with two imported packages and both of them must work correctly. I suspect it's the cause in my case of nov22p1 as the FairCMakeModules could be not probably imported. That being said,
|
No, the
Not sure I understand, no output is expected.
Which system? Note: |
FairCMakeModules v1.0 is included in |
Please also compare your These you can leave out, you should just need to FairRoot/templates/project_stl_containers/CMakeLists.txt Lines 81 to 123 in 99be5f4
|
Here is a minimum cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(MinimumExample LANGUAGES CXX)
find_package(FairCMakeModules 0.2 REQUIRED)
include(FairFindPackage2)
find_package2(PRIVATE FairRoot VERSION 19 REQUIRED)
list(PREPEND CMAKE_MODULE_PATH ${FairRoot_PREFIX}/share/fairbase/cmake/modules)
find_package2_implicit_dependencies()
include(FairSummary)
fair_summary_package_dependencies()
I have not tried, but I expect this to work with FairSoft It is not perfect yet, and it will not be for a while. FairRoot is still a mess ;) |
Hi, @dennisklein Thanks for your detailed explanation.
Sorry, I meant "imported" instead of "installed". But later the issue was to be caused by not specifying FairRoot to be 19 and FairRoot 18 was actually used. I tried your minimum example in a debian 10 server and it still didn't work out. Here is my cmake: cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(MinimumExample LANGUAGES CXX)
list(APPEND CMAKE_PREFIX_PATH "/u/yanwang/software/FairRoot")
list(APPEND CMAKE_PREFIX_PATH "/cvmfs/fairsoft.gsi.de/debian10/fairsoft/nov22p1")
find_package(FairCMakeModules 0.2 REQUIRED)
include(FairFindPackage2)
find_package2(PRIVATE FairRoot VERSION 19 REQUIRED)
list(PREPEND CMAKE_MODULE_PATH ${FairRoot_PREFIX}/share/fairbase/cmake/modules)
find_package2_implicit_dependencies()
include(FairSummary)
fair_summary_package_dependencies()
add_executable(main main.cpp)
target_link_libraries(main PRIVATE ROOT::RIO) I didn't define any env variables except those for the compiler and cmake. Here is the output:
Error shows that CMake is trying to import ROOT using MODULE mode instead of the suggested CONFIG mode. Here are some version info:
|
|
|
@dennisklein Very nice! It works now.
That's absolutely right. But unfortunately, most of time I need to install FairRoot v18 and v19 together such that I could test whether our software could work with both versions. For now, it seems impossible by just changing the version in find_package2(PRIVATE FairRoot VERSION 18 REQUIRED) # change to 19 if needed. I wonder whether it's a better idea to put list(PREPEND CMAKE_MODULE_PATH ${FairRoot_PREFIX}/share/fairbase/cmake/modules) If in the next time we change the path Another thing I would like to ask is whether it's possible to import ROOT using CONFIG mode explicitly. But that would change the implementation of
Yes, you have to define proper env variables before launch the cmake. I normally do this with my own function: function use_gcc(){
export CC=gcc
export CXX=g++
[ -z "$ld_library_path" ] && typeset -gT LD_LIBRARY_PATH ld_library_path
path=('/u/land/software/gcc/latest/bin' $path)
export LD_LIBRARY_PATH="/u/land/software/gcc/latest/lib64${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
export LIBRARY_PATH="/u/land/software/gcc/latest/lib64${LIBRARY_PATH:+:$LIBRARY_PATH}"
typeset -gU path ld_library_path
} However, I don't think it's a good idea to hard-code compiler info (or generator type) into project cmake configuration. Maybe next time I want to use gcc 14, I have to unnecessarily change the project. |
This is a well understood use case! Actually, I just proposed a week ago in our internal group meeting that we should have a new repository that contains both our examples and the project templates exactly to ensure better this common requirement. This new repo would then be part of our CI in such a way, that it has to pass working with the 2+ latest FairRoot releases and also functions as an example repo on how we envision the user CMakeLists.txt to look like. Note beside: My idea is also to move FairRoot more and more towards a standard CMake library from the point of view a user's (experiment's) project. However, this is an invasive change to the current model which ties the experiment's project very tightly in non-standard ways (for historic reasons - mainly CMake v2 did not have standards for many aspects). So, it will likely take a few releases to accomplish that - and we also need to keep the steps small enough to not alienate anyone too much.
The idea is that you always require the minimum version your project supports. Then you list the FairRoot install prefix - you want to be found - in your Note: It is not supported to install multiple versions of FairRoot into the same install prefix!
Yes, there will be more Also, find modules are currently shipped as part of the FairRoot install tree, but we want to move them to the FairCMakeModules project instead as we re-use those find modules in multiple places and it they should not be tied to a FairRoot release in any case.
There is a different standard mechanism in CMake to control this:
I agree, that is what I wrote, no? CMake toolchain files are basically an alternative to your shell function. |
One more thing: As long as your experiment project supports FairRoot pre FairRoot/cmake/modules/FindFairRoot.cmake Line 25 in 99be5f4
|
Thanks again. That's pretty clear.
Sorry for the misunderstanding. I haven't used cmake toolchain except the one from conan package manager. But I will try it out. Thus, this issue can be closed. |
Is your feature request related to a problem? Please describe.
Importing FairRoot with
find_package
reads the cmake fileFairRootConfig.cmake
. Currently, it only contains the targets and some extra variables. The dependent project still needs to import all the necessary packages like ROOT, Geant4, etc. It would be much better if this can be automatically done in the config file.Describe the solution you'd like
In the file FairRootConfig.cmake.in, ROOT, Geant4, etc should be added there:
Same goes for other packages.
Additional context
Some other configuration variables, such as
CMAKE_PREFIX_PATH
should also be added here to make sure packages can be found and correctly imported.The text was updated successfully, but these errors were encountered: