Warning, /education/labplot/cmake/FindCantor.cmake is written in an unsupported language. File is not indexed.

0001 #=============================================================================
0002 # Copyright (c) 2019 Harald Sitter <sitter@kde.org>
0003 #
0004 # Redistribution and use in source and binary forms, with or without
0005 # modification, are permitted provided that the following conditions
0006 # are met:
0007 #
0008 # 1. Redistributions of source code must retain the copyright
0009 #    notice, this list of conditions and the following disclaimer.
0010 # 2. Redistributions in binary form must reproduce the copyright
0011 #    notice, this list of conditions and the following disclaimer in the
0012 #    documentation and/or other materials provided with the distribution.
0013 # 3. The name of the author may not be used to endorse or promote products
0014 #    derived from this software without specific prior written permission.
0015 #
0016 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0017 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0018 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0019 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0020 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0021 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0022 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0023 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0024 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0025 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0026 #=============================================================================
0027 
0028 # Try to find via config. If that isn't available fall back to manual lookup.
0029 # Config is vastly preferable because it will also make sure link dependencies
0030 # are found and actually in the target link interface.
0031 find_package(Cantor ${Cantor_FIND_VERSION} ${Cantor_FIND_REQUIRED} CONFIG QUIET)
0032 if(Cantor_FOUND)
0033     return()
0034 endif()
0035 
0036 find_library(Cantor_LIBRARIES cantorlibs)
0037 find_path(Cantor_INCLUDE_DIR cantor/worksheetaccess.h)
0038 
0039 if(EXISTS "${Cantor_INCLUDE_DIR}/cantor/cantorlibs_version.h")
0040     file(READ "${Cantor_INCLUDE_DIR}/cantor/cantorlibs_version.h" Cantorlibs_version_H_CONTENT)
0041 
0042     string(REGEX MATCH "#define CANTOR_VERSION_MAJOR[ ]+[0-9]+" Cantor_VERSION_MAJOR_MATCH ${Cantorlibs_version_H_CONTENT})
0043     string(REGEX MATCH "#define CANTOR_VERSION_MINOR[ ]+[0-9]+" Cantor_VERSION_MINOR_MATCH ${Cantorlibs_version_H_CONTENT})
0044     string(REGEX MATCH "#define CANTOR_VERSION_PATCH[ ]+[0-9]+" Cantor_VERSION_PATCH_MATCH ${Cantorlibs_version_H_CONTENT})
0045 
0046     string(REGEX REPLACE ".*_MAJOR[ ]+(.*)" "\\1" Cantor_VERSION_MAJOR ${Cantor_VERSION_MAJOR_MATCH})
0047     string(REGEX REPLACE ".*_MINOR[ ]+(.*)" "\\1" Cantor_VERSION_MINOR ${Cantor_VERSION_MINOR_MATCH})
0048     string(REGEX REPLACE ".*_PATCH[ ]+(.*)" "\\1"  Cantor_VERSION_PATCH  ${Cantor_VERSION_PATCH_MATCH})
0049 
0050     set(Cantor_VERSION "${Cantor_VERSION_MAJOR}.${Cantor_VERSION_MINOR}.${Cantor_VERSION_PATCH}")
0051 else()
0052     set(Cantor_VERSION "0.0.0")
0053 endif()
0054 
0055 include(FindPackageHandleStandardArgs)
0056 find_package_handle_standard_args(Cantor
0057     FOUND_VAR
0058         Cantor_FOUND
0059     REQUIRED_VARS
0060         Cantor_LIBRARIES
0061         Cantor_INCLUDE_DIR
0062     VERSION_VAR
0063         Cantor_VERSION
0064 )
0065 
0066 if(Cantor_FOUND AND NOT TARGET Cantor::cantorlibs)
0067     add_library(Cantor::cantorlibs UNKNOWN IMPORTED)
0068     set_target_properties(Cantor::cantorlibs PROPERTIES
0069         IMPORTED_LOCATION "${Cantor_LIBRARIES}"
0070         INTERFACE_INCLUDE_DIRECTORIES "${Cantor_INCLUDE_DIR}"
0071     )
0072 endif()
0073 
0074 mark_as_advanced(Cantor_LIBRARIES Cantor_INCLUDE_DIR Cantor_VERSION)
0075 
0076 include(FeatureSummary)
0077