MantisBT - CMake
View Issue Details
0015753CMakeCMakepublic2015-09-21 08:492016-02-01 09:10
danilcha 
 
normalmajoralways
closedduplicate 
Apple MacOS X10.9.5
CMake 3.3.1 
 
0015753: CMake cannot detect changes in nested header files when using '-iquote'
Create a new project with such CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
project(test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -iquote ${CMAKE_CURRENT_SOURCE_DIR}")
add_executable(test-iquote main.cpp dir/1.h dir/2.h)

And such structure:

CMakeLists.txt
Main.cpp (contains #include "dir/1.h")
dir\
    1.h (contains #include "dir/2.h")
    2.h

Build. Then modify 2.h. Build again. Nothing will happen, it will just say '[100%] Built target test-iquote'.
Tried with both clang and GCC. GNU Make 3.81.
No tags attached.
duplicate of 0015491closed Kitware Robot First-class support for GNU -iquote, -I- and -I=opt/foo include directory specifiers 
Issue History
2015-09-21 08:49danilchaNew Issue
2015-09-21 08:52Brad KingNote Added: 0039454
2015-09-21 08:58danilchaNote Added: 0039455
2015-09-21 09:05danilchaNote Added: 0039456
2015-09-21 09:11Brad KingNote Added: 0039457
2015-09-21 09:11Brad KingRelationship addedduplicate of 0015491
2015-09-21 09:12danilchaNote Added: 0039458
2015-09-21 09:12Brad KingNote Added: 0039459
2015-09-21 09:12Brad KingStatusnew => resolved
2015-09-21 09:12Brad KingResolutionopen => duplicate
2015-09-21 09:13danilchaNote Added: 0039460
2016-02-01 09:10Robert MaynardNote Added: 0040412
2016-02-01 09:10Robert MaynardStatusresolved => closed

Notes
(0039454)
Brad King   
2015-09-21 08:52   
CMake does not try to interpret include flags that are not specified through the include_directories or target_include_directories commands. Therefore the Makefile generator dependency scanner does not know about the specified directory.

The Ninja generator should work because it asks the compiler to report dependency information, and that has the full command line.
(0039455)
danilcha   
2015-09-21 08:58   
Also tried with gmake 4.1, the same results.
(0039456)
danilcha   
2015-09-21 09:05   
Brad Kind, thank you! But what is Ninja generator and how to use it? I'm not using the CMake directly, I'm using it though CLion, and at he moment they encourage to use -quote (http://blog.jetbrains.com/clion/2015/08/new-clion-1-1-eap-project-scopes-cmake-targets-and-other-changes/ [^]).

I opened a CLion ticket (https://youtrack.jetbrains.com/issue/CPP-4565 [^]), they said they are fixing the problem in another way, so maybe this issue won't be that important for CLion users soon.
(0039457)
Brad King   
2015-09-21 09:11   
> But what is Ninja generator and how to use it?

When running CMake directly in a fresh build tree one can specify a generator, e.g.

 cmake ../src -GNinja

That will generate build files for the "ninja" build tool instead of "make".

If you're using CMake through CLion then I don't know whether the generator can be selected in this way.
(0039458)
danilcha   
2015-09-21 09:12   
Brad Kind, agha, Ninja is an alternative to 'make', it is even possible to use it with CLion: http://www.mergeconflict.net/2014/11/speeding-up-clion-build-times-with.html, [^] though not very reliably, because is requires manual edit of CMakeCache.
(0039459)
Brad King   
2015-09-21 09:12   
I'm resolving this as a duplicate of 0015491 because that issue covers the underlying problem of supporting -iquote. That issue is actually linked from the article linked in 0015753:0039456.
(0039460)
danilcha   
2015-09-21 09:13   
OK, thank you!
(0040412)
Robert Maynard   
2016-02-01 09:10   
Closing resolved issues that have not been updated in more than 4 months.