|
| 1 | +# -*- Mode:cmake; Coding:us-ascii-unix; fill-column:158 -*- |
| 2 | +#########################################################################################################################################################.H.S.## |
| 3 | +## |
| 4 | +# @file IncludeMRasterLib.cmake |
| 5 | +# @author Mitch Richling http://www.mitchr.me/ |
| 6 | +# @date 2025-01-27 |
| 7 | +# @brief Include MRaster config.@EOL |
| 8 | +# @std cmake |
| 9 | +# @copyright |
| 10 | +# @parblock |
| 11 | +# Copyright (c) 2025, Mitchell Jay Richling <http://www.mitchr.me/> All rights reserved. |
| 12 | +# |
| 13 | +# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: |
| 14 | +# |
| 15 | +# 1. Redistributions of source code must retain the above copyright notice, this list of conditions, and the following disclaimer. |
| 16 | +# |
| 17 | +# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions, and the following disclaimer in the documentation |
| 18 | +# and/or other materials provided with the distribution. |
| 19 | +# |
| 20 | +# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software |
| 21 | +# without specific prior written permission. |
| 22 | +# |
| 23 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 24 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 25 | +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 26 | +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 27 | +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| 28 | +# DAMAGE. |
| 29 | +# @endparblock |
| 30 | +# @filedetails |
| 31 | +# |
| 32 | +# The MRaster project's CMakeLists.txt file will export a CMake configuration file named MRasterLib.cmake into the build directory. If a project needs |
| 33 | +# to use MRaster, then it may simply include this file into its CMakeLists.txt. |
| 34 | +# |
| 35 | +# I keep dependent repositories I have authored in the same base directory, and I always use a build directory called 'build'. While this makes it super |
| 36 | +# simple for me to pull in include files using a fixed relative path, it also complicates matters for people trying to use my code. This include file |
| 37 | +# contains a bit of code that looks for project dependencies using my preferred conventions, but provides for a bit of simple configuration and produces a |
| 38 | +# far more meaningful error message. |
| 39 | +# |
| 40 | +# The user to specify the absolute path to the MRasterLib.cmake file on the cmake command line with an option like this: |
| 41 | +# |
| 42 | +# -DMRaster_PATH=/full/path/to/the/file/MRasterLib.cmake |
| 43 | +# |
| 44 | +# Note the PATHS argument for find_file can be used to hard code the location of the MRasterLib.cmake file into the CMakeLists.txt file. |
| 45 | +# |
| 46 | +# This code sets some variables: |
| 47 | +# - MRaster_PATH will be set to MRaster_PATH-NOTFOUND if the file is not found. This can be useful if you wish to replace the FATAL_ERROR message |
| 48 | +# with some other action. |
| 49 | +# - MRaster_INCLUDE will be set to the include path for MRaster. Note that MRaster is a header only library; however, it can use LibTIFF for some advanced |
| 50 | +# TIFF file reader functionality -- if you don't need that, then the include path is all you need to use MRaster. |
| 51 | +# |
| 52 | +#########################################################################################################################################################.H.E.## |
| 53 | + |
| 54 | +#--------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 55 | +find_file(MRaster_PATH "MRasterLib.cmake" PATHS "mraster/build" "../mraster/build") |
| 56 | +if(NOT MRaster_PATH STREQUAL "MRaster_PATH-NOTFOUND") |
| 57 | + message(STATUS "Found MRaster: ${MRaster_PATH}") |
| 58 | + include("${MRaster_PATH}") |
| 59 | +else() |
| 60 | + message(FATAL_ERROR " MRaster Search Failed!\n" |
| 61 | + " The MRaster repository must be located in the same directory as this repository,\n" |
| 62 | + " and must be configured with a build directory named 'build' at the root of the \n" |
| 63 | + " MRaster repository. That is to say, do the following in the same directory \n" |
| 64 | + " where you cloned this repository: \n" |
| 65 | + " git clone 'https://github.com/richmit/MRaster.git' \n" |
| 66 | + " cd mraster/build \n" |
| 67 | + " cmake .. \n" |
| 68 | + " cd ../.. \n" |
| 69 | + " Then return to this repository, and try to configure it again.\n") |
| 70 | +endif() |
| 71 | +get_target_property(MRaster_INCLUDE MRaster INTERFACE_INCLUDE_DIRECTORIES) |
0 commit comments