[CMake] Does set_target_properties compile_flags option override include_directories?

Laura Auton Garcia darklulu+cmake at gmail.com
Wed Mar 30 06:24:20 EDT 2011


Hello all,
The project I am working on uses pkg-config --cflags option to get the
include directories of an external project, and I am trying to add the
output to the compile_flags option used in set_target_properties. As
well as the pkg-config directory, some other flags are specified and
well recognized by the IDE we are building the project for (Visual
Studio).
The code stands as specified here (run_pkgconfig is a macro):
RUN_PKGCONFIG("--cflags" "ACE" result LINKER_FLAGS)
SET(LINKER_FLAGS "${LINKER_FLAGS} -D_CRT_SECURE_NO_WARNINGS
-DACE_AS_STATIC_LIBS")
SET_TARGET_PROPERTIES(
    myproject PROPERTIES
    COMPILE_FLAGS ${LINKER_FLAGS} )

pkg-config output: -Ic:/ace/ace_wrappers/include

The LINKER_FLAGS variable is well set to with this content:
-Ic:/ace/ace_wrappers/include -D_CRT_SECURE_NO_WARNINGS
-DACE_AS_STATIC_LIBS

Prior to this, some include directories from our own project are added
using include_directories statement.
INCLUDE_DIRECTORIES(
   ${MYPROJECT_DIR_PATH}
   ${MYPROJECT_DIR_PATH}/component
   ${MYPROJECT_DIR_PATH}/error
   ${MYPROJECT_DIR_PATH}/libraries)

The project is then built successfully until we open the visual studio
solution generated. After exploring the C/C++ command line properties
of the project, it seems that all the include directories but the one
generated by pkg-config are missing:

/I"c:/ace/ace_wrappers/include" /D "_CRT_SECURE_NO_WARNINGS" /D
"ACE_AS_STATIC_LIBS"

If I don't add the pkg-config output, then all the directories
included with include-directories appear to be ok:

/I"C:/git-projects/myproject" /I"C:/git-projects/myproject/component"
/I"C:/git-projects/myproject/error"
/I"C:/git-projects/myproject/libraries" /D "_CRT_SECURE_NO_WARNINGS"
/D "ACE_AS_STATIC_LIBS"

So the question is, does compile-flags option override all the
directories included with include_directories? If that's the case,
then how do I add external include directories through pkg-config? I
am pretty new at cmake so any help will be appreciated.

Thank you in advance.
Laura Autón.


More information about the CMake mailing list