aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-01-20 13:28:47 +0000
committerAlexander Neundorf <neundorf@kde.org>2007-01-20 13:28:47 +0000
commit6bcd26467abb252ca269faad4ae2131566531ce0 (patch)
treed2972ef2f5edac856253b5aa34e76e0f102bf377
parent4a12ccbf2a87c8e88b1cc2ee70c914b62c3f5c52 (diff)
downloadextra-cmake-modules-6bcd26467abb252ca269faad4ae2131566531ce0.tar.gz
extra-cmake-modules-6bcd26467abb252ca269faad4ae2131566531ce0.tar.bz2
Added new macro MACRO_OPTIONAL_ADD_SUBDIRECTORY(dir), which might be useful e.g. for extragear.
If you use this instead of the normal ADD_SUBDIRECTORY(), it adds for every directory an option so you can skip this directory, and it doesn't complain if the directory doesn't exist. E.g. if you want to compile just one project from the extragear or kdesupport you can turn the other dirs off if you use this macro instead of the normal ADD_SUBDIRECTORY() Alex CCMAIL: kde-core-devel@kde.org CCMAIL: kde-buildsystem@kde.org svn path=/trunk/KDE/kdelibs/; revision=625574
-rw-r--r--modules/MacroLibrary.cmake1
-rw-r--r--modules/MacroOptionalAddSubdirectory.cmake27
2 files changed, 28 insertions, 0 deletions
diff --git a/modules/MacroLibrary.cmake b/modules/MacroLibrary.cmake
index 59836927..3b802126 100644
--- a/modules/MacroLibrary.cmake
+++ b/modules/MacroLibrary.cmake
@@ -7,6 +7,7 @@
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
INCLUDE(MacroOptionalFindPackage)
+INCLUDE(MacroOptionalAddSubdirectory)
INCLUDE(MacroAdditionalCleanFiles)
INCLUDE(MacroAddFileDependencies)
INCLUDE(MacroAddCompileFlags)
diff --git a/modules/MacroOptionalAddSubdirectory.cmake b/modules/MacroOptionalAddSubdirectory.cmake
new file mode 100644
index 00000000..b0d565c2
--- /dev/null
+++ b/modules/MacroOptionalAddSubdirectory.cmake
@@ -0,0 +1,27 @@
+# - MACRO_OPTIONAL_ADD_SUBDIRECTORY() combines ADD_SUBDIRECTORY() with an OPTION()
+# MACRO_OPTIONAL_ADD_SUBDIRECTORY( <dir> )
+# If you use MACRO_OPTIONAL_ADD_SUBDIRECTORY() instead of ADD_SUBDIRECTORY(),
+# this will have two effects
+# 1 - CMake will not complain if the directory doesn't exist
+# This makes sense if you want to distribute just one of the subdirs
+# in a source package, e.g. just one of the subdirs in kdeextragear.
+# 2 - If the directory exists, it will offer an option to skip the
+# subdirectory.
+# This is useful if you want to compile only a subset of all
+# directories.
+
+# Copyright (c) 2007, Alexander Neundorf, <neundorf@kde.org>
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+
+MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir )
+ GET_FILENAME_COMPONENT(_fullPath ${_dir} ABSOLUTE)
+ IF(EXISTS ${_fullPath})
+ OPTION(BUILD_${_dir} "Build directory ${_dir}" TRUE)
+ IF(BUILD_${_dir})
+ ADD_SUBDIRECTORY(${_dir})
+ ENDIF(BUILD_${_dir})
+ ENDIF(EXISTS ${_fullPath})
+ENDMACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY)