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

Ryan Pavlik rpavlik at iastate.edu
Wed Jun 9 11:48:58 EDT 2010


So, I made a little typo - you don't probably want to supply the PATHS 
argument at all.  PATH_SUFFIXES are tacked on to the end of every place 
CMake looks, so the number of places searched is (# of cmake default 
places + 1 for hints path) * (# of PATH_SUFFIXES arguments + 1 for no 
suffix)

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


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


If the root dir is set correctly, both of these will find the same file, 
however, the first one will effectively do this in your example:

set(MYSQLCONNECTORCPP_INCLUDE_DIR "C:/Program Files/MySQL/MySQL 
Connector C++ 1.0.5/include/cppconn")

and the second will do
set(MYSQLCONNECTORCPP_INCLUDE_DIR "C:/Program Files/MySQL/MySQL 
Connector C++ 1.0.5/include")

(This is so, when you do 
include_directories(${MYSQLCONNECTORCPP_INCLUDE_DIR}), the correct path 
is added so that for your particular way of accessing the include file 
(specified under NAMES), it works.)

Hopefully this clears things up - the find_path part of the docs online 
might also be helpful.

Ryan

On 06/09/2010 10:36 AM, Torri, Stephen CIV NSWCDD, W15 wrote:
>
>
>    
>> 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)
>>
>>
>>      
> Thanks Ryan. Would the first case work with these two examples?
>
> #include<mysql_connection>
>
> versus another would did:
>
> #include<cppconn/mysqlconn.h>
>
> I guess I am a little held up on what is coming after PATH_SUFFIXES.
>
> Stephen
>    

-- 
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