From 5b0a774eaabe3123cf7f659314cf0d0886c21e80 Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> Date: Mon, 4 Feb 2019 18:16:30 +0100 Subject: [PATCH] [cmake] Give a meaningful error message if not cloned recursively --- cmake/modules/CMakeLists.txt | 1 + cmake/modules/DuneCodegenMacros.cmake | 1 + cmake/modules/DuneSubmoduleChecker.cmake | 36 ++++++++++++++++++++++++ python/CMakeLists.txt | 7 +++++ 4 files changed, 45 insertions(+) create mode 100644 cmake/modules/DuneSubmoduleChecker.cmake diff --git a/cmake/modules/CMakeLists.txt b/cmake/modules/CMakeLists.txt index 0746ef28..1227056c 100644 --- a/cmake/modules/CMakeLists.txt +++ b/cmake/modules/CMakeLists.txt @@ -1,5 +1,6 @@ install(FILES deplist.py dune-codegen_sourcepath.py DuneCodegenMacros.cmake + DuneSubmoduleChecker.cmake GeneratedSystemtest.cmake DESTINATION ${DUNE_INSTALL_MODULEDIR}) diff --git a/cmake/modules/DuneCodegenMacros.cmake b/cmake/modules/DuneCodegenMacros.cmake index 68231070..0bc00246 100644 --- a/cmake/modules/DuneCodegenMacros.cmake +++ b/cmake/modules/DuneCodegenMacros.cmake @@ -160,3 +160,4 @@ function(add_generated_executable) endfunction() include(GeneratedSystemtests) +include(DuneSubmoduleChecker) diff --git a/cmake/modules/DuneSubmoduleChecker.cmake b/cmake/modules/DuneSubmoduleChecker.cmake new file mode 100644 index 00000000..ad640dff --- /dev/null +++ b/cmake/modules/DuneSubmoduleChecker.cmake @@ -0,0 +1,36 @@ +# A CMake module to check for the existence of submodules! +# +# .. cmake_function:: dune_check_submodule +# +# .. cmake_param:: PATH +# :required: +# +# The relative path to the submodule directory +# +# .. cmake_param:: INDICATOR +# :required: +# +# A filename (like setup.py) that indicates a correctly cloned submodule +# + + +function(dune_check_submodule) + # Parse Arguments + include(CMakeParseArguments) + cmake_parse_arguments(SUBMODULE "" "PATH;INDICATOR" "" ${ARGN}) + + if(SUBMODULE_UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments in dune_check_submodule: This often indicates typos!") + endif() + + if(NOT SUBMODULE_PATH) + message(FATAL_ERROR "PATH argument not given to dune_check_submodule!") + endif() + if(NOT SUBMODULE_INDICATOR) + message(FATAL_ERROR "INDICATOR argument not given to dune_check_submodule!") + endif() + + if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${SUBMODULE_PATH}/${SUBMODULE_INDICATOR}) + message(FATAL_ERROR "No git submodule found at location ${CMAKE_CURRENT_SOURCE_DIR}/${SUBMODULE_PATH}. You should clone this repository with the --recursive flag! It is described in the README!") + endif() +endfunction() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 4c7b4d72..84ac5660 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,3 +1,10 @@ +# Check that the submodules have been checked out! +dune_check_submodule(PATH pytools INDICATOR setup.py) +dune_check_submodule(PATH cgen INDICATOR setup.py) +dune_check_submodule(PATH pymbolic INDICATOR setup.py) +dune_check_submodule(PATH loopy INDICATOR setup.py) +dune_check_submodule(PATH ufl INDICATOR setup.py) + # Install all the external packages that we have as submodules dune_python_install_package(PATH pytools) dune_python_install_package(PATH cgen) -- GitLab