Skip to content
Snippets Groups Projects
Commit b3d8b8f8 authored by Steffen Müthing's avatar Steffen Müthing
Browse files

[CMake][Release] Fix dune_enable_all_packages()-related problems


This branch fixes a number of problems related to
dune_enable_all_packages():

- The feature requires at least CMake 2.8.12, which is more recent than
  the baseline requirement of the core modules (2.8.12). We now check
  for that when executing the relevant functions and also remind the
  user to set the correct version in cmake_minimum_required().
- Updated the documentation to also state the version requirement.
- The duneproject script now also warns the user about the more
  stringent CMake version requirements when using the feature and sets
  the correct minimum required CMake version in the new module's main
  CMakeLists.txt file.
- There was a bug in duneproject that caused it to always enable
  dune_enable_all_packages(), ignoring the choice made by the user. That
  bug is fixed in this branch.
- Some minor fixes to duneproject while I was at it.

This fixes FS1678.

* feature/FS1678:
  [dunecontrol] Output choice of external package handling and required CMake version
  [duneproject] Allow specifying ENABLE_ALL as 5th command line argument
  [duneproject] Update CMake minimum version if ENABLE_ALL is true
  [duneproject][Bugfix] Make sure dune_enable_all_packages() can actually be disabled
  [CMake] Improve documentation in DuneEnableAllPackages.cmake
  [CMake][Doc] Add required CMake version to dune_enable_all_packages()
  [CMake] Require CMake 2.8.12 for dune_enable_all_packages()
  [CMake] Fix typo in warning message.
  Add a warning that some functions are 2.8.12

