0
votes

I don't know how to explain why, but when I run cmake in a directory it works fine. If I go one level up and in the CMakeLists.txt use Add_SubDirectory then it is broken.

I will put the steps down.

  1. mkdir MyFolder
  2. git clone https://github.com/mariadb-corporation/mariadb-connector-c.git

These steps work to prove that the build works:

  1. cd mariadb-connector-c
  2. mkdir build && cd build
  3. cmake -G Ninja ..
  4. ninja

Ok that worked great. So next trying it one level up:

  1. cd ../.. (Now located in "MyFolder")
  2. Add a CMakeLists.txt with this source.
cmake_minimum_required(VERSION 3.0.0)
project(mariadb VERSION 1.0.0)

add_subdirectory(mariadb-connector-c)
  1. mkdir build & cd build
  2. cmake -G Ninja ..

And now it blows up. Does anyone know why this is the case?

Edit

As requested here is the first error of the log when it is built as a sub project.

Determining if files select.h exist failed with the following output:
Change Dir: /home/questionable/Desktop/Programming/source-mariadb/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/ninja cmTC_c650d && [1/2] Building C object CMakeFiles/cmTC_c650d.dir/HAVE_SELECT_H.c.o
FAILED: CMakeFiles/cmTC_c650d.dir/HAVE_SELECT_H.c.o 
/usr/bin/cc   -Wunused -Wlogical-op -Wno-uninitialized -Wall -Wextra -Wformat-security -Wno-init-self -Wwrite-strings -Wshift-count-overflow -Wdeclaration-after-statement -Wno-undef -Wno-unknown-pragmas -o CMakeFiles/cmTC_c650d.dir/HAVE_SELECT_H.c.o   -c /home/questionable/Desktop/Programming/source-mariadb/build/CMakeFiles/CheckIncludeFiles/HAVE_SELECT_H.c
/home/questionable/Desktop/Programming/source-mariadb/build/CMakeFiles/CheckIncludeFiles/HAVE_SELECT_H.c:2:10: fatal error: select.h: No such file or directory
    2 | #include <select.h>
      |          ^~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.


Source:
/* */
#include <select.h>


int main(void){return 0;}
1
Define "blows up." What errors do you get?Stephen Newell
It's an entire log of errors, pages and pages. The first error is that it can't find <select.h> and the last error is that -lpthread doesn't exist.Questionable
Unless the documentation/README for a CMake project is explicitly specifies that it can be built as a subproject, no one guarantees that it can be built in that manner. Well, it is usually a good assumption, that a particular project could be built as a subproject. But if you want us to debug that usage, you need to be more detailed about your problem. E.g. show the exact error message you got. As usual, if your error log is too lengthy, it is normally sufficient to show only the first error message.Tsyvarev
No, do not show content of CMakeErrorLog.txt file: these error messages are mostly not "real". Show the error message in the CMake output.Tsyvarev
Please post the entire log of errors, all the pages and all the pages. Please also compile with verbose (make VERBOSE=1 or cmake --verbose --build ..) for even more pages of logs of errors and post it all then. You posted parts of CMakeErrorLog that was used for detection of select.h - I do not feel it's even related to the problem, it's just detecting select.h, and sure it should be missing, it's sys/select.h.KamilCuk

1 Answers

1
votes

Errors I get at cmake configure stage from your source are:

CMake Deprecation Warning at mariadb-connector-c/CMakeLists.txt:5 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


CMake Warning (dev) at mariadb-connector-c/CMakeLists.txt:19 (PROJECT):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    PROJECT_VERSION
    PROJECT_VERSION_MAJOR
    PROJECT_VERSION_MINOR
    PROJECT_VERSION_PATCH
This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Error at mariadb-connector-c/cmake/install_plugins.cmake:11 (INSTALL):
  INSTALL TARGETS given no LIBRARY DESTINATION for module target "dialog".
Call Stack (most recent call first):
  mariadb-connector-c/cmake/plugins.cmake:82 (INSTALL_PLUGIN)
  mariadb-connector-c/plugins/auth/CMakeLists.txt:30 (REGISTER_PLUGIN)
  mariadb-connector-c/plugins/CMakeLists.txt:7 (INCLUDE)
  mariadb-connector-c/CMakeLists.txt:392 (INCLUDE)


