Warning, /sdk/codevis/thirdparty/soci/cmake/modules/FindDB2.cmake is written in an unsupported language. File is not indexed.
0001 ###############################################################################
0002 # CMake module to search for DB2 client library
0003 #
0004 # On success, the macro sets the following variables:
0005 # DB2_FOUND = if the library found
0006 # DB2_LIBRARY = full path to the library
0007 # DB2_LIBRARIES = full path to the library
0008 # DB2_INCLUDE_DIR = where to find the library headers
0009 #
0010 # Copyright (c) 2013 Denis Chapligin
0011 #
0012 # Redistribution and use is allowed according to the terms of the BSD license.
0013 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
0014 #
0015 ###############################################################################
0016
0017 if(UNIX)
0018 set(DB2_INSTALL_PATHS
0019 /opt/ibm/db2/V11.5
0020 /opt/ibm/db2/V10.1
0021 /opt/ibm/db2/V9.7
0022 /opt/ibm/db2/V9.5
0023 /opt/ibm/db2/V9.1
0024 /opt/ibm/clidriver
0025 /opt/clidriver)
0026
0027 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
0028 set(DB2_LIBDIRS "lib32" "lib")
0029 else()
0030 set(DB2_LIBDIRS "lib64" "lib")
0031 endif()
0032
0033 set(DB2_FIND_INCLUDE_PATHS)
0034 set(DB2_FIND_LIB_PATHS)
0035 foreach(db2_install_path ${DB2_INSTALL_PATHS})
0036 if (IS_DIRECTORY ${db2_install_path}/include)
0037 set(DB2_FIND_INCLUDE_PATHS
0038 ${DB2_FIND_INCLUDE_PATHS}
0039 ${db2_install_path}/include)
0040 endif()
0041 foreach(db2_libdir ${DB2_LIBDIRS})
0042 if (IS_DIRECTORY ${db2_install_path}/${db2_libdir})
0043 set(DB2_FIND_LIB_PATHS
0044 ${DB2_FIND_LIB_PATHS}
0045 ${db2_install_path}/${db2_libdir})
0046 endif()
0047 endforeach(db2_libdir)
0048 endforeach(db2_install_path)
0049 elseif(WIN32)
0050 if (CMAKE_CL_64) # 64-bit build, DB2 64-bit installed
0051 set(DB2_FIND_INCLUDE_PATHS $ENV{ProgramW6432}/IBM/SQLLIB/include)
0052 set(DB2_FIND_LIB_PATHS $ENV{ProgramW6432}/IBM/SQLLIB/lib)
0053 else() # 32-bit build, DB2 64-bit or DB2 32-bit installed
0054
0055 if(EXISTS "$ENV{ProgramW6432}/IBM/SQLLIB/lib")
0056 # On 64-bit Windows with DB2 64-bit installed:
0057 # LIB environment points to {DB2}/IBM/SQLLIB/lib with64-bit db2api.lib,
0058 # this flag prevents checking paths in LIB, so Win32 version can be detected
0059 set(DB2_FIND_LIB_NO_LIB NO_SYSTEM_ENVIRONMENT_PATH)
0060
0061 endif()
0062
0063 set(DB2_FIND_INCLUDE_PATHS
0064 $ENV{ProgramW6432}/IBM/SQLLIB/include
0065 $ENV{ProgramFiles}/IBM/SQLLIB/include)
0066 set(DB2_FIND_LIB_PATHS
0067 $ENV{ProgramFiles}/IBM/SQLLIB/lib
0068 $ENV{ProgramFiles}/IBM/SQLLIB/lib/win32
0069 $ENV{ProgramW6432}/IBM/SQLLIB/lib/win32)
0070 endif()
0071 endif()
0072
0073 find_path(DB2_INCLUDE_DIR sqlcli1.h
0074 $ENV{DB2_INCLUDE_DIR}
0075 $ENV{DB2_DIR}/include
0076 $ENV{DB2_HOME}
0077 $ENV{IBM_DB_INCLUDE}
0078 ${DB2_FIND_INCLUDE_PATHS})
0079
0080 find_library(DB2_LIBRARY
0081 NAMES db2 db2api
0082 PATHS
0083 $ENV{DB2LIB}
0084 $ENV{IBM_DB_LIB}
0085 ${DB2_FIND_LIB_PATHS}
0086 ${DB2_FIND_LIB_NO_LIB})
0087
0088 if(DB2_LIBRARY)
0089 get_filename_component(DB2_LIBRARY_DIR ${DB2_LIBRARY} PATH)
0090 endif()
0091
0092 if(DB2_INCLUDE_DIR AND DB2_LIBRARY_DIR)
0093 set(DB2_FOUND TRUE)
0094 endif()
0095
0096 set(DB2_LIBRARIES ${DB2_LIBRARY})
0097
0098 # Handle the QUIETLY and REQUIRED arguments and set DB2_FOUND to TRUE
0099 # if all listed variables are TRUE
0100 include(FindPackageHandleStandardArgs)
0101 find_package_handle_standard_args(DB2
0102 DEFAULT_MSG
0103 DB2_INCLUDE_DIR
0104 DB2_LIBRARIES)
0105
0106 mark_as_advanced(DB2_INCLUDE_DIR DB2_LIBRARIES)