[CMake] find_package for both debug and release with Visual Studio

Dan Kegel dank at kegel.com
Fri Sep 25 09:27:56 EDT 2015


"John Barbero Unenge" <john.barbero.unenge at gmail.com> wrote:
>
> I'm tearing my hair out about how to include thrid party libraries in my
cmake project. Currently I build Poco and a bunch of others that all
generate their respective <LibName>Config.cmake which I use with
find_package. I have a wrapping build script that builds all of my
dependencies and package them separately for debug and release ...
>
> I thought I could just do:
>
> find_package(Foo
>             HINTS "${CMAKE_SOURCE_DIR}/some/path/debug/libFoo/lib/cmake"
>             REQUIRED
> )
> get_target_property(LIB_FOO_DEBUG lib_foo LOCATION)
>
> find_package(Foo
>             HINTS "${CMAKE_SOURCE_DIR}/some/path/release/libFoo/lib/cmake"
>             REQUIRED
> )
> get_target_property(LIB_FOO_RELEASE lib_foo LOCATION)
>
> set(LIB_FOO_LIBRARIES optimized "${LIB_FOO_RELEASE}" debug
"${LIB_FOO_DEBUG}")
>
> message("LIB_FOO_LIBRARIES: \"${LIB_FOO_LIBRARIES}\"")
> # Gives: LIB_FOO_LIBRARIES:
"optimized;C:/path/to/proj/some/path/debug/libFoo/lib/foo.lib;debug;C:/path/to/proj/some/path/debug/libFoo/lib/foo.lib"
>
> It seems like the first call to find_package for target Foo is cached,
whis I don't really want.
>
> Am I going about this the wrong way? How do I properly work with 3rd
party libraries with the Visual Studio generator?
>
> Any pointers are greatly appreciated.

Qt seems to manage it, if I'm reading
http://doc.qt.io/qt-5/cmake-manual.html
right.  Maybe you can find a clue there.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150925/325ab3aa/attachment.html>


More information about the CMake mailing list