Warning, /sdk/codevis/thirdparty/soci/cmake/modules/FindSoci.cmake is written in an unsupported language. File is not indexed.

0001 ###############################################################################
0002 # CMake module to search for SOCI library
0003 #
0004 # This module defines:
0005 #  Soci_INCLUDE_DIRS        = include dirs to be used when using the soci library
0006 #  Soci_LIBRARY             = full path to the soci library
0007 #  Soci_VERSION             = the soci version found
0008 #  Soci_FOUND               = true if soci was found
0009 #
0010 # This module respects:
0011 #  LIB_SUFFIX         = (64|32|"") Specifies the suffix for the lib directory
0012 #
0013 # For each component you specify in find_package(), the following variables are set.
0014 #
0015 #  Soci_${COMPONENT}_PLUGIN = full path to the soci plugin (not set for the "core" component)
0016 #  Soci_${COMPONENT}_FOUND
0017 #
0018 # This module provides the following imported targets, if found:
0019 #
0020 #  Soci::core               = target for the core library and include directories
0021 #  Soci::${COMPONENT}       = target for each plugin
0022 #
0023 # Redistribution and use is allowed according to the terms of the BSD license.
0024 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
0025 #
0026 ###############################################################################
0027 #
0028 ### Global Configuration Section
0029 #
0030 set(_SOCI_ALL_PLUGINS    mysql odbc postgresql sqlite3)
0031 set(_SOCI_REQUIRED_VARS  Soci_INCLUDE_DIR Soci_LIBRARY)
0032 
0033 #
0034 ### FIRST STEP: Find the soci headers.
0035 #
0036 find_path(
0037     Soci_INCLUDE_DIR soci.h
0038     HINTS "/usr/local"
0039     PATH_SUFFIXES "" "soci"
0040     DOC "Soci (http://soci.sourceforge.net) include directory")
0041 mark_as_advanced(Soci_INCLUDE_DIR)
0042 
0043 set(Soci_INCLUDE_DIRS ${Soci_INCLUDE_DIR} CACHE STRING "")
0044 
0045 #
0046 ### SECOND STEP: Find the soci core library. Respect LIB_SUFFIX
0047 #
0048 find_library(
0049     Soci_LIBRARY
0050     NAMES soci_core
0051     HINTS ${Soci_INCLUDE_DIR}/..
0052     PATH_SUFFIXES lib${LIB_SUFFIX})
0053 mark_as_advanced(Soci_LIBRARY)
0054 
0055 get_filename_component(Soci_LIBRARY_DIR ${Soci_LIBRARY} PATH)
0056 mark_as_advanced(Soci_LIBRARY_DIR)
0057 
0058 #
0059 ### THIRD STEP: Find all installed plugins if the library was found
0060 #
0061 if(Soci_INCLUDE_DIR AND Soci_LIBRARY)
0062     set(Soci_core_FOUND TRUE CACHE BOOL "")
0063 
0064     add_library(Soci::core UNKNOWN IMPORTED)
0065     set_target_properties(
0066         Soci::core
0067         PROPERTIES IMPORTED_LOCATION "${Soci_LIBRARY}"
0068         INTERFACE_INCLUDE_DIRECTORIES "${Soci_INCLUDE_DIR}"
0069     )
0070 
0071     #
0072     ### FOURTH STEP: Obtain SOCI version
0073     #
0074     set(Soci_VERSION_FILE "${Soci_INCLUDE_DIR}/version.h")
0075     if(EXISTS "${Soci_VERSION_FILE}")
0076         file(READ "${Soci_VERSION_FILE}" VERSION_CONTENT)
0077         string(REGEX MATCH "#define[ \t]*SOCI_VERSION[ \t]*[0-9]+" VERSION_MATCH "${VERSION_CONTENT}")
0078         string(REGEX REPLACE "#define[ \t]*SOCI_VERSION[ \t]*" "" VERSION_MATCH "${VERSION_MATCH}")
0079 
0080         if(NOT VERSION_MATCH)
0081             message(WARNING "Failed to extract SOCI version")
0082         else()
0083             math(EXPR MAJOR "${VERSION_MATCH} / 100000" OUTPUT_FORMAT DECIMAL)
0084             math(EXPR MINOR "${VERSION_MATCH} / 100 % 1000" OUTPUT_FORMAT DECIMAL)
0085             math(EXPR PATCH "${VERSION_MATCH} % 100" OUTPUT_FORMAT DECIMAL)
0086 
0087             set(Soci_VERSION "${MAJOR}.${MINOR}.${PATCH}" CACHE STRING "")
0088         endif()
0089     else()
0090         message(WARNING "Unable to check SOCI version")
0091     endif()
0092 
0093     foreach(plugin IN LISTS _SOCI_ALL_PLUGINS)
0094 
0095         find_library(
0096             Soci_${plugin}_PLUGIN
0097             NAMES soci_${plugin}
0098             HINTS ${Soci_INCLUDE_DIR}/..
0099             PATH_SUFFIXES lib${LIB_SUFFIX})
0100         mark_as_advanced(Soci_${plugin}_PLUGIN)
0101 
0102         if(Soci_${plugin}_PLUGIN)
0103             set(Soci_${plugin}_FOUND TRUE CACHE BOOL "")
0104             add_library(Soci::${plugin} UNKNOWN IMPORTED)
0105             set_target_properties(
0106                 Soci::${plugin}
0107                 PROPERTIES IMPORTED_LOCATION "${Soci_${plugin}_PLUGIN}"
0108             )
0109             target_link_libraries(Soci::${plugin} INTERFACE Soci::core)
0110         else()
0111             set(Soci_${plugin}_FOUND FALSE CACHE BOOL "")
0112         endif()
0113 
0114     endforeach()
0115 endif()
0116 
0117 #
0118 ### ADHERE TO STANDARDS
0119 #
0120 include(FindPackageHandleStandardArgs)
0121 find_package_handle_standard_args(Soci
0122     REQUIRED_VARS ${_SOCI_REQUIRED_VARS}
0123     VERSION_VAR Soci_VERSION
0124     HANDLE_COMPONENTS
0125 )
0126 
0127 # For compatibility with previous versions of this script
0128 # DO NOT USE THESE VARIABLES IN NEW PROJECTS!
0129 set(SOCI_FOUND ${Soci_FOUND})
0130 set(SOCI_INCLUDE_DIRS ${Soci_INCLUDE_DIRS})
0131 set(SOCI_LIBRARY ${Soci_LIBRARY})
0132 set(SOCI_VERSION ${Soci_VERSION})
0133 set(SOCI_mysql_FOUND ${Soci_mysql_FOUND})
0134 set(SOCI_odbc_FOUND ${Soci_odbc_FOUND})
0135 set(SOCI_postgresql_FOUND ${Soci_postgresql_PLUGIN})
0136 set(SOCI_sqlite3_FOUND ${Soci_sqlite3_PLUGIN})
0137 set(SOCI_mysql_PLUGIN ${Soci_mysql_PLUGIN})
0138 set(SOCI_odbc_PLUGIN ${Soci_odbc_PLUGIN})
0139 set(SOCI_postgresql_PLUGIN ${Soci_postgresql_PLUGIN})
0140 set(SOCI_sqlite3_PLUGIN ${Soci_sqlite3_PLUGIN})