(cherry picked from commit 90411efd)
Signed-off-by: default avatarSteffen Müthing <muething@dune-project.org>
parent 2e05853b
No related branches found
No related tags found
No related merge requests found
......@@ -181,10 +181,15 @@ PROJECT="$1"
DEPENDENCIES="$2"
VERSION="$3"
MAINTAINER="$4"
ENABLE_ALL="$5"
################## READ OPTIONS ##################
while [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; do
# Track minimum CMake version
CMAKE_MINIMUM_REQUIRED=2.8.6
while [ -z $PROJECT ]; do
read -p "1) Name of your new Project? (e.g.: dune-grid): " PROJECT
if echo "$MODULES" | grep -q ^$PROJECT$; then
......@@ -226,13 +231,29 @@ while [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; do
read -p "4) Maintainer's email address? " MAINTAINER
done
while [ "$ENABLE_ALL" != "y" -a "$ENABLE_ALL" != "Y" -a "$ENABLE_ALL" != "n" -a "$ENABLE_ALL" != "N" ]; do
read -p "5) Enable all available packages? (Choose 'y' if you don't understand the question.) [y/N]" ENABLE_ALL
echo "5) Enable all available packages? (Choose 'y' if you don't understand the question, but see warning below.)"
read -p " WARNING: If you enable this option, your module will require at least CMake 2.8.12 to build. You can check your version with 'cmake --version' [y/N]" ENABLE_ALL
done
# canonicalize contents of ENABLE_ALL
ENABLE_ALL=$(tr '[:upper:]' '[:lower:]' <<< "$ENABLE_ALL")
# set newer CMake minimum version if ENABLE_ALL is true
if [ 'y' == "$ENABLE_ALL" ] ; then
CMAKE_MINIMUM_REQUIRED=2.8.12
fi
echo
echo "creating Project \"$PROJECT\", version $VERSION "
echo "which depends on \"$DEPENDENCIES\""
echo "with maintainer \"$MAINTAINER\""
if [ "y" == "$ENABLE_ALL" ] ; then
echo "and new, automatic external package handling based on dune_enable_all_packages()."
else
echo "and old external package handling (you need to manually add external dependencies to each target in CMakeLists.txt)."
fi
echo "Minimum required CMake version for building this project: ${CMAKE_MINIMUM_REQUIRED}"
echo
read -p "Are these informations correct? [y/N] " DATACORRECT
# reset data if necessary
......@@ -243,7 +264,10 @@ while [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; do
MAINTAINER=""
ENABLE_ALL=""
fi
done
done
echo
echo "A sample code $MODULE.cc is generated in the \"$PROJECT\" directory."
......@@ -373,7 +397,7 @@ Preparing the Sources
Additional to the software mentioned in README you'll need the
following programs installed on your system:
cmake >= 2.8.6
cmake >= ${CMAKE_MINIMUM_REQUIRED}
or if you use the old autoconf build system:
......@@ -486,7 +510,7 @@ M_DELIM
################## CMakeLists.txt ##################
echo "- $PROJECT/CMakeLists.txt"
cat> "$PROJECT/CMakeLists.txt" << M_DELIM
cmake_minimum_required(VERSION 2.8.6)
cmake_minimum_required(VERSION ${CMAKE_MINIMUM_REQUIRED})
project($PROJECT CXX)
if(NOT (dune-common_DIR OR dune-common_ROOT OR
......@@ -506,7 +530,7 @@ include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
M_DELIM
if test ! -z "$ENABLE_ALL"; then
if [ 'y' == "$ENABLE_ALL" ] ; then
cat>> "$PROJECT/CMakeLists.txt" << M_DELIM
dune_enable_all_packages()
M_DELIM
......
# This module provides the macros necessary for a simplified CMake build system
# This module provides the functions necessary for a simplified CMake build system
#
# The DUNE build system relies on the user to choose and add the compile and link flags
# necessary to build an executable. While this offers full control to the user, it
# is an error-prone procedure.
#
# Alternatively, users may use the macros in this module to simply add the compile flags for all
# Alternatively, users may use the functions in this module to simply add the compile flags for all
# found external modules to all executables in a DUNE module. Likewise, all found libraries are
# linked to all targets.
#
# This module provides the following macros:
# This module provides the following functions:
#
# dune_enable_all_packages(INCLUDE_DIRS [include_dirs]
# COMPILE_DEFINITIONS [compile_definitions]
......@@ -18,8 +18,8 @@
# )
#
# Adds all flags and all libraries to all executables that are subsequently added in the directory
# from where this macro is called and from all its subdirectories (recursively).
# If used, this macro MUST be called in the top level CMakeLists.txt BEFORE adding any subdirectories!
# from where this function is called and from all its subdirectories (recursively).
# If used, this function MUST be called in the top level CMakeLists.txt BEFORE adding any subdirectories!
# You can optionally add additional include dirs and compile definitions that will also be applied to
# all targets in the module.
# Finally, if your module contains libraries as well as programs and if the programs should automatically
......@@ -30,6 +30,9 @@
# versions handle linking (in particular CMP022 and CMP038). You can later add source files to the library
# anywhere in the source tree by calling dune_library_add_sources().
#
# Warning: dune_enable_all_packages() requires CMake 2.8.12+. If you call this function with an older version
# of CMake, the build will fail with a fatal error. DO NOT enable this feature if your module needs
# to compile on machines with an older version of CMake.
# Warning: The library feature requires CMake 3.1+. If you use the feature with older versions, CMake
# will emit a fatal error. Moreover, it will issue a warning if the cmake_minimum_required()
# version is older than 3.1.
......@@ -47,9 +50,11 @@
# dune_target_enable_all_packages(TARGETS [target] ...)
#
# Adds all currently registered package flags (see dune_register_package_flags()) to the given targets.
# This macro is mainly intended to help write DUNE modules that want to use dune_enable_all_packages() and
# This function is mainly intended to help write DUNE modules that want to use dune_enable_all_packages() and
# define their own libraries, but need to be compatible with CMake < 3.1.
#
# Note: Just like dune_enable_all_packages(), this function requires CMake 2.8.12+.
#
#
# dune_register_package_flags(COMPILE_DEFINITIONS [flags]
# COMPILE_OPTIONS [options]
......@@ -59,7 +64,7 @@
# )
#
# To correctly implement the automatic handling of external libraries, the compile flags, include paths and link
# flags of all found packages must be registered with this function. This macro is only necessary for people that
# flags of all found packages must be registered with this function. This function is only necessary for people that
# want to write their own FindFooBar CMake modules to link against additional libraries which are not supported by
# the DUNE core modules. Call this function at the end of every find module. If you are using an external FindFoo
# module which you cannot alter, call it after the call to find_package(foo).
......@@ -105,6 +110,16 @@ endfunction(dune_register_package_flags)
function(dune_enable_all_packages)
if (CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "dune_enable_all_packages() needs CMake 2.8.12+")
elseif(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
message(WARNING
"You are using dune_enable_all_packages().
This requires at least CMake 2.8.12, but your Dune module only requires ${CMAKE_MINIMUM_REQUIRED_VERSION}.
Update the cmake_minimum_required() call in your main CMakeLists.txt file to get rid of this warning.")
endif()
include(CMakeParseArguments)
set(OPTIONS APPEND VERBOSE)
set(SINGLEARGS)
......@@ -240,6 +255,15 @@ endfunction(dune_enable_all_packages)
function(dune_target_enable_all_packages)
if (CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "dune_target_enable_all_packages() needs CMake 2.8.12+")
elseif(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
message(WARNING
"You are using dune_target_enable_all_packages().
This requires at least CMake 2.8.12, but your Dune module only requires ${CMAKE_MINIMUM_REQUIRED_VERSION}.
Update the cmake_minimum_required() call in your main CMakeLists.txt file to get rid of this warning.")
endif()
foreach(_target ${ARGN})
get_property(all_incs GLOBAL PROPERTY ALL_PKG_INCS)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment