在FindXXX.cmake的XXX_INCLUDE_DIRS或XXX_LIBRARIES中指定多个路径

时间:2017-01-24 14:08:03

标签: cmake

考虑以下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}")

就像在这个例子中一样,XXX_INCLUDE_DIRS是一个中间有空格的字符串,因此,当使用<{p>}添加CMakeLists.txt

 target_include_directories(a PRIVATE ${XXX_INCLUDE_DIRS})

编译器将其调用为

-I"XXXpath XXXYYYpath"

我应该如何修改

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

设置变量XXX_INCLUDE_DIRS的值?

XXX_LIBRARIES中的多个库路径也出现了同样的问题。

1 个答案:

答案 0 :(得分:2)

您为XXX_LIBRARIESXXX_INCLUDE_DIRS等变量提供了多个条目,作为以分号分隔的列表。

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