aboutsummaryrefslogtreecommitdiff
path: root/modules/MacroAppendIf.cmake
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 /modules/MacroAppendIf.cmake
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
Diffstat (limited to 'modules/MacroAppendIf.cmake')
-rw-r--r--modules/MacroAppendIf.cmake22
1 files changed, 22 insertions, 0 deletions
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 )