[CMake] Is this the proper way to define a package config?

Johannes Zarl johannes.zarl at jku.at
Thu Oct 23 05:59:48 EDT 2014


Hi,

Assuming you are not a boost developer / your changes won't be upstreamed, 
then creating a BoostConfig.cmake file won't do you much good. If someone wants 
to use your project, he/she will have to patch the locally installed boost 
version to include a BoostConfig.cmake file.

You might want to have a look into the FindBoost[1] module of cmake.

XXXConfig.cmake files are intended to be written by the creator of a package, 
FindXXX.cmake packages are intended as a workaround when a package does not 
contain an XXXConfig.cmake file and are usually written by a consumer of a 
package.

HTH,
  Johannes

[1] http://www.cmake.org/cmake/help/v3.0/module/FindBoost.html

On Friday 17 October 2014 00:18:34 Robert Dailey wrote:
> I have a local package of boost built on Windows. It is always
> relative to the root of my project at a consistent structure and
> location. I wanted to define an import target for this and thought it
> might be best to define a BoostConfig.cmake package config file at the
> root of the boost lib directory. Is this the right approach? The code
> is below.
> 
> Note that I do not have this working just yet because I don't know how
> to properly setup the interface link libraries. Could use some
> guidance here too... thanks.
> 
> add_library( Boost STATIC IMPORTED GLOBAL )
> 
> file( GLOB boost_debug_libs ${CMAKE_CURRENT_LIST_DIR}/lib/win32/debug/*.lib
> ) file( GLOB boost_release_libs
> ${CMAKE_CURRENT_LIST_DIR}/lib/win32/release/*.lib )
> 
> set_target_properties( Boost PROPERTIES
>     IMPORTED_LOCATION_DEBUG lib/win32/debug
>     IMPORTED_LOCATION_RELEASE lib/win32/release
>     INTERFACE_INCLUDE_DIRECTORIES include
>     INTERFACE_LINK_LIBRARIES
>         $<$<CONFIG:Debug>:${boost_debug_libs}>
>         $<$<CONFIG:Release>:${boost_release_libs}>
> )
> 
> set( Boost_INCLUDE_DIRS include )
> set( Boost_LIBRARIES Boost )



More information about the CMake mailing list