[CMake] "Emulate" a package result (find_package)

r2d2leboss at voila.fr r2d2leboss at voila.fr
Sat Mar 28 17:57:49 EDT 2015


Hi,

We develop a library that we will call LIBRARY. To compile this library, we use CMake (of course :) ). This library include multiple components, like Boost system, 
i.e. there are few add_library commands. This library produce LIBRARY_COMPONENTS_1, LIBRARY_COMPONENTS_2, LIBRARY_COMPONENTS_3 (each 
component is a static or shared library, some both). At the end, user execute "make install" to merge all include dirs in "include/" and all components in "lib/". This 
project include a FindLIBRARY.cmake file to use this library in another project.

We have modules, MODULE_1, MODULE_2, ... MODULE_N. Each module use some components of LIBRARY, maybe LIBRARY_COMPONENTS_1, 
LIBRARY_COMPONENTS_2 or both... To compile MODULE_1, they need to compile LIBRARY first (separately) then module CMakeLists.txt will use 
FindLIBRARY.cmake to link to components. This one works well.

Now, we would like to make something better. We have a project PROJECT with few modules (not all) and we would like to compile automatically, i.e. we would 
like a top level CMakeLists.txt which compile LIBRARY and MODULE_1, MODULE_2, MODULE_3... 

Our idea was to use add_subdirectory but modules will try to search LIBRARY and they will not find the library because it's not still compiled... So, how to "emulate" 
find_package result for LIBRARY ? Bad idea (I think), is to set LIBRARY-FOUND to true, manually include dirs (a pain because library is not installed) and it will not 
prevent to library upgrade (maybe that tomorrow it will have a new components, so a new include dir to add). 

Do you have any idea to build our top level PROJECT CMakeLists.txt ?

Thank you,

Jean

PROJECT/
CMakeLists.txt
libs/
LIBRARY/
CMakeLists.txt
...
modules/
MODULE_1/
FindLIBRARY.cmake
CMakeLists.txt
...
MODULE_2
FindLIBRARY.cmake
CMakeLists.txt
...
MODULE_2
FindLIBRARY.cmake
CMakeLists.txt
...
___________________________________________________________
Mode, hifi, maison,… J'achète malin. Je compare les prix avec Voila.fr http://shopping.voila.fr/


More information about the CMake mailing list