MantisBT - CMake
View Issue Details
0014109CMakeCMakepublic2013-04-23 22:222013-10-07 10:09
Tim Patterson 
David Cole 
normalminoralways
closedno change required 
CMake 2.8.8 
CMake 2.8.8 
0014109: Target property INCLUDE_DIRECTORIES is ignored in Visual Studio Generator
The INCLUDE_DIRECTORIES property on a target appears to be ignored by the VS generator. Setting the property on the directory works fine.
CMakeLists.txt:

PROJECT(SomeProject)
cmake_minimum_required(VERSION 2.8)

ADD_LIBRARY(HelloWorld HelloWorld.cpp)

IF(TRUE)
    # This doesn't work (despite being set correctly):
    SET_PROPERTY(TARGET HelloWorld APPEND PROPERTY INCLUDE_DIRECTORIES "ThisIsATest")
    GET_TARGET_PROPERTY(_includeDirs HelloWorld INCLUDE_DIRECTORIES)
    MESSAGE("_includeDirs = ${_includeDirs}")
ELSE()
    # This works:
    SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES "ThisIsATest")
ENDIF()
No tags attached.
Issue History
2013-04-23 22:22Tim PattersonNew Issue
2013-04-23 23:32David ColeNote Added: 0032930
2013-04-23 23:37Tim PattersonNote Added: 0032931
2013-04-23 23:58David ColeNote Added: 0032932
2013-04-24 00:07Tim PattersonNote Added: 0032933
2013-04-24 08:01David ColeAssigned To => David Cole
2013-04-24 08:01David ColeStatusnew => assigned
2013-04-24 08:01David ColeNote Added: 0032934
2013-04-24 08:01David ColeStatusassigned => resolved
2013-04-24 08:01David ColeFixed in Version => CMake 2.8.8
2013-04-24 08:01David ColeResolutionopen => no change required
2013-10-07 10:09Robert MaynardNote Added: 0034037
2013-10-07 10:09Robert MaynardStatusresolved => closed

Notes
(0032930)
David Cole   
2013-04-23 23:32   
This is fixed already in 2.8.11.

When I run your CMakeLists file with CMake 2.8.11-rc3, I get this output:

_includeDirs = ThisIsATest
(0032931)
Tim Patterson   
2013-04-23 23:37   
Note that the property always prints out correctly - even in the earlier version I am running. I just put it in as a sanity check. The real test is to see if the path appears in the generated project's property page (Which can't be tested from within cmake easily).
(0032932)
David Cole   
2013-04-23 23:58   
Well if I add a HelloWorld.cpp file so that it generates correctly, and I look at the generated Visual Studio project, I see:

ThisIsATest;%(AdditionalIncludeDirectories)

in the "Additional Include Directories" field.

So... I still contend that this is fixed in later versions of CMake. The INCLUDE_DIRECTORIES property did not become write-able as a target property directly until version 2.8.8.

Are you certain you are using CMake 2.8.8 to do this?

What version of Visual Studio are you using?

I cannot reproduce the problem when I use CMake 2.8.11-rc3 and Visual Studio 11.
(0032933)
Tim Patterson   
2013-04-24 00:07   
I just upgraded to cmake 2.8.10.2 and the issue is resolved. I checked and I was using 2.8.7 :-/. I guess that means u can close this ticket!

Thanks for getting back to me so quickly, btw! Thanks for such a fantastic tool, too! :-)
(0032934)
David Cole   
2013-04-24 08:01   
See previous notes for details...
(0034037)
Robert Maynard   
2013-10-07 10:09   
Closing resolved issues that have not been updated in more than 4 months.