[CMake] CMAKE_INCLUDE_CURRENT_DIR only for out-of-source ?

Brad King brad.king at kitware.com
Mon Mar 20 18:47:44 EST 2006


Alexander Neundorf wrote:
> Hi, 
>  
> in cmLocalGenerator.cxx there's the following code: 
>  
> if(!inSource && this->Makefile->IsOn("CMAKE_INCLUDE_CURRENT_DIR")) 
> { 
>    includeSourceDir = true; 
>    includeBinaryDir = true; 
> } 
>  
> Why is there the test for !inSource ? 
>  
> This means if I have in one directory: 
>  
> test1.h 
> main.c: 
>  
> #include <test1.h> 
> int main() 
> { 
> ... 
> } 
>  
> This will work for out-of-source builds, but not for in-source builds. 
> I would have expected that the CMAKE_INCLUDE_CURRENT_DIR option also adds 
> CMAKE_CURRENT_SOURCE_DIR to the include path for in-source builds. 
> Are there special reasons why not ? 

The idea of that option was to make *double-quote* includes look the 
same for in-source and out-of-source builds.  For angle-bracket includes 
only the explicitly given include path should be used.

Note in your example that running just

   gcc main.c

will not work.

-Brad


More information about the CMake mailing list