Sparse directory support with CMake 2.8

Jonathan Marten jjm2 at keelhaul.demon.co.uk
Thu Mar 4 17:12:39 CET 2010


I'm using/developing some applications in extragear, but not all.  So to make 
keeping up-to-date with SVN easier, I've checked out SVN with sparse 
directories as described in 
http://svnbook.red-bean.com/en/1.5/svn.advanced.sparsedirs.html.  For 
example, extragear/graphics is fully populated but extragear/sdk is empty 
(apart from .svn).

The problem is that, when configuring with CMake 2.8, it fails here with:

CMake Warning (dev) 
at /ws/trunk/inst/share/apps/cmake/modules/MacroOptionalAddSubdirectory.cmake:39 
(ADD_SUBDIRECTORY):
  The source directory

    /ws/trunk/extragear/sdk

  does not contain a CMakeLists.txt file.

  CMake does not support this case but it used to work accidentally and is
  being allowed for compatibility.

  Policy CMP0014 is not set: Input directories must have CMakeLists.txt.  Run
  "cmake --help-policy CMP0014" for policy details.  Use the cmake_policy

Being able to have a sparse source tree is something that used to work, and is 
very useful for developers who don't want to track/build everything.  Would 
it be possible to fix this by changing MacroOptionalAddSubdirectory.cmake as 
follows?

--- MacroOptionalAddSubdirectory.cmake    (revision 1098844)
+++ MacroOptionalAddSubdirectory.cmake    (working copy)
@@ -24,7 +24,7 @@
 
 MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir )
    GET_FILENAME_COMPONENT(_fullPath ${_dir} ABSOLUTE)
-   IF(EXISTS ${_fullPath})
+   IF(EXISTS ${_fullPath}/CMakeLists.txt)
       IF(DISABLE_ALL_OPTIONAL_SUBDIRECTORIES)
          SET(_DEFAULT_OPTION_VALUE FALSE)
       ELSE(DISABLE_ALL_OPTIONAL_SUBDIRECTORIES)
@@ -37,5 +37,5 @@
       IF(BUILD_${_dir})
          ADD_SUBDIRECTORY(${_dir})
       ENDIF(BUILD_${_dir})
-   ENDIF(EXISTS ${_fullPath})
+   ENDIF(EXISTS ${_fullPath}/CMakeLists.txt)
 ENDMACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY)

Also as a side effect, comment 1 at the top of the file would be true again!

Regards, 
  Jonathan

-- 
Jonathan Marten                         http://www.keelhaul.demon.co.uk
Twickenham, UK                          jjm2 at keelhaul.demon.co.uk


More information about the Kde-buildsystem mailing list