Using find_package with different build trees

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Using find_package with different build trees

Stefanos Mitropoulos

Hello all!

I am trying to follow the modern cmake path and use the find_packages()/link libraries way.

I am using a test scenario in which: LIB_B depends on LIB_A and EXEC_A depends on both.

I was wondering how you could link EXEC_A to the debug lib version of LIB_B and the release version of LIB_A or vice versa.

On LIB_A I am using set(CMAKE_DEBUG_POSTFIX "-debug")
so my LIB_A is going to be LIB_A-debug when making the debug tree. I install them in /usr/local/lib and both reside there.

For example let's say I have this line of code in LIB_A:

#ifdef Release  

This is going to differentiate LIB_A and LIB_A-debug.

in EXEC_A I would use

find_package(LIBA REQUIRED) 
add_executable(EXEC_A main.cpp) 
target_link_libraries(EXEC_A PUBLIC LIBS::LIBA LIBS::LIBB) 

assuming I have exported the libraries in the LIBS namespace.

Is there any way to differentiate between library versions?

EDIT: I am on Linux (centos) and using GCC 8. My CMake version is 3.14

Email Signature
Stefanos Mitropoulos
t: 30-210-8993660
e: [hidden email]
The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to share any part of this message with any third party, without a written consent of the sender. If you received this message by mistake, please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: