[CMake] Using find_package with different build trees

Stefanos Mitropoulos smitropoulos at edps.gr
Wed Aug 21 05:16:39 EDT 2019


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 printf("THIS IS RELEASE MODE"); #endif |

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
Developer 	Logo <http://www.edps.gr>
EDPS S.A.
t: 30-210-8993660
e: smitropoulos at edps.gr
www.edps.gr <http://www.edps.gr> 	
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.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190821/48526a84/attachment.html>


More information about the CMake mailing list