Didn't test it, just ran it through my cleanup software and then tweaked it a bit by hand. Hopefully this should help - at the very least it will be more readable and standardized.

With this, you should just be able to set a MYSQLCONNECTORCPP_ROOT_DIR and have it find the rest properly and automatically, marking as advanced when possible.

Ryan

---

# - 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++
#
# The user may wish to set, in the CMake GUI or otherwise, this variable:
#  MYSQLCONNECTORCPP_ROOT_DIR - path to start searching for the module

set(MYSQLCONNECTORCPP_ROOT_DIR
        "${MYSQLCONNECTORCPP_ROOT_DIR}"
        CACHE
        PATH
        "Where to start looking for this component.")

if(WIN32)
        find_path(MYSQLCONNECTORCPP_INCLUDE_DIR
                NAMES
                mysql_connection.h
                PATHS
                "C:\\Program Files"
                HINTS
                ${MYSQLCONNECTORCPP_ROOT_DIR}
                PATH_SUFFIXES
                include)
                
        find_library(MYSQLCONNECTORCPP_LIBRARY
                NAMES
                mysqlcppconn
                mysqlcppconn-static
                HINTS
                ${MYSQLCONNECTORCPP_ROOT_DIR}
                PATH_SUFFIXES
                lib)
                
else()
        find_path(MYSQLCONNECTORCPP_INCLUDE_DIR
                mysql_connection.h
                HINTS
                ${MYSQLCONNECTORCPP_ROOT_DIR}
                PATH_SUFFIXES
                include)
                
        find_library(MYSQLCONNECTORCPP_LIBRARY
                NAMES
                mysqlcppconn
                mysqlcppconn-static
                HINTS
                ${MYSQLCONNECTORCPP_ROOT_DIR}
                PATH_SUFFIXES
                lib64
                lib)
endif()

mark_as_advanced(MYSQLCONNECTORCPP_INCLUDE_DIR MYSQLCONNECTORCPP_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MysqlConnectorCpp
        DEFAULT_MSG
        MYSQLCONNECTORCPP_INCLUDE_DIR
        MYSQLCONNECTORCPP_LIBRARY)

if(MYSQLCONNECTORCPP_FOUND)
        set(MYSQLCONNECTORCPP_INCLUDE_DIRS "${MYSQLCONNECTORCPP_INCLUDE_DIR}") 
# Add any dependencies here
        set(MYSQLCONNECTORCPP_LIBRARIES "${MYSQLCONNECTORCPP_LIBRARY}") # Add 
any dependencies here
        mark_as_advanced(MYSQLCONNECTORCPP_ROOT_DIR)
endif()





On 05/26/2010 12:11 PM, Torri, Stephen CIV NSWCDD, W15 wrote:
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

--
Ryan Pavlik
HCI Graduate Student
Virtual Reality Applications Center
Iowa State University

[email protected]
http://academic.cleardefinition.com

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to