-
Notifications
You must be signed in to change notification settings - Fork 98
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
Fix the error that ROOT header files can't be found #1466
Conversation
I'm trying to use the dev version of FairRoot in R3BRoot. We are still using the MODULE mode to find ROOT, which runs through FindRoot.cmake. In this case, the ${ROOT_INCLUDE_DIR} is defined properly but ${ROOT_INCLUDE_DIRS} is empty. What is the suggested way to include ROOT package? |
FairRoot dev has a major CMake rewrite. See the Chabgelog. Handling this in R3BRoot in a way that is compatible with FairRoot 18.x and 19.x at the same time is not trivial! The idea is that FairRoot 18.8 has most C++ changes and 19.0 has only CMake changes. I don't know, how close we are to this idea still. But once it was like this. |
Great to hear this change. If using CONFIG mode to find ROOT is preferred, should we just use cmake targets without global variable In this case, we should keep it as ${ROOT_INCLUDE_DIR} for the MODULE mode and do not use global ${ROOT_INCLUDE_DIRS} if users choose to use CONFIG mode. |
Right, the idea is to use exported targets from ROOT with their include paths. So one should only need to properly declare dependencies on ROOT::Core/etc and be done without needing to take care about include paths. |
Hi Sorry for the late reply.
It's great the hear that again. But I always have a problem with ROOTCINT when generating dictionary. The problem is that it seems ROOTCINT can't use the included path from the CMake targets. Every time I try to compile a library, with some cmake targets as its dependencies, rootcint seems to always fail to find the header files: # at R3BBase cmake file:
target_include_directories(R3BBase PUBLIC folder)
# at another cmake file
set(DEPENDENCIES R3BBase)
GENERATE_LIBRARY() even though the header file does exist inside an include folder of include_directories(folder) which sets the global include_directories for all targets (including those who even don't need this folder). This works but would fail if Is there any way to make rootcint work with cmake targets? Or even is there actually a plan to implement it in FairMacros? A possible solution. |
So I tried the solution mentioned above. It works (it has actually been documented in ROOT manual) Please find the example in this PR proposed in R3BRoot. The boilerplate part is: add_library(R3BSource SHARED ${SRCS})
target_include_directories(R3BSource PUBLIC ${DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(R3BSource PUBLIC R3BData MbsAPI Ucesb)
root_generate_dictionary(R3BSource_dict ${HEADERS} MODULE R3BSource LINKDEF SourceLinkDef.h) With this ROOT can automatically find those needed include dirs without using |
This PR has been covered with the release of FairRoot 19. |
Thanks for taking care and cleaning up! :-) |
ROOT header files can't be found because of an typo in FairMacros.cmake.
Fixed by changing ROOT_INCLUDE_DIRS to ROOT_INCLUDE_DIR
Edit:
It seems that this was changed deliberately by PR #1119.
Checklist: