Permalink
Browse files

Use IncludeKrimsCmakeModule and FindPackageAutocheckoutFallback from …

…krims
  • Loading branch information...
mfherbst committed Aug 9, 2017
1 parent f0e659b commit d5ee49d9ec48383410ed1d9ff042389e1f845cb6
Showing with 94 additions and 148 deletions.
  1. +91 −34 cmake/IncludeKrimsCmakeModule.cmake
  2. +0 −110 cmake/findKrims.cmake
  3. +2 −4 cmake/setup_dependencies.cmake
  4. +1 −0 update_from_sister_repos.sh
@@ -1,32 +1,38 @@
## ---------------------------------------------------------------------
##
## Copyright (C) 2016-17 by the layzten authors
## Copyright (C) 2016-17 by the lazyten authors
##
## This file is part of layzten.
## This file is part of lazyten.
##
## layzten is free software: you can redistribute it and/or modify
## lazyten is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published
## by the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## layzten is distributed in the hope that it will be useful,
## lazyten is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with layzten. If not, see <http://www.gnu.org/licenses/>.
## along with lazyten. If not, see <http://www.gnu.org/licenses/>.
##
## ---------------------------------------------------------------------
## DO NOT EDIT
## This file is automatically generated from a file in the repository "krims".
## Edit the original and call the script "update_from_sister_repos.sh" instead.
# Try to find a cmake module which gets shipped with krims.
#
# In case the module is not found and AUTOCHECKOUT_MISSING_LIBS is set to
# on, krims is automatically checked out and the module is loaded from there.
# Otherwise a fatal error is produced.
# This module is not intended to be used from within krims at all.
# It is just for convenience of downstream libraries, such that they can
# find krims during their install process.
#
option(AUTOCHECKOUT_MISSING_REPOS "Automatically checkout missing repositories" OFF)
option(AUTOCHECKOUT_FORCED
"Force autocheckout of repositories, even if they are present on the system. \
Implies AUTOCHECKOUT_MISSING_REPOS set to ON" OFF)
if (NOT DEFINED EXTERNAL_DIR)
if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/../external/get_krims.sh")
@@ -37,46 +43,97 @@ projects. Try to specify it manually using the variable EXTERNAL_DIR.")
endif()
endif()
function(autocheckout_krims)
# We could not include it with the hint => try autocheckout
execute_process(
COMMAND "sh" "get_krims.sh"
WORKING_DIRECTORY "${EXTERNAL_DIR}"
RESULT_VARIABLE RES
)
if (NOT RES EQUAL 0)
message(FATAL_ERROR "Getting krims failed with error: ${RES}")
endif()
endfunction()
# NOTE: This has to be a macro otherwise it opens a new scope, which means
# that the variables set in teh included modules are *not* available
# that the variables set in the included modules are *not* available
# to the outside scope!
macro(include_krims_cmake_module MODULE)
# Sanity check
# Search for a cmake module distributed with krims in the following places:
# - The hint given via 'krims_DIR' environment or cmake cache variable
# - The location generated by inspecting the CMAKE_INSTALL_PREFIX
# - The default include call (i.e. system modules)
# - Do and autocheckout (if allowed) and search for the module in the
# checked out version of krims.
#
# If AUTOCHECKOUT_FORCED is ON only the last search (i.e. autocheckout
# and a search in the automatically checked out version) will be done.
#
if(NOT EXISTS "${EXTERNAL_DIR}/get_krims.sh")
message(FATAL_ERROR "get_krims.sh does not exist in EXTERNAL_DIR \
== ${EXTERNAL_DIR}.")
endif()
# First try to load it plainly as a module:
include(${MODULE} OPTIONAL RESULT_VARIABLE RES)
if ("${RES}" STREQUAL "NOTFOUND")
# We could not "just" find it. Try the krims_DIR hint:
include("$ENV{krims_DIR}/share/cmake/modules/${MODULE}.cmake"
OPTIONAL RESULT_VARIABLE RES)
# Determine FIRST_TRY_LOCATION, i.e the place where we first try to find
# the module
set(FIRST_TRY_LOCATION "")
if (NOT "$ENV{krims_DIR}" MATCHES "NOTFOUND"
AND NOT "$ENV{krims_DIR}" MATCHES "AUTOCHECKOUT")
set(FIRST_TRY_LOCATION
"$ENV{krims_DIR}/share/cmake/modules/${MODULE}.cmake")
endif()
if ("${RES}" STREQUAL "NOTFOUND")
if (AUTOCHECKOUT_MISSING_REPOS)
# We could not include it with the hint => try autocheckout
execute_process(
COMMAND "sh" "get_krims.sh"
WORKING_DIRECTORY "${EXTERNAL_DIR}"
RESULT_VARIABLE RES
)
if (NOT RES EQUAL 0)
message(FATAL_ERROR "Getting krims from git failed with error: ${RES}")
endif()
endif()
if (NOT "${krims_DIR}" MATCHES "NOTFOUND"
AND NOT "${krims_DIR}" MATCHES "AUTOCHECKOUT")
set(FIRST_TRY_LOCATION "${krims_DIR}/share/cmake/modules/${MODULE}.cmake")
endif()
if ("${krims_DIR}" STREQUAL "krims_DIR-AUTOCHECKOUT"
OR "$ENV{krims_DIR}" STREQUAL "krims_DIR-AUTOCHECKOUT"
OR AUTOCHECKOUT_FORCED)
autocheckout_krims()
include("${EXTERNAL_DIR}/krims/cmake/modules/${MODULE}.cmake"
set(FIRST_TRY_LOCATION
"${EXTERNAL_DIR}/krims/cmake/modules/${MODULE}.cmake")
endif()
# Try the first try location
if (NOT "${FIRST_TRY_LOCATION}" STREQUAL "")
include("${FIRST_TRY_LOCATION}" OPTIONAL RESULT_VARIABLE RES)
endif()
unset(FIRST_TRY_LOCATION)
if (AUTOCHECKOUT_FORCED AND "${RES}" STREQUAL "NOTFOUND")
# We should have found it now.
message(FATAL_ERROR "Even though autocheckout is forced, we could not \
find the cmake module ${MODULE} in the krims module checked out. \
Check that you have the correct version of krims checked out.")
endif()
# Try the install location
if ("${RES}" STREQUAL "NOTFOUND")
include("${CMAKE_INSTALL_PREFIX}/share/cmake/modules/${MODULE}.cmake"
OPTIONAL RESULT_VARIABLE RES)
endif()
# Try a normal include
if ("${RES}" STREQUAL "NOTFOUND")
# We still could not find it.
include(${MODULE} OPTIONAL RESULT_VARIABLE RES)
endif()
message(FATAL_ERROR "Could not find the ${MODULE} module.
Either provide the installation prefix of the krims library in the environment \
variable krims_DIR or enable autocheckout via '-DAUTOCHECKOUT_MISSING_REPOS=ON'.")
if ("${RES}" STREQUAL "NOTFOUND")
# We still could not find it => autocheckout
if (AUTOCHECKOUT_MISSING_REPOS)
autocheckout_krims()
include("${EXTERNAL_DIR}/krims/cmake/modules/${MODULE}.cmake")
else()
message(FATAL_ERROR "Could not find the ${MODULE} module, \
which should be distributed with krims. You can either provide the installation prefix \
of the krims library in the environment variable 'krims_DIR' or enable autocheckout
via '-DAUTOCHECKOUT_MISSING_REPOS=ON'.")
endif()
endif()
endmacro(include_krims_cmake_module)
View

This file was deleted.

Oops, something went wrong.
@@ -51,10 +51,8 @@ endif()
#############
#-- krims --#
#############
# Find at least version 0.0.0
set(KRIMS_VERSION 0.0.0)
include(cmake/findKrims.cmake)
include_krims_cmake_module(FindPackageAutocheckoutFallback)
find_package_autocheckout_fallback(krims 0.1.0)
foreach (build ${DRB_BUILD_TYPES})
set(LAZYTEN_DEPENDENCIES_${build} ${LAZYTEN_DEPENDENCIES_${build}} ${krims_${build}_TARGET})
endforeach()
@@ -26,6 +26,7 @@ update_file "krims" ".clang-format" || exit 1
update_file "krims" ".clang-tidy" || exit 1
update_file "krims" "cmake/findCatch.cmake" || exit 1
update_file "krims" "cmake/findRapidcheck.cmake" || exit 1
update_file "krims" "cmake/IncludeKrimsCmakeModule.cmake" || exit 1
update_file "krims" "doc/Doxyfile.in" || exit 1
update_file "krims" "external/get.lib.sh" || exit 1
update_file "krims" "external/get_rapidcheck.sh" || exit 1

0 comments on commit d5ee49d

Please sign in to comment.