[CMake] Linking to MySQL C++ Connector libraries using extra flags, Ubuntu 14.04 LTS, gcc

Peleg Bar-Sapir pelegs at gmail.com
Wed Apr 29 17:56:41 EDT 2015


Hello,

First, I would like to point out that I'm new to CMake, and I'm not a
professional programer by any means - just a Physics research student.
I looked for answers to my issue online, but couldn't find anything
that helped me. I also asked my peers and friends, but unfortunately
none of them could find an answer as well.

I want to use MySQL connector for C++ in a program. Usually I do this
by using the 'mysql' and 'my_global' libraries, and then run gcc with
this added flag: `mysql_config --cflags --libs`.
Typing this command into my console results in:

$mysql_config --cflags --libs
-I/usr/include/mysql -DBIG_JOINS=1  -fno-strict-aliasing    -g -DNDEBUG
-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -ldl

meaning there are some linking flags that must be given so gcc would
compile my code, apart from just "-lmysql" or "-l/usr/include/mysql".

My question is how do I ensure this works also with CMake? I
understand how to use the CMakeLists.txt file to configure additional
external libraries, but none of them require special flags as above,
at least in my basic use of them. Since there's no module for MySQL
connector, I'm a bit lost here.

Could anyone please give me a some advices, or point me to what should be done?


Thanks,

Peleg Bar Sapir


More information about the CMake mailing list