[cmake-developers] [CMake 0013188]: Target and directory include_directory usage.

Mantis Bug Tracker mantis at public.kitware.com
Fri May 4 01:04:17 EDT 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=13188 
====================================================================== 
Reported By:                bungeman
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13188
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2012-05-04 01:04 EDT
Last Modified:              2012-05-04 01:04 EDT
====================================================================== 
Summary:                    Target and directory include_directory usage.
Description: 
I tried out the newly added target and directory INCLUDE_DIRECTORIES property
and ran into some issues. I can't seem to be able to set the directory property
at all. The target property appears to treat relative includes as being relative
to the build directory, which is confusing since include_directories(...) treats
them relative to the source (CMakeLists.txt) directory.

Steps to Reproduce: 
./main.cpp
  #include "target_include.h"
  int main(int, char**) { return foo; }

./include/target_include.h
  #define foo 0

./CMakeLists.txt
  cmake_minimum_required(VERSION 2.8.8)
  project(directory_includes)
  add_executable(target main.cpp)

  #when attempting to 'make' in './build' subdirectory after running 'cmake ..'

  #does not work but should
  #set_property(TARGET target APPEND PROPERTY INCLUDE_DIRECTORIES "includes")
  #set_property(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES "includes")
  #set_directory_properties(PROPERTY INCLUDE_DIRECTORIES "includes")
  #set_property(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/includes")
  #set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/includes")
  #set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY
INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/includes")
  #set_directory_properties(PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/includes")

  #shouldn't work, and doesn't
  #set_property(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES "../includes")
  #set_directory_properties(PROPERTY INCLUDE_DIRECTORIES "../includes")

  #works, and should
  #set_property(TARGET target APPEND PROPERTY INCLUDE_DIRECTORIES
"${CMAKE_CURRENT_SOURCE_DIR}/includes")
  include_directories(includes)

  #works, and shouldn't
  #set_property(TARGET target APPEND PROPERTY INCLUDE_DIRECTORIES "../includes")


Additional Information: 
Note that all of the above which fail parse and generate makefiles fine, but the
resulting makefiles fail to build as they do not include 'includes' in the list
of include directories. This was tested with current master branch (c196e9ea).

The one test in Tests/IncludeDirectories just tests the one new case which does
work and should -- that setting INCLUDE_DIRECTORIES with an absolute path works.
There are a few places where the directory version is used or tested, but it
only appears to be testing that it parsed ok, not that it actually worked. It
seems like there should be at least one test like
Tests/IncludeDirectories/TargetIncludeDirectories called
DirectoryIncludeDirectories.

If these are supposed to be relative to the build directory, then it would be
useful to document that, though it certainly seems like they should be relative
to the source directory. I suppose there should be tests for this as well.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-05-04 01:04 bungeman       New Issue                                    
======================================================================




More information about the cmake-developers mailing list