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

Ryan Pavlik rpavlik at iastate.edu
Wed Jun 9 11:33:59 EDT 2010



On 05/27/2010 03:29 PM, Torri, Stephen CIV NSWCDD, W15 wrote:
>> From: Ryan Pavlik [mailto:rpavlik at iastate.edu]
>> Sent: Wed 5/26/2010 5:37 PM
>> To: Torri, Stephen CIV NSWCDD, W15; cmake at cmake.org
>> Subject: Re: [CMake] Help creating a module for detecting mysql-connector-c++
>>
>> No, the "ROOT_DIR" variables are to be set by the user at configure time
>> - let's say you installed something into a weird directory, you'd like
>> to be able to tell it where to find it.  You wouldn't generally set it
>> in your cmakelists.txt, except if you know a relative location (for
>> example, there is no PARTB_ROOT_DIR set, but it's always bundled with
>> PARTA, and you have a PARTA_ROOT_DIR, you might consider setting
>> PARTB_ROOT_DIR to be the value of PARTA_ROOT_DIR)
>>      
> Ryan,
>
> Ok. I see that its now an entry in the cmake-gui. What I filled in the file with the directory where mysql-connector-c++ is installed but I could not figure out why it failed to find it.  The headers are found in "C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include\cppconn" so I changed the find_path for the include to be:
>
>          find_path(MYSQLCONNECTORCPP_INCLUDE_DIR
>                  NAMES
>                  mysql_connection.h
>                  PATHS
>                  "cppconn"
>                  HINTS
>                  ${MYSQLCONNECTORCPP_ROOT_DIR}
>                  PATH_SUFFIXES
>                  include)
>
> Where I think I am getting confused is how this command is expanded. In particular I would like to follow what is doing by running this module in some sort of debug mode. That is print out the paths it looked into to find the target header.
>
> Stephen
>    

If you (and others, in general) use it this way:
#include <mysql_connection.h>
then this is what you want:

         find_path(MYSQLCONNECTORCPP_INCLUDE_DIR
                 NAMES
                 mysql_connection.h
                 PATHS
                 HINTS
                 ${MYSQLCONNECTORCPP_ROOT_DIR}
                 PATH_SUFFIXES
                 include
		include/cppcon)

but if you use it this way:
#include <cppcon/mysql_connection.h>
then you want

find_path(MYSQLCONNECTORCPP_INCLUDE_DIR
                 NAMES
                 cppcon/mysql_connection.h
                 PATHS
                 HINTS
                 ${MYSQLCONNECTORCPP_ROOT_DIR}
                 PATH_SUFFIXES
                 include)


Ryan

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

rpavlik at iastate.edu
http://academic.cleardefinition.com
Internal VRAC/HCI Site: http://tinyurl.com/rpavlik



More information about the CMake mailing list