[CMake] Release and Debug build linking

Tamás Kenéz tamas.kenez at gmail.com
Tue Oct 6 17:19:25 EDT 2015


CMake supports multi-config generators such as Visual Studio and Xcode for
a long time.

There are two flavors of config-modules (and find-modules), the legacy one
which creates variables like MY_PACKAGE_LIBRARIES and the install-export
kind which creates IMPORTED targets.
Both kinds of modules support providing Debug and Release versions of the
same library from a single find-module or config-module.

So if your package's find-module or config-module is written correctly you
don't need any if's just a single find_package().

Tamas

On Tue, Oct 6, 2015 at 10:21 PM, Lee Butler <iraytrace at gmail.com> wrote:

> I am looking for a way to tell my project to link against external debug
> libraries with a debug build and external release libraries with a release
> build with Visual Studio.
>
> I sort of want to be able to say something like
> if (BuildingReleaseConfig)
> find_package(OtherPackage REQUIRED COMPONENTS one two three PATHS
> OtherPkgDir/Release)
> endif()
>
> if (BuildingDebugConfig)
> find_package(OtherPackage REQUIRED COMPONENTS oned twod threed PATHS
> OtherPkgDir/Debug)
> endif()
>
> the idea is that the if () tells CMake which build configuration the
> find_package results should go into.  Is there any way to tell CMake what
> to write into each VS configuration?
>
> I realize the traditional CMake way is to create only one build at a time
> and specify CMAKE_BUILD_TYPE, but we seem to have stepped beyond that with
> the Visual Studio generator.
>
> Lee
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151006/22ec3b66/attachment.html>


More information about the CMake mailing list