|
| 1 | +#------------------------------------------------------------------------------- |
| 2 | +# SuiteSparse/Mongoose/cmake_modules/MongooseConfig.cmake |
| 3 | +#------------------------------------------------------------------------------- |
| 4 | + |
| 5 | +# The following copyright and license applies to just this file only, not to |
| 6 | +# the library itself: |
| 7 | +# MongooseConfig.cmake, Copyright (c) 2023, Timothy A. Davis. All Rights Reserved. |
| 8 | +# SPDX-License-Identifier: BSD-3-clause |
| 9 | + |
| 10 | +#------------------------------------------------------------------------------- |
| 11 | + |
| 12 | +# Finds the Mongoose include file and compiled library. |
| 13 | +# The following targets are defined: |
| 14 | +# mongoose - for the shared library (if available) |
| 15 | +# mongoose_static - for the static library (if available) |
| 16 | + |
| 17 | +# For backward compatibility the following variables are set: |
| 18 | + |
| 19 | +# MONGOOSE_INCLUDE_DIR - where to find Mongoose.hpp |
| 20 | +# MONGOOSE_LIBRARY - dynamic Mongoose library |
| 21 | +# MONGOOSE_STATIC - static Mongoose library |
| 22 | +# MONGOOSE_LIBRARIES - libraries when using Mongoose |
| 23 | +# MONGOOSE_FOUND - true if Mongoose found |
| 24 | + |
| 25 | +# Set ``CMAKE_MODULE_PATH`` to the parent folder where this module file is |
| 26 | +# installed. |
| 27 | + |
| 28 | +#------------------------------------------------------------------------------- |
| 29 | + |
| 30 | +@PACKAGE_INIT@ |
| 31 | + |
| 32 | +set ( MONGOOSE_DATE "@Mongoose_DATE@" ) |
| 33 | +set ( MONGOOSE_VERSION_MAJOR @Mongoose_VERSION_MAJOR@ ) |
| 34 | +set ( MONGOOSE_VERSION_MINOR @Mongoose_VERSION_MINOR@ ) |
| 35 | +set ( MONGOOSE_VERSION_PATCH @Mongoose_VERSION_PATCH@ ) |
| 36 | +set ( MONGOOSE_VERSION "@Mongoose_VERSION_MAJOR@.@Mongoose_VERSION_MINOR@.@Mongoose_VERSION_PATCH@" ) |
| 37 | + |
| 38 | +include ( ${CMAKE_CURRENT_LIST_DIR}/MongooseTargets.cmake ) |
| 39 | + |
| 40 | +# The following is only for backward compatibility with FindMongoose. |
| 41 | + |
| 42 | +set ( _target_shared mongoose ) |
| 43 | +set ( _target_static mongoose_static ) |
| 44 | +set ( _var_prefix "MONGOOSE" ) |
| 45 | + |
| 46 | +get_target_property ( ${_var_prefix}_INCLUDE_DIR ${_target_shared} INTERFACE_INCLUDE_DIRECTORIES ) |
| 47 | +if ( ${_var_prefix}_INCLUDE_DIR ) |
| 48 | + # First item in SuiteSparse targets contains the "main" header directory. |
| 49 | + list ( GET ${_var_prefix}_INCLUDE_DIR 0 ${_var_prefix}_INCLUDE_DIR ) |
| 50 | +endif ( ) |
| 51 | +get_target_property ( ${_var_prefix}_LIBRARY ${_target_shared} IMPORTED_IMPLIB ) |
| 52 | +if ( NOT ${_var_prefix}_LIBRARY ) |
| 53 | + get_target_property ( _library_chk ${_target_shared} IMPORTED_LOCATION ) |
| 54 | + if ( EXISTS ${_library_chk} ) |
| 55 | + set ( ${_var_prefix}_LIBRARY ${_library_chk} ) |
| 56 | + endif ( ) |
| 57 | +endif ( ) |
| 58 | +if ( TARGET ${_target_static} ) |
| 59 | + get_target_property ( ${_var_prefix}_STATIC ${_target_static} IMPORTED_LOCATION ) |
| 60 | +endif ( ) |
| 61 | + |
| 62 | +# Check for most common build types |
| 63 | +set ( _config_types "Debug" "Release" "RelWithDebInfo" "MinSizeRel" ) |
| 64 | + |
| 65 | +get_property ( _isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG ) |
| 66 | +if ( _isMultiConfig ) |
| 67 | + # For multi-configuration generators (e.g., Visual Studio), prefer those |
| 68 | + # configurations. |
| 69 | + list ( PREPEND _config_types ${CMAKE_CONFIGURATION_TYPES} ) |
| 70 | +else ( ) |
| 71 | + # For single-configuration generators, prefer the current configuration. |
| 72 | + list ( PREPEND _config_types ${CMAKE_BUILD_TYPE} ) |
| 73 | +endif ( ) |
| 74 | + |
| 75 | +list ( REMOVE_DUPLICATES _config_types ) |
| 76 | + |
| 77 | +foreach ( _config ${_config_types} ) |
| 78 | + string ( TOUPPER ${_config} _uc_config ) |
| 79 | + if ( NOT ${_var_prefix}_LIBRARY ) |
| 80 | + get_target_property ( _library_chk ${_target_shared} |
| 81 | + IMPORTED_IMPLIB_${_uc_config} ) |
| 82 | + if ( EXISTS ${_library_chk} ) |
| 83 | + set ( ${_var_prefix}_LIBRARY ${_library_chk} ) |
| 84 | + endif ( ) |
| 85 | + endif ( ) |
| 86 | + if ( NOT ${_var_prefix}_LIBRARY ) |
| 87 | + get_target_property ( _library_chk ${_target_shared} |
| 88 | + IMPORTED_LOCATION_${_uc_config} ) |
| 89 | + if ( EXISTS ${_library_chk} ) |
| 90 | + set ( ${_var_prefix}_LIBRARY ${_library_chk} ) |
| 91 | + endif ( ) |
| 92 | + endif ( ) |
| 93 | + if ( TARGET ${_target_static} AND NOT ${_var_prefix}_STATIC ) |
| 94 | + get_target_property ( _library_chk ${_target_static} |
| 95 | + IMPORTED_LOCATION_${_uc_config} ) |
| 96 | + if ( EXISTS ${_library_chk} ) |
| 97 | + set ( ${_var_prefix}_STATIC ${_library_chk} ) |
| 98 | + endif ( ) |
| 99 | + endif ( ) |
| 100 | +endforeach ( ) |
| 101 | + |
| 102 | +set ( MONGOOSE_LIBRARIES ${MONGOOSE_LIBRARY} ) |
| 103 | + |
| 104 | +macro ( suitesparse_check_exist _var _files ) |
| 105 | + # ignore generator expressions |
| 106 | + string ( GENEX_STRIP "${_files}" _files2 ) |
| 107 | + |
| 108 | + foreach ( _file ${_files2} ) |
| 109 | + if ( NOT EXISTS "${_file}" ) |
| 110 | + message ( FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist!" ) |
| 111 | + endif ( ) |
| 112 | + endforeach () |
| 113 | +endmacro ( ) |
| 114 | + |
| 115 | +suitesparse_check_exist ( MONGOOSE_INCLUDE_DIR ${MONGOOSE_INCLUDE_DIR} ) |
| 116 | +suitesparse_check_exist ( MONGOOSE_LIBRARY ${MONGOOSE_LIBRARY} ) |
| 117 | + |
| 118 | +message ( STATUS "Mongoose version: ${MONGOOSE_VERSION}" ) |
| 119 | +message ( STATUS "Mongoose include: ${MONGOOSE_INCLUDE_DIR}" ) |
| 120 | +message ( STATUS "Mongoose library: ${MONGOOSE_LIBRARY}" ) |
| 121 | +message ( STATUS "Mongoose static: ${MONGOOSE_STATIC}" ) |
0 commit comments