[CMake] IF(IS_DIRECTORY behaviour

Brad King brad.king at kitware.com
Mon Jun 26 10:29:40 EDT 2006


David Somers wrote:
> I've been updating a few of my old cmake files (and writing a few new ones 
> too)... in a few places I've been adding some IF(IS_DIRECTORY foo) tests.
> 
> I just noticed some strange behaviour in cmake-2.4.2:
> 
> I'm trying to test to see if directory foo is present in 
> ${CMAKE_CURRENT_SOURCE_DIR}
> 
> IF(IS_DIRECTORY blah)
> ...
> ENDIF(IS_DIRECTORY blah)
> 
> does NOT work.
> 
> IF(IS_DIRECTORY ./blah)
> ...
> ENDIF(IS_DIRECTORY ./blah)
> 
> does work.
> 
> This seems wrong (having prefix with "./") Thoughts?
> 
> BTW, I assume that IS_DIRECTORY works relative to ${CMAKE_CURRENT_SOURCE_DIR} 
> unless a path to an absolute dir is given... the help for the IF(IS_DIRECTORY 
> command doesn't state this at all :-(

Always use a full path for these options.  When running in script mode 
(cmake -P) there is no current source dir.

-Brad


More information about the CMake mailing list