aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-12-16 13:19:46 +0000
committerAlexander Neundorf <neundorf@kde.org>2007-12-16 13:19:46 +0000
commit095470941e9a5c481ee9736e802052bd390c505f (patch)
tree3a357309a500c2e71b57d6e9a5254f466bbc8bff
parent2414142ddec42fb0c112a7d0df45214d9375b6c3 (diff)
downloadextra-cmake-modules-095470941e9a5c481ee9736e802052bd390c505f.tar.gz
extra-cmake-modules-095470941e9a5c481ee9736e802052bd390c505f.tar.bz2
new macro MACRO_APPEND_IF(var condition value1..valuen)
can be used to simplify code: macro_append_if(mySrcs SOMELIB_FOUND file1.cpp file2.cpp) instead of if(SOMELIB_FOUND) set(mySrcs file1.cpp file2.cpp) endif(SOMELIB_FOUND) Alex svn path=/trunk/KDE/kdelibs/; revision=749077
-rw-r--r--modules/CMakeLists.txt2
-rw-r--r--modules/MacroAppendIf.cmake22
-rw-r--r--modules/MacroLibrary.cmake2
3 files changed, 24 insertions, 2 deletions
diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt
index e8eba2e1..5de4aa7a 100644
--- a/modules/CMakeLists.txt
+++ b/modules/CMakeLists.txt
@@ -1,4 +1,4 @@
-# install the cmake files
+## install the cmake files
file(GLOB cmakeFiles "${CMAKE_CURRENT_SOURCE_DIR}/*.cmake")
diff --git a/modules/MacroAppendIf.cmake b/modules/MacroAppendIf.cmake
new file mode 100644
index 00000000..62949de2
--- /dev/null
+++ b/modules/MacroAppendIf.cmake
@@ -0,0 +1,22 @@
+# MACRO_APPEND_IF( VAR CONDITION VALUE1...VALUEN )
+# This convenience macro appends the values VALUE1 up to VALUEN to the list
+# given in VAR, but only if the variable CONDITION is TRUE:
+#
+# usage example:
+# IF(SOMELIB_FOUND)
+# SET(my_sources ${my_sources} somefile.c someotherfile.c)
+# ENDIF(SOMELIB_FOUND)
+#
+# becomes:
+# MACRO_APPEND_IF(my_sources SOMELIB_FOUND somefile.c someotherfile.c)
+
+# Copyright (c) 2006, 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_append_if _list _cond )
+ if(${_cond})
+ list(APPEND ${_list} ${ARGN})
+ endif(${_cond})
+endmacro(macro_append_if _list _cond )
diff --git a/modules/MacroLibrary.cmake b/modules/MacroLibrary.cmake
index 3b802126..5e482f92 100644
--- a/modules/MacroLibrary.cmake
+++ b/modules/MacroLibrary.cmake
@@ -1,5 +1,4 @@
# - include MacroLibrary offers a collection of macros which extend the built-in cmake commands
-# OPTIONAL_FIND_PACKAGE( <name> [QUIT] )
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
#
@@ -12,6 +11,7 @@ INCLUDE(MacroAdditionalCleanFiles)
INCLUDE(MacroAddFileDependencies)
INCLUDE(MacroAddCompileFlags)
INCLUDE(MacroAddLinkFlags)
+INCLUDE(MacroAppendIf)
INCLUDE(MacroEnsureOutOfSourceBuild)
INCLUDE(MacroBoolTo01)
INCLUDE(MacroPushRequiredVars)