[CMake] export(TARGETS for multi-configuration

Ruslan Baratov ruslan_baratov at yahoo.com
Tue Jan 21 07:53:31 EST 2014


> ------------------------------
>
> Message: 2
> Date: Fri, 17 Jan 2014 23:46:45 +0400
> From: ZZ ZZ <zero-zip at yandex.ru>
> To: cmake at cmake.org
> Subject: [CMake] export(TARGETS for multi-configuration
> Message-ID: <176711389988005 at web18h.yandex.ru>
> Content-Type: text/plain; charset=koi8-r
>
> Hi all,
>
> Our CMakeLists.txt contains with the following command:
>
> export(TARGETS ${OpenCVModules_TARGETS} FILE "${CMAKE_BINARY_DIR}/OpenCVModules.cmake")
>
> For release configuration it generates Relase imports
>
> set_property(TARGET opencv_legacy APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
> set_target_properties(opencv_legacy PROPERTIES
> ??IMPORTED_IMPLIB_RELEASE "E:/opencv24_vs2008_x64/lib/opencv_legacy248.lib"
> ??IMPORTED_LOCATION_RELEASE "E:/opencv24_vs2008_x64/bin/opencv_legacy248.dll"
> ??)
>
> For debug configuration Debug ones:
>
> # Import target "opencv_legacy" for configuration "Debug"
> set_property(TARGET opencv_legacy APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
> set_target_properties(opencv_legacy PROPERTIES
> ??IMPORTED_IMPLIB_DEBUG "E:/opencv24_vs2008_x64/lib/opencv_legacy248d.lib"
> ??IMPORTED_LOCATION_DEBUG "E:/opencv24_vs2008_x64/bin/opencv_legacy248d.dll"
> ??)
>
> My question is how to generate export file which contains both of Debug and Release target properties?
> I can't write to different files for Releae and Debug and include both - the files contain guards again multiple includes.
>
In install case you can use install(EXPORT ...) command:

   install(TARGETS foo EXPORT FooTargets)
   install(EXPORT FooTargets)

debug will produce: FooTargets.cmake and FooTargets-debug.cmake
release will produce: FooTargets.cmake and FooTargets-release.cmake
Both debug/release versions of FooTargets.cmake are equal.

Take a look at this mini-project: 
https://github.com/forexample/package-example



More information about the CMake mailing list