[CMake] Controlling order of includes with INTERFACE_INCLUDE_DIRECTORIES for an IMPORTED target

David Jobet djobet at tower-research.com
Fri Oct 12 03:42:32 EDT 2018


Hello,

we embed in our source a copy of an ICC build of LLVM, that we import :

add_library(global_llvm_external STATIC IMPORTED)
set_property(TARGET global_llvm_external APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/icc/include)
set_property(TARGET global_llvm_external APPEND PROPERTY
IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/icc/lib/libLLVMCore.a)
set_property(TARGET global_llvm_external APPEND PROPERTY
INTERFACE_LINK_LIBRARIES
${CMAKE_CURRENT_SOURCE_DIR}/icc/lib/libLLVMLTO.a ...)

add_library(global_llvm INTERFACE)
target_link_libraries(global_llvm INTERFACE global_llvm_external)
add_library(global::llvm ALIAS global_llvm)

It works fine, until someone decided to install a more recent version
of LLVM in its development env. (which is not ABI compatible)

Somehow, system includes path are looked into first
g++ ... -I/apps/homefs1/USER/work/. -I. -isystem
/spare/local/USER/conda_root/envs/gcc6cxx14/include -isystem
/apps/homefs1/USER/work/.../libllvm/icc/include ...

so, as with include_directories where it's possible to control the
ordering with BEFORE or AFTER, is there a way to tell cmake that when
linking against global::llvm we want the include directories needed by
global::llvm to be prepended (instead of appended) ?

With regards

David


More information about the CMake mailing list