[CMake] Help creating a module for detecting mysql-connector-c++

Torri, Stephen CIV NSWCDD, W15 stephen.torri at navy.mil
Wed May 26 13:11:20 EDT 2010


I am trying to create a connector for finding mysql-connector-c++. This is a C++ library that allows a C++ application or library connect to a MySQL server. Right now it works fine on Linux but fails to locate the mysql-connector-c++ library installed on a XP 64-bit machine. On the Linux system the headers are located in /usr/include and the libraries are in /usr/lib. On the Windows system the location is not as easy to locate since the user can place them pretty much anywhere. At present they are installed in C:\Program Files\MySQL\MySQL Connector C++ 1.0.5. When I configure the project via the CMake-gui on Windows it reports that MysqlConnectorCpp_INCLUDE_DIR and MysqlConnectorCpp_LIBRARIES are NOTFOUND.
 
Here is my module as it stands right now. Am I doing something wrong on the Windows side?
 
Stephen
 
--------------------------------------
 
# - Try to find Mysql-Connector-C++
# Once done, this will define
# 
#   MysqlConnectorCpp_FOUND - system has Mysql-Connector-C++ installed
#   MysqlConnectorCpp_INCLUDE_DIRS - the Mysql-Connector-C++ include directories
#   MysqlConnectorCpp_LIBRARIES - link these to use Mysql-Connector-C++
SET (MysqlConnector_Cpp_FOUND FALSE)
IF (WIN32)
  FIND_PATH(MysqlConnectorCpp_INCLUDE_DIR
        NAMES mysql_connection.h
        PATHS "C:\\Program Files"
        )
  FIND_LIBRARY(MysqlConnectorCpp_LIBRARY mysqlcppconn)
  FIND_LIBRARY(MysqlConnectorCpp_LIBRARY mysqlcppconn-static)
ELSE(WIN32)
  FIND_PATH(MysqlConnectorCpp_INCLUDE_DIR mysql_connection.h
        /opt/include
        /usr/local/include
        /usr/include
  )
  FIND_LIBRARY(MysqlConnectorCpp_LIBRARY
    NAMES mysqlcppconn mysqlcppconn-static
    PATHS /opt/lib
        /usr/local/lib
        /usr/lib
  )
ENDIF(WIN32)
IF(MysqlConnectorCpp_LIBRARY)
  SET(MysqlConnectorCpp_FOUND "YES")
ENDIF(MysqlConnectorCpp_LIBRARY)
~                                          


More information about the CMake mailing list