CMake Error at mariadb-connector-c/cmake/install_plugins.cmake:11 (INSTALL):
  INSTALL TARGETS given no LIBRARY DESTINATION for module target
  "client_ed25519".
Call Stack (most recent call first):
  mariadb-connector-c/cmake/plugins.cmake:82 (INSTALL_PLUGIN)
  mariadb-connector-c/plugins/auth/CMakeLists.txt:54 (REGISTER_PLUGIN)
  mariadb-connector-c/plugins/CMakeLists.txt:7 (INCLUDE)
  mariadb-connector-c/CMakeLists.txt:392 (INCLUDE)


CMake Error at mariadb-connector-c/cmake/install_plugins.cmake:11 (INSTALL):
  INSTALL TARGETS given no LIBRARY DESTINATION for module target
  "caching_sha2_password".
Call Stack (most recent call first):
  mariadb-connector-c/cmake/plugins.cmake:82 (INSTALL_PLUGIN)
  mariadb-connector-c/plugins/auth/CMakeLists.txt:70 (REGISTER_PLUGIN)
  mariadb-connector-c/plugins/CMakeLists.txt:7 (INCLUDE)
  mariadb-connector-c/CMakeLists.txt:392 (INCLUDE)


CMake Error at mariadb-connector-c/cmake/install_plugins.cmake:11 (INSTALL):
  INSTALL TARGETS given no LIBRARY DESTINATION for module target
  "sha256_password".
Call Stack (most recent call first):
  mariadb-connector-c/cmake/plugins.cmake:82 (INSTALL_PLUGIN)
  mariadb-connector-c/plugins/auth/CMakeLists.txt:81 (REGISTER_PLUGIN)
  mariadb-connector-c/plugins/CMakeLists.txt:7 (INCLUDE)
  mariadb-connector-c/CMakeLists.txt:392 (INCLUDE)


CMake Error at mariadb-connector-c/cmake/install_plugins.cmake:11 (INSTALL):
  INSTALL TARGETS given no LIBRARY DESTINATION for module target
  "auth_gssapi_client".
Call Stack (most recent call first):
  mariadb-connector-c/cmake/plugins.cmake:82 (INSTALL_PLUGIN)
  mariadb-connector-c/plugins/auth/CMakeLists.txt:106 (REGISTER_PLUGIN)
  mariadb-connector-c/plugins/CMakeLists.txt:7 (INCLUDE)
  mariadb-connector-c/CMakeLists.txt:392 (INCLUDE)


CMake Error at mariadb-connector-c/cmake/install_plugins.cmake:11 (INSTALL):
  INSTALL TARGETS given no LIBRARY DESTINATION for module target
  "mysql_clear_password".
Call Stack (most recent call first):
  mariadb-connector-c/cmake/plugins.cmake:82 (INSTALL_PLUGIN)
  mariadb-connector-c/plugins/auth/CMakeLists.txt:126 (REGISTER_PLUGIN)
  mariadb-connector-c/plugins/CMakeLists.txt:7 (INCLUDE)
  mariadb-connector-c/CMakeLists.txt:392 (INCLUDE)


CMake Error at mariadb-connector-c/cmake/install_plugins.cmake:11 (INSTALL):
  INSTALL TARGETS given no LIBRARY DESTINATION for module target "remote_io".
Call Stack (most recent call first):
  mariadb-connector-c/cmake/plugins.cmake:82 (INSTALL_PLUGIN)
  mariadb-connector-c/plugins/io/CMakeLists.txt:7 (REGISTER_PLUGIN)
  mariadb-connector-c/plugins/CMakeLists.txt:7 (INCLUDE)
  mariadb-connector-c/CMakeLists.txt:392 (INCLUDE)


-- Configuring incomplete, errors occurred!
See also "/home/kamil/tmp/test/build/CMakeFiles/CMakeOutput.log".
See also "/home/kamil/tmp/test/build/CMakeFiles/CMakeError.log".

Looks like there's a problem in install.cmake. Looks like strangely INSTALL_PLUGINDIR is not set, so DESTINATION argument to install has no parameter... :/ . The following:

cmake_minimum_required(VERSION 3.0.0)
project(mariadb VERSION 1.0.0)

set(INSTALL_PLUGINDIR /some/path)
add_subdirectory(mariadb-connector-c)

allows building the project.