[CMake] Handling library dependencies and minimizing duplicated include_directories
Daniel Lidström
daniel.lidstrom at sbg.se
Sat Mar 20 09:15:48 EDT 2010
Hi Mike,
> Most of us would write a "FindGFL.cmake" file which will locate the
> GFL library and set GFL_INCLUDE_DIRS, GFL_LIBRARIES, and other
> standard directories/files like that. Some of these files will do the
> "include(${GFL_INCLUDE_DIRS}" for you and some will not.
> Some design those (like FindQt4.cmake) with an additional
> "UseQt4.cmake" which you simply do an "include(${USE_QT4_FILE})". So
> in your case, if you have a large project with lots of project
> dependent on a few of your libraries I would write a "FindGFL.cmake"
> that does the "include()" for you. Then your cmake files look
> something like this.
>
>
> set (CMAKE_MODULE_PATH "Path/To/Your/Find*.cmake/Dir"
> ${CMAKE_MODULE_PATH} )
> Find_package(GFL)
>
> add_library(somelib ${srcs})
> target_link_libraries (somelib ${GFL_LIBRARIES} )
>
> This is much more scalable. Does that help?
This would definitely help me. I am wondering one thing though. Do you
place all your FindXXX.cmake in the same folder? If I understand you
correctly it would like something like this:
UMC3D/
CMakeLists.txt
GFL/
CMakeLists.txt
Device/
CMakeLists.txt
Test/
CMakeLists.txt
Then I need to create a CMake folder like so:
UMC3D/
CMake/
FindGFL.cmake
FindDevice.cmake
.
.
.
A difference that I can see with this compared to Boost.Build is that the
configuration of GFL (build and usage) is separated (GFL/CMakeLists.txt + CMake/FindGFL.cmake).
Is this how you deal with this? Maybe it is not a big problem.
Regards,
Daniel Lidström
Stockholm, Sweden
More information about the CMake
mailing list