CMakeUserFindMySQL: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
 
No edit summary
Line 1: Line 1:
[[CMake_User_Contributed_Macros|Back]]
[[CMake_User_Contributed_Macros|Back]]
-----
-----
# - Find mysqlclient
# - Find mysqlclient
# Find the native MySQL includes and library
# Find the native MySQL includes and library
#
#
#  MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
#  MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
#  MYSQL_LIBRARIES  - List of libraries when using MySQL.
#  MYSQL_LIBRARIES  - List of libraries when using MySQL.
#  MYSQL_FOUND      - True if MySQL found.
#  MYSQL_FOUND      - True if MySQL found.
 
 
IF (MYSQL_INCLUDE_DIR)
IF (MYSQL_INCLUDE_DIR)
  # Already in cache, be silent
  # Already in cache, be silent
  SET(MYSQL_FIND_QUIETLY TRUE)
  SET(MYSQL_FIND_QUIETLY TRUE)
ENDIF (MYSQL_INCLUDE_DIR)
ENDIF (MYSQL_INCLUDE_DIR)
 
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
  /usr/local/include/mysql
  /usr/local/include/mysql
  /usr/include/mysql
  /usr/include/mysql
)
)
 
SET(MYSQL_NAMES mysqlclient mysqlclient_r)
SET(MYSQL_NAMES mysqlclient mysqlclient_r)
FIND_LIBRARY(MYSQL_LIBRARY
FIND_LIBRARY(MYSQL_LIBRARY
  NAMES ${MYSQL_NAMES}
  NAMES ${MYSQL_NAMES}
  PATHS /usr/lib /usr/local/lib
  PATHS /usr/lib /usr/local/lib
)
)
 
IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
    SET(MYSQL_FOUND TRUE)
  SET(MYSQL_FOUND TRUE)
    SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
    SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
    SET(MYSQL_FOUND FALSE)
  SET(MYSQL_FOUND FALSE)
    SET( MYSQL_LIBRARIES )
  SET( MYSQL_LIBRARIES )
ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
 
IF (MYSQL_FOUND)
IF (MYSQL_FOUND)
   IF (NOT MYSQL_FIND_QUIETLY)
   IF (NOT MYSQL_FIND_QUIETLY)
      MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
    MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
   ENDIF (NOT MYSQL_FIND_QUIETLY)
   ENDIF (NOT MYSQL_FIND_QUIETLY)
ELSE (MYSQL_FOUND)
ELSE (MYSQL_FOUND)
   IF (MYSQL_FIND_REQUIRED)
   IF (MYSQL_FIND_REQUIRED)
      MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
    MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
      MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
    MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
   ENDIF (MYSQL_FIND_REQUIRED)
   ENDIF (MYSQL_FIND_REQUIRED)
ENDIF (MYSQL_FOUND)
ENDIF (MYSQL_FOUND)
 
MARK_AS_ADVANCED(
MARK_AS_ADVANCED(
  MYSQL_LIBRARY
  MYSQL_LIBRARY
  MYSQL_INCLUDE_DIR
  MYSQL_INCLUDE_DIR
  )
  )
-----
-----
[[CMake_User_Contributed_Macros|Back]]
[[CMake_User_Contributed_Macros|Back]]


{{CMake/Template/Footer}}
{{CMake/Template/Footer}}

Revision as of 06:06, 24 February 2007

Back


# - Find mysqlclient
# Find the native MySQL includes and library
#
#  MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
#  MYSQL_LIBRARIES   - List of libraries when using MySQL.
#  MYSQL_FOUND       - True if MySQL found.

IF (MYSQL_INCLUDE_DIR)
  # Already in cache, be silent
  SET(MYSQL_FIND_QUIETLY TRUE)
ENDIF (MYSQL_INCLUDE_DIR)

FIND_PATH(MYSQL_INCLUDE_DIR mysql.h
  /usr/local/include/mysql
  /usr/include/mysql
)

SET(MYSQL_NAMES mysqlclient mysqlclient_r)
FIND_LIBRARY(MYSQL_LIBRARY
  NAMES ${MYSQL_NAMES}
  PATHS /usr/lib /usr/local/lib
)

IF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
   SET(MYSQL_FOUND TRUE)
    SET( MYSQL_LIBRARIES ${MYSQL_LIBRARY} )
ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)
   SET(MYSQL_FOUND FALSE)
   SET( MYSQL_LIBRARIES )
ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIBRARY)

IF (MYSQL_FOUND)
  IF (NOT MYSQL_FIND_QUIETLY)
    MESSAGE(STATUS "Found MySQL: ${MYSQL_LIBRARY}")
  ENDIF (NOT MYSQL_FIND_QUIETLY)
ELSE (MYSQL_FOUND)
  IF (MYSQL_FIND_REQUIRED)
    MESSAGE(STATUS "Looked for MySQL libraries named ${MYSQL_NAMES}.")
    MESSAGE(FATAL_ERROR "Could NOT find MySQL library")
  ENDIF (MYSQL_FIND_REQUIRED)
ENDIF (MYSQL_FOUND)

MARK_AS_ADVANCED(
  MYSQL_LIBRARY
  MYSQL_INCLUDE_DIR
  )

Back



CMake: [Welcome | Site Map]