[cmake-developers] Setting the INCLUDE_DIRECTORIES property before and after a target after 9106b564

Raphael Kubo da Costa rakuco at FreeBSD.org
Mon Apr 30 20:37:21 EDT 2012


While packaging CMake 2.8.8 for FreeBSD, an old port of lprof [1]
started failing to build after some include headers were not found.

The relevant CMakeLists does the following:

  add_library(foo foo.c)
  set_directory_properties(
      PROPERTIES INCLUDE_DIRECTORIES "${SOME_DIRECTORY}")

foo.c includes "bar.h" which is in ${SOME_DIRECTORY}.

This used to work until commit 9106b564ae5bf0bf1c1ff4a3fca484bcfd40e183,
and the following patch can be applied to master for ctest to fail on
the IncludeDirectories test:

diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
index 2cf36f5..05065c2 100644
--- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt
@@ -21,6 +21,7 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/bar")

 add_executable(TargetIncludeDirectories main.cpp)
 set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/bat")
-set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foo")
+# set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foo")
+set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foo")

 include_directories("${CMAKE_CURRENT_BINARY_DIR}/baz")

Moving that set_property(DIRECTORY) call somewhere before the
add_executable() call makes the test pass.

Is this change of behaviour intentional?

Cheers.

[1] http://www.freshports.org/graphics/lprof-devel




More information about the cmake-developers mailing list