|
| 1 | +# -------------------------------------------------------------------------------------------------------- |
| 2 | +# Copyright (c) 2006-2023, Knut Reinert & Freie Universität Berlin |
| 3 | +# Copyright (c) 2016-2023, Knut Reinert & MPI für molekulare Genetik |
| 4 | +# This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License |
| 5 | +# shipped with this file and also available at: https://github.com/seqan/sharg-parser/blob/main/LICENSE.md |
| 6 | +# -------------------------------------------------------------------------------------------------------- |
| 7 | + |
| 8 | +cmake_minimum_required (VERSION 3.16) |
| 9 | +project (sharg_test_external_project CXX) |
| 10 | + |
| 11 | +include (../sharg-test.cmake) # for SHARG_EXTERNAL_PROJECT_CMAKE_ARGS, SHARG_VERSION |
| 12 | +include (ExternalProject) |
| 13 | + |
| 14 | +set (SHARG_ROOT "${CMAKE_CURRENT_LIST_DIR}/../../") |
| 15 | + |
| 16 | +include (install-sharg.cmake) |
| 17 | + |
| 18 | +option (SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE |
| 19 | + "Enable this option if you want to get a detailed list which paths were considered for find_package(...)" FALSE) |
| 20 | + |
| 21 | +# 1) This tests test/external_project/sharg_submodule_add_subdirectory/CMakeLists.txt |
| 22 | +# That means we use add_subdirectory directly on sharg's top level CMakeLists.txt. |
| 23 | +# This will automatically call find_package and expose our sharg::sharg target. |
| 24 | +# This is expected to work with CMake >= 3.4. |
| 25 | +# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../) |
| 26 | +ExternalProject_Add ( |
| 27 | + sharg_submodule_add_subdirectory |
| 28 | + PREFIX sharg_submodule_add_subdirectory |
| 29 | + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_submodule_add_subdirectory" |
| 30 | + CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} |
| 31 | + "-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}" # |
| 32 | + "-DSHARG_ROOT=${SHARG_ROOT}") |
| 33 | + |
| 34 | +# 2) This tests test/external_project/sharg_submodule_find_package/CMakeLists.txt |
| 35 | +# We have a sharg checkout somewhere and we point CMAKE_PREFIX_PATH to <checkout>/sharg/build_system |
| 36 | +# and then use `find_package` to find `sharg-config.cmake` which exposes our `sharg::sharg` target. |
| 37 | +# This is expected to work with CMake >= 3.4. |
| 38 | +# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../) |
| 39 | +ExternalProject_Add ( |
| 40 | + sharg_submodule_find_package |
| 41 | + PREFIX sharg_submodule_find_package |
| 42 | + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_submodule_find_package" |
| 43 | + CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} "-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}" |
| 44 | + "-DCMAKE_PREFIX_PATH=${SHARG_ROOT}/build_system") |
| 45 | + |
| 46 | +# 3) This tests test/external_project/sharg_installed/CMakeLists.txt |
| 47 | +# This test assumes that sharg was installed by make install (e.g. system-wide). |
| 48 | +# This is the way most upstream packages, like debian, provide our library. |
| 49 | +# This test assumes that `sharg-config.cmake` can be found by cmake in some global paths like /usr/share/cmake/. |
| 50 | +# |
| 51 | +# We simulate this by using our `make package` release, e.g. the one we release under |
| 52 | +# https://github.com/seqan/sharg/releases, and unzipping it to some folder and making |
| 53 | +# that path globally accessible by CMAKE_SYSTEM_PREFIX_PATH. |
| 54 | +# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../) |
| 55 | +ExternalProject_Add ( |
| 56 | + sharg_installed |
| 57 | + PREFIX sharg_installed |
| 58 | + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_installed" |
| 59 | + CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} "-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}" |
| 60 | + "-DCMAKE_SYSTEM_PREFIX_PATH=${SHARG_SYSTEM_PREFIX}") |
| 61 | +add_dependencies (sharg_installed sharg_test_prerequisite) |
| 62 | + |
| 63 | +# 4) This tests test/external_project/sharg_fetch_content_zip/CMakeLists.txt |
| 64 | +# It uses fetch_content (a CMake 3.14 feature) to download our zip-release (e.g. zip, tar.xz) from |
| 65 | +# https://github.com/seqan/sharg/releases. fetch_content will automatically download, verify, extract it. |
| 66 | +# The user only needs to define CMAKE_PREFIX_PATH to be able to find our `sharg-config.cmake`. |
| 67 | +# Note that FetchContent is a CMake >= 3.14 feature. |
| 68 | +# This is expected to work with CMake >= 3.14. |
| 69 | +# (ExternalProject_Add simulates a fresh and separate invocation of cmake ../) |
| 70 | +ExternalProject_Add ( |
| 71 | + sharg_fetch_content_zip |
| 72 | + PREFIX sharg_fetch_content_zip |
| 73 | + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_fetch_content_zip" |
| 74 | + CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} "-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}" |
| 75 | + "-DSHARG_PACKAGE_ZIP_URL=${SHARG_PACKAGE_ZIP_URL}") |
| 76 | +add_dependencies (sharg_fetch_content_zip sharg_test_prerequisite) |
| 77 | + |
| 78 | +# 5) This test is the same as 2) but emulates the settings within the setup tutorial. |
| 79 | +# This test is used as snippet in the setup tutorial. |
| 80 | +ExternalProject_Add ( |
| 81 | + sharg_setup_tutorial |
| 82 | + PREFIX sharg_setup_tutorial |
| 83 | + SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/sharg_setup_tutorial" |
| 84 | + CMAKE_ARGS ${SHARG_EXTERNAL_PROJECT_CMAKE_ARGS} "-DCMAKE_FIND_DEBUG_MODE=${SHARG_EXTERNAL_PROJECT_FIND_DEBUG_MODE}") |
0 commit comments