Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify multiple paths in XXX_INCLUDE_DIRS or XXX_LIBRARIES of FindXXX.cmake

Tags:

cmake

Consider the following example of a FindXXX.cmake:

find_path(XXX_INCLUDE_DIR NAMES XXX/XXX.h)
find_path(XXXYYY_INCLUDE_DIR NAMES YYY.h)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XXX DEFAULT_MSG
        XXX_INCLUDE_DIR XXXYYY_INCLUDE_DIR)

set(XXX_INCLUDE_DIRS "${XXX_INCLUDE_DIR} ${XXXYYY_INCLUDE_DIR}")

As it is in this example, XXX_INCLUDE_DIRS is a string with a space in the middle, and, thus, when added in CMakeLists.txt using

 target_include_directories(a PRIVATE ${XXX_INCLUDE_DIRS})

it is invoked by the compiler as

-I"XXXpath XXXYYYpath"

How should I modify the line

set(XXX_INCLUDE_DIRS ${XXX_INCLUDE_DIR} ${XXXYYY_INCLUDE_DIR})

which sets the value for the variable XXX_INCLUDE_DIRS?

The same question arises for multiple library paths in XXX_LIBRARIES.

like image 957
Jorge Leitao Avatar asked Oct 14 '25 08:10

Jorge Leitao


1 Answers

You provide multiple entries for variables like XXX_LIBRARIES and XXX_INCLUDE_DIRS as a semicolon-separated list.

set(XXX_INCLUDE_DIRS "${XXX_INCLUDE_DIR};${XXXYYY_INCLUDE_DIR}")
like image 79
usr1234567 Avatar answered Oct 17 '25 01:10

usr1234567



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!