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

Robert Dailey rcdailey.lists at gmail.com
Thu Oct 23 12:53:33 EDT 2014


Thanks for the reply!

Basically the boost library I have is precompiled and in my own unique
structure. I do not plan to distribute the CMake scripts I write, they
are for personal / internal usage only.

You suggested a find module, but will this also generate a custom
target for boost? That's important so that when I do
target_link_libraries(), I can pass in "boost" and everything is
handled for me. I do not want to be working with libs & header files
directly in each executable or library I define that has a dependency
on boost.

Thanks again.

On Thu, Oct 23, 2014 at 4:59 AM, Johannes Zarl <johannes.zarl at jku.at> wrote:
> 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 )
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list