[CMake] custom configuration types and linking with 3rd-party libs
Yuri V. Timenkov
ytimenkov at parallels.com
Tue Aug 26 08:35:08 EDT 2008
On Tuesday 26 August 2008 03:59:04 Brad King wrote:
> cyril_wobow wrote:
> > Unfortunately, there is a showstopper : when it comes to linking, tell
> > me if I am wrong, there is no way to express which configuration type
> > should link against which library. In particular, all my configuration
> > types end up linking against the release version of my 3rd party
> > libraries.
> >
> > 1st possible solution :
> > Is there a way to specify libraries to link with, using a
> > XX_<CONFIG>-style variable ?
>
> Use an IMPORTED library. This is supported in CMake 2.6:
>
> add_library(xx_lib STATIC IMPORTED)
> set_target_properties(xx_lib PROPERTIES
> IMPORTED_CONFIGURATIONS "DEBUG;RELEASE"
> IMPORTED_LOCATION_GUIDEBUG ${XX_DEBUG}
> IMPORTED_LOCATION_GUIRELEASE ${XX_RELEASE}
> MAP_IMPORTED_CONFIG_GUIRELEASE RELEASE
> MAP_IMPORTED_CONFIG_CONSOLERELEASE RELEASE
> MAP_IMPORTED_CONFIG_GUIDEBUG DEBUG
> MAP_IMPORTED_CONFIG_CONSOLEDEBUG DEBUG
> )
> # ...
> target_link_libraries(myexe xx_lib)
>
> See related documentation here:
>
> http://www.cmake.org/Wiki/CMake_2.6_Notes#Importing_Targets
> http://www.cmake.org/HTML/cmake-2.6.html#command:add_library
> http://www.cmake.org/HTML/cmake-2.6.html#prop_tgt:IMPORTED_LOCATION_CONFIG
> http://www.cmake.org/HTML/cmake-2.6.html#prop_tgt:MAP_IMPORTED_CONFIG_CONFI
>G
I'll take a note of this hint anyways.
But this approach takes actions to use libraries found by standard find_package
commands, and event Qt has a significant number of libraries even to pass them
as list to macro. Same true for boost.
>
> -Brad
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list