[CMake] Imported targets and include ordering

Roger Leigh rleigh at codelibre.net
Thu Aug 11 15:01:08 EDT 2016


On 11/08/2016 16:24, rleigh at codelibre.net wrote:
> I've come across an odd situation where I'm unsure what the most
> portable and recommended solution would be.
>
> I'm linking a program against the CURL and ICU libraries.  CURL has
> traditional variables for the includes and libraries; ICU has imported
> targets.
>
> In FindICU:
>           set_target_properties(${_ICU_imported_target} PROPERTIES
>             INTERFACE_INCLUDE_DIRECTORIES "${ICU_INCLUDE_DIR}")
>
> In my code:
>
> find_package(CURL)
> find_package(ICU COMPONENTS uc data)
> [...]
> list(APPEND libxerces_c_DEPS ${CURL_LIBRARIES})
> include_directories(${CURL_INCLUDE_DIRS})
> list(APPEND libxerces_c_DEPS ICU::uc ICU::data)
>
> And the resulting includes on the compiler invocation:
>
> /usr/bin/CC   -DHAVE_CONFIG_H -D_FILE_OFFSET_BITS=64 -I.
> -I/tmp/b2/xerces-source/src -Isrc -I/tmp/b2/xerces-source/tests -isystem
> /tmp/b2/superbuild-install/include -msse2 -MD -MT
> tests/CMakeFiles/XSValueTest.dir/src/XSValueTest/XSValueTest.cpp.o -MF
> tests/CMakeFiles/XSValueTest.dir/src/XSValueTest/XSValueTest.cpp.o.d -o
> tests/CMakeFiles/XSValueTest.dir/src/XSValueTest/XSValueTest.cpp.o -c
> /tmp/b2/xerces-source/tests/src/XSValueTest/XSValueTest.cpp
>
> The problem is this:
> CURL is in /usr/local/include
> ICU v55 is in /usr/local/include
> ICU v57 is in /tmp/b2/superbuild-install/include with its libs in
> /tmp/b2/superbuild-install/lib

Sorry, I noticed that the compiler invocation was from the wrong source 
file; it should have -I/usr/local/include right at the start, then 
-isystem /tmp/b2/superbuild-install/include at the end as above.



More information about the CMake mailing list