From 6bcd26467abb252ca269faad4ae2131566531ce0 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sat, 20 Jan 2007 13:28:47 +0000 Subject: 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 --- modules/MacroOptionalAddSubdirectory.cmake | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 modules/MacroOptionalAddSubdirectory.cmake (limited to 'modules/MacroOptionalAddSubdirectory.cmake') 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( ) +# 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, +# +# 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) -- cgit v1.2.1 From b8079a1830eae2bda2eeadaf7f2ebf6cff173391 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Thu, 14 Aug 2008 20:28:45 +0000 Subject: add a switch to disable all optional dirs initially, e.g. for building only one of all the subdirs (requested by Saro) Alex CCMAIL: ps_ml@gmx.de svn path=/trunk/KDE/kdelibs/; revision=847137 --- modules/MacroOptionalAddSubdirectory.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'modules/MacroOptionalAddSubdirectory.cmake') diff --git a/modules/MacroOptionalAddSubdirectory.cmake b/modules/MacroOptionalAddSubdirectory.cmake index b0d565c2..9566bb4c 100644 --- a/modules/MacroOptionalAddSubdirectory.cmake +++ b/modules/MacroOptionalAddSubdirectory.cmake @@ -19,7 +19,11 @@ MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir ) GET_FILENAME_COMPONENT(_fullPath ${_dir} ABSOLUTE) IF(EXISTS ${_fullPath}) - OPTION(BUILD_${_dir} "Build directory ${_dir}" TRUE) + SET(_DEFAULT_OPTION_VALUE TRUE) + IF(DISABLE_ALL_OPTIONAL_SUBDIRS) + SET(_DEFAULT_OPTION_VALUE FALSE) + ENDIF(DISABLE_ALL_OPTIONAL_SUBDIRS) + OPTION(BUILD_${_dir} "Build directory ${_dir}" ${_DEFAULT_OPTION_VALUE}) IF(BUILD_${_dir}) ADD_SUBDIRECTORY(${_dir}) ENDIF(BUILD_${_dir}) -- cgit v1.2.1 From c8fdd34370f5f0929cb1e531641ed93dbc7e5ae8 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sat, 16 Aug 2008 15:26:55 +0000 Subject: don't override BUILD_ with the DISABLE_ALL master switch Alex svn path=/trunk/KDE/kdelibs/; revision=848008 --- modules/MacroOptionalAddSubdirectory.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/MacroOptionalAddSubdirectory.cmake') diff --git a/modules/MacroOptionalAddSubdirectory.cmake b/modules/MacroOptionalAddSubdirectory.cmake index 9566bb4c..32e25141 100644 --- a/modules/MacroOptionalAddSubdirectory.cmake +++ b/modules/MacroOptionalAddSubdirectory.cmake @@ -20,9 +20,9 @@ MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir ) GET_FILENAME_COMPONENT(_fullPath ${_dir} ABSOLUTE) IF(EXISTS ${_fullPath}) SET(_DEFAULT_OPTION_VALUE TRUE) - IF(DISABLE_ALL_OPTIONAL_SUBDIRS) + IF(DISABLE_ALL_OPTIONAL_SUBDIRS AND NOT DEFINED BUILD_${_dir}) SET(_DEFAULT_OPTION_VALUE FALSE) - ENDIF(DISABLE_ALL_OPTIONAL_SUBDIRS) + ENDIF(DISABLE_ALL_OPTIONAL_SUBDIRS AND NOT DEFINED BUILD_${_dir}) OPTION(BUILD_${_dir} "Build directory ${_dir}" ${_DEFAULT_OPTION_VALUE}) IF(BUILD_${_dir}) ADD_SUBDIRECTORY(${_dir}) -- cgit v1.2.1 From 200901dce93b54946d79b6d38564cddf14990afe Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Tue, 17 Mar 2009 21:27:31 +0000 Subject: Add a cmake variable DISABLE_ALL_OPTIONAL_SUBDIRECTORIES which can be set to TRUE to disable all subdirectories by default This should make building project in a modular way easier. Alex svn path=/trunk/KDE/kdelibs/; revision=940644 --- modules/MacroOptionalAddSubdirectory.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'modules/MacroOptionalAddSubdirectory.cmake') diff --git a/modules/MacroOptionalAddSubdirectory.cmake b/modules/MacroOptionalAddSubdirectory.cmake index 32e25141..bf1196bf 100644 --- a/modules/MacroOptionalAddSubdirectory.cmake +++ b/modules/MacroOptionalAddSubdirectory.cmake @@ -9,6 +9,12 @@ # subdirectory. # This is useful if you want to compile only a subset of all # directories. +# +# If the CMake variable DISABLE_ALL_OPTIONAL_SUBDIRECTORIES is set to TRUE +# for the first CMake run on the project, all subdirectories will be disabled +# by default (but can of course be enabled via the respective options). +# E.g. the following will disable all subdirectories except the one named "kcalc": +# $ cmake -DDISABLE_ALL_OPTIONAL_SUBDIRECTORIES=TRUE -DBUILD_kcalc=TRUE # Copyright (c) 2007, Alexander Neundorf, # @@ -19,7 +25,11 @@ MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir ) GET_FILENAME_COMPONENT(_fullPath ${_dir} ABSOLUTE) IF(EXISTS ${_fullPath}) - SET(_DEFAULT_OPTION_VALUE TRUE) + IF(DISABLE_ALL_OPTIONAL_SUBDIRECTORIES) + SET(_DEFAULT_OPTION_VALUE FALSE) + ELSE(DISABLE_ALL_OPTIONAL_SUBDIRECTORIES) + SET(_DEFAULT_OPTION_VALUE TRUE) + ENDIF(DISABLE_ALL_OPTIONAL_SUBDIRECTORIES) IF(DISABLE_ALL_OPTIONAL_SUBDIRS AND NOT DEFINED BUILD_${_dir}) SET(_DEFAULT_OPTION_VALUE FALSE) ENDIF(DISABLE_ALL_OPTIONAL_SUBDIRS AND NOT DEFINED BUILD_${_dir}) -- cgit v1.2.1 From 402833335d31d0b7c445e082f1134357c68ed350 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Tue, 17 Mar 2009 22:03:56 +0000 Subject: -make documentation more exact Alex svn path=/trunk/KDE/kdelibs/; revision=940658 --- modules/MacroOptionalAddSubdirectory.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/MacroOptionalAddSubdirectory.cmake') diff --git a/modules/MacroOptionalAddSubdirectory.cmake b/modules/MacroOptionalAddSubdirectory.cmake index bf1196bf..5de49f95 100644 --- a/modules/MacroOptionalAddSubdirectory.cmake +++ b/modules/MacroOptionalAddSubdirectory.cmake @@ -11,9 +11,9 @@ # directories. # # If the CMake variable DISABLE_ALL_OPTIONAL_SUBDIRECTORIES is set to TRUE -# for the first CMake run on the project, all subdirectories will be disabled +# for the first CMake run on the project, all optional subdirectories will be disabled # by default (but can of course be enabled via the respective options). -# E.g. the following will disable all subdirectories except the one named "kcalc": +# E.g. the following will disable all optional subdirectories except the one named "kcalc": # $ cmake -DDISABLE_ALL_OPTIONAL_SUBDIRECTORIES=TRUE -DBUILD_kcalc=TRUE # Copyright (c) 2007, Alexander Neundorf, -- cgit v1.2.1 From 52480798b223873f585937940a0083ca463ad47a Mon Sep 17 00:00:00 2001 From: Jonathan Marten Date: Fri, 5 Mar 2010 08:41:10 +0000 Subject: Allow macro_optional_add_subdirectory to work with CMake 2.8 in the case where a directory exists but is empty, by checking that it contains a CMakeLists.txt file before adding it. OK from kde-buildsystem list at http://lists.kde.org/?t=126772053200003&r=1&w=2 svn path=/trunk/KDE/kdelibs/; revision=1099212 --- modules/MacroOptionalAddSubdirectory.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/MacroOptionalAddSubdirectory.cmake') diff --git a/modules/MacroOptionalAddSubdirectory.cmake b/modules/MacroOptionalAddSubdirectory.cmake index 5de49f95..ec0ea30a 100644 --- a/modules/MacroOptionalAddSubdirectory.cmake +++ b/modules/MacroOptionalAddSubdirectory.cmake @@ -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 @@ MACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY _dir ) IF(BUILD_${_dir}) ADD_SUBDIRECTORY(${_dir}) ENDIF(BUILD_${_dir}) - ENDIF(EXISTS ${_fullPath}) + ENDIF(EXISTS ${_fullPath}/CMakeLists.txt) ENDMACRO (MACRO_OPTIONAL_ADD_SUBDIRECTORY) -- cgit v1.2.1