CMake在目录中生成,但在使用add_子目录时不会生成

CMake在目录中生成,但在使用add_子目录时不会生成,cmake,Cmake,我不知道如何解释原因,但当我在目录中运行cmake时,它工作正常。如果我升级一级,在CMakeLists.txt中使用Add_子目录,那么它就被破坏了 我要把台阶放下 mkdir MyFolder git克隆 以下步骤用于证明构建工作正常: cd-ADB-c连接器 mkdir生成和cd生成 cmake-G忍者。。 忍者 好的,效果很好。因此,下一步尝试更高层次: cd../。。现在位于MyFolder中 使用此源添加CMakeLists.txt。 mkdir构建和cd构建 cmake-G忍者。。

我不知道如何解释原因,但当我在目录中运行cmake时,它工作正常。如果我升级一级,在CMakeLists.txt中使用Add_子目录,那么它就被破坏了

我要把台阶放下

mkdir MyFolder git克隆 以下步骤用于证明构建工作正常:

cd-ADB-c连接器 mkdir生成和cd生成 cmake-G忍者。。 忍者 好的,效果很好。因此,下一步尝试更高层次:

cd../。。现在位于MyFolder中 使用此源添加CMakeLists.txt。 mkdir构建和cd构建 cmake-G忍者。。 现在它爆炸了。有人知道为什么会这样吗

编辑 根据要求,这里是日志作为子项目构建时的第一个错误

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

我在cmake配置阶段从您的源代码中得到的错误有:

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

允许生成项目。

定义爆炸。你有什么错误?这是一个完整的错误日志,一页又一页。第一个错误是找不到,最后一个错误是-lpthread不存在。除非CMake项目的文档/自述文件明确指定它可以作为子项目构建,否则没有人保证它可以以这种方式构建。嗯,通常是一个很好的假设,一个特定的项目可以作为一个子项目来构建。但如果您希望我们调试该用法,则需要更详细地说明您的问题。例如,显示您收到的确切错误消息。通常,如果您的错误日志太长,通常只显示第一条错误消息就足够了。不,不要显示CMakeErrorLog.txt文件的内容:这些错误消息大多是不真实的。在CMake输出中显示错误消息。请发布整个错误日志、所有页面和所有页面。还请使用verbose make verbose=1或cmake-verbose-build编译。。查看更多错误日志,然后全部发布。您发布了用于检测select.h的CMakeErrorLog的部分内容-我觉得它甚至与问题无关,它只是检测select.h,当然它应该缺失,它是sys/select.h。
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".
cmake_minimum_required(VERSION 3.0.0)
project(mariadb VERSION 1.0.0)

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