[CMake] Can find_package(...) distinguish between debug and release installs?

Bo Zhou bo.schwarzstein at gmail.com
Tue Apr 10 21:10:00 EDT 2018


Hi,

Since you're using FetchContent/ExternalProject_Add, you could create a
special stage installation folder for those external projects, organize
them by different configurations, for example.

3rdParty/Debug/zlib/include+lib
3rdParty/Release/zlib/include+lib


So with this way, the name from the external libraries is not that
important, we just take care the specific name for specific platform.

>From the project needs these libraries, you could set the XXX_ROOT to tell
CMake built-in module where to locate the dependency, or locate the include
folder and library manually for the different configurations, it would work
for both VisualStudio-based project and GCC/Clang projects.

Good luck.

On Tue, Apr 10, 2018 at 9:59 PM, Saad Khattak <saadrustam at gmail.com> wrote:

> Thanks Bo.
>
> I have added the suffix to my libraries already, however with some 3rd
> party libraries that I am getting with FetchContent, I have no control over
> how they name their libraries.
>
> Now, their <project>Config.cmake files have release targets that are
> globbed by one of the CMake config files (which is part of the install
> process). So CMake 'can' figure out which configuration has been installed
> and I was hoping that there was a built-in way to distinguish that rather
> than me writing some custom scripts for it (where the scripts will search
> for the debug/release target files).
>
> On Mon, Apr 9, 2018 at 11:03 PM Bo Zhou <bo.schwarzstein at gmail.com> wrote:
>
>> Hi,
>>
>> Generally speaking, no, you might have to use the suffix or special name
>> to distinguish the different library, such as with the "_d" suffix.
>>
>> The Boost module of CMake is a considerable example, since it could
>> generate different names for Debug and Release libraries on Windows.
>>
>> At POSIX(UNIX, OSX, Linux), sometimes user mixes the library, it still
>> works well. On Windows, it's dangerous or even won't work with mixed
>> libraries which were built by different Visual Studios with different
>> runtime libraries.
>>
>> Cheers.
>>
>> On Tue, Apr 10, 2018 at 10:56 AM, Saad Khattak <saadrustam at gmail.com>
>> wrote:
>>
>>> Hi,
>>>
>>> When find_package(LibA) sets the LibA_FOUND variable, is it possible to
>>> know if the package found is the Debug or Release build (or both)? I have a
>>> fairly complex build setup where I need to be able to distinguish if
>>> find_package(LibA) found a Debug or Release build.
>>>
>>> - Saad
>>>
>>> --
>>>
>>> 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:
>>> https://cmake.org/mailman/listinfo/cmake
>>>
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180411/961957b9/attachment-0001.html>


More information about the CMake mailing list