cmake issue with finding mysql
Hi,
I have not that much experience with cmake, so some help here is welcome.
I've installed sqlpp11 as follows:
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_DATE=ON -DBUILD_POSTGRESQL_CONNECTOR=ON -DBUILD_MYSQL_CONNECTOR=ON ..
make -j$(nproc) && sudo make install
This succesfully installed sqlpp11 on my system.
After that I've tried to add sqlpp11 to my project with:
find_package(Sqlpp11 REQUIRED COMPONENTS MySQL PostgreSQL)
The output I get is:
CMake Warning (dev) at /usr/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:273 (message):
The package name passed to `find_package_handle_standard_args` (MYSQL) does
not match the name of the calling package (MySQL). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
cmake/FindMySQL.cmake:49 (find_package_handle_standard_args)
/usr/share/cmake-3.18/Modules/CMakeFindDependencyMacro.cmake:47 (find_package)
/usr/local/lib/cmake/Sqlpp11/Sqlpp11MySQLConfig.cmake:2 (find_dependency)
/usr/local/lib/cmake/Sqlpp11/Sqlpp11Config.cmake:49 (include)
CMakeLists.txt:39 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMakeLists.txt:39 (find_package):
Found package configuration file:
/usr/local/lib/cmake/Sqlpp11/Sqlpp11Config.cmake
but it set Sqlpp11_FOUND to FALSE so package "Sqlpp11" is considered to be
NOT FOUND. Reason given by package:
Sqlpp11 could not be found because dependency MySQL could not be found.
-- Configuring incomplete, errors occurred!
See also "/home/matthijs/Projects/smclient/build/CMakeFiles/CMakeOutput.log".
See also "/home/matthijs/Projects/smclient/build/CMakeFiles/CMakeError.log".
I am not sure where to look for a solution in this case.
I've also tried with MariaDB as follows:
find_package(Sqlpp11 REQUIRED COMPONENTS MariaDB PostgreSQL)
Output:
CMake Error at /usr/share/cmake-3.18/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
By not providing "FindMariaDB.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "MariaDB", but
CMake did not find one.
Could not find a package configuration file provided by "MariaDB" with any
of the following names:
MariaDBConfig.cmake
mariadb-config.cmake
Add the installation prefix of "MariaDB" to CMAKE_PREFIX_PATH or set
"MariaDB_DIR" to a directory containing one of the above files. If
"MariaDB" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
/usr/local/lib/cmake/Sqlpp11/Sqlpp11MariaDBConfig.cmake:2 (find_dependency)
/usr/local/lib/cmake/Sqlpp11/Sqlpp11Config.cmake:49 (include)
CMakeLists.txt:39 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/matthijs/Projects/smclient/build/CMakeFiles/CMakeOutput.log".
See also "/home/matthijs/Projects/smclient/build/CMakeFiles/CMakeError.log".
Any help is appreciated.
Regards, Matthijs
@Leon0402 Can you help here?
@matthijs I am very much a cmake illiterate myself. Just wanted to call out that there is no need to use cmake to use sqlpp11, especially if you installed the library already.
I will have a look later :) My first guess would be that we forgot to install the findPackage scripts in https://github.com/rbock/sqlpp11/tree/main/cmake or they're not found.
CMake has some integrated for Postgresql (https://cmake.org/cmake/help/v3.23/module/FindPostgreSQL.html) and others. But not for MySQL and not for mariaDB either. So therefore we have our own scripts, which are apparently not found (at least the second error message with MariaDB states that).
Have a look at #434, maybe you can test this @matthijs with the mysql and mariadb connector?
I'll test it tomorrow morning with both connectors.
I am guessing this is fixed. Please open a new issue with any remaining parts otherwise.