• <bdo id='E6KTr'></bdo><ul id='E6KTr'></ul>
    <i id='E6KTr'><tr id='E6KTr'><dt id='E6KTr'><q id='E6KTr'><span id='E6KTr'><b id='E6KTr'><form id='E6KTr'><ins id='E6KTr'></ins><ul id='E6KTr'></ul><sub id='E6KTr'></sub></form><legend id='E6KTr'></legend><bdo id='E6KTr'><pre id='E6KTr'><center id='E6KTr'></center></pre></bdo></b><th id='E6KTr'></th></span></q></dt></tr></i><div id='E6KTr'><tfoot id='E6KTr'></tfoot><dl id='E6KTr'><fieldset id='E6KTr'></fieldset></dl></div>

    <small id='E6KTr'></small><noframes id='E6KTr'>

      <tfoot id='E6KTr'></tfoot>
      <legend id='E6KTr'><style id='E6KTr'><dir id='E6KTr'><q id='E6KTr'></q></dir></style></legend>

      1. CMake 找不到源文件 (add_executable)

        时间:2023-09-18
            <bdo id='YGlWm'></bdo><ul id='YGlWm'></ul>

          • <i id='YGlWm'><tr id='YGlWm'><dt id='YGlWm'><q id='YGlWm'><span id='YGlWm'><b id='YGlWm'><form id='YGlWm'><ins id='YGlWm'></ins><ul id='YGlWm'></ul><sub id='YGlWm'></sub></form><legend id='YGlWm'></legend><bdo id='YGlWm'><pre id='YGlWm'><center id='YGlWm'></center></pre></bdo></b><th id='YGlWm'></th></span></q></dt></tr></i><div id='YGlWm'><tfoot id='YGlWm'></tfoot><dl id='YGlWm'><fieldset id='YGlWm'></fieldset></dl></div>
            <legend id='YGlWm'><style id='YGlWm'><dir id='YGlWm'><q id='YGlWm'></q></dir></style></legend>
              <tbody id='YGlWm'></tbody>

              <small id='YGlWm'></small><noframes id='YGlWm'>

                • <tfoot id='YGlWm'></tfoot>

                  本文介绍了CMake 找不到源文件 (add_executable)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我一直在尝试按照此处的供应商教程进行操作:CMake-Tutorial,请查看此处的文档:Cmake-Documentation,并尽可能通过以下来源来教育自己YouTube,但我真的很难为使用 OpenGL 设置环境.在修改了 Glitter 样板以及 open.gl 和 learnopengl.com 上的教程后,我决定了解构建过程太重要了,不能不去研究.

                  I have been trying to follow the vendor's tutorial here: CMake-Tutorial, look over the documentation here: Cmake-Documentation, and educate myself as best as possible with sources on YouTube, but I am really struggling with getting the environment set up for working with OpenGL. Having tinkered with the Glitter boilerplate and the tutorials on open.gl and learnopengl.com, I've decided that understanding the build process is too important not to investigate.

                  在我的调查中,我遇到了 CMake 错误无法找到源文件",其详细信息如下所示.问题似乎是由add_executable"引起的.

                  In my investigation, I have come across the CMake error "cannot find source file" which is shown below in more detail. The problem seems to be arising from "add_executable".

                  这里问了一个类似的问题:CMake - 找不到文件.解决方案包括确保为每个变量正确设置了 ${PROJECT_SOURCE_DIR},我相信我已经做到了.

                  A similar question was asked here: CMake - Cannot find file. The solution involved ensuring that the ${PROJECT_SOURCE_DIR} was set properly for each variable, which I believe I have done.

                  我的文件结构:

                  + infuriating_project
                      + bin // post compile results
                      + src // my humble code
                      + deps // external code
                          +glew
                              + include
                              + src
                          +glfw
                              + include
                              + src
                          +glm
                          +soil
                              + lib
                              + src
                  

                  我的 CMakeLists.txt:

                  My CMakeLists.txt:

                  cmake_minimum_required (VERSION 3.0)
                  
                  
                  # Version Information ---------------------------------------------------------
                  project (openGL-practice)
                  SET (VERSION_MAJOR 1)
                  SET (VERSION_MINOR 0)
                  SET (VERSION_FEATURE 0)
                  SET (VERSION_PATCH 0)
                  SET (VERSION "${VERSION_MAJOR}.${VERSION_MINOR}")
                  SET (VERSION "${VERSION}.${VERSION_FEATURE}.${VERSION_PATCH}")
                  MESSAGE ("Version: ${VERSION}")
                  
                  # Configure Source & Binary Directories ---------------------------------------
                  SET (PROJECT_ROOT "${PROJECT_SOURCE_DIR}")
                  SET (PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/src")
                  SET (PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/bin")
                  MESSAGE ("Source path: ${PROJECT_SOURCE_DIR}")
                  MESSAGE ("Binary path: ${PROJECT_BINARY_DIR}")
                  
                  # Configure Depenency Directories ---------------------------------------------
                  SET (PROJECT_DEPS "${PROJECT_ROOT}/deps")
                  SET (glew_inc "${PROJECT_DEPS}/glew/include/GL/")
                  SET (glew_src "${PROJECT_DEPS}/glew/src/")
                  SET (glfw_inc "${PROJECT_DEPS}/glfw/include/GLFW/")
                  SET (glfw_src "${PROJECT_DEPS}/glfw/src/")
                  SET (glm "${PROJECT_DEPS}/glm/glm/")
                  SET (soil_lib "${PROJECT_DEPS}/lib/")
                  SET (soil_src "${PROJECT_DEPS}/src/")
                  
                  # Include directories ---------------------------------------------------------
                  include_directories("
                      ${PROJECT_SOURCE_DIR}
                      ${PROJECT_BINARY_DIR}
                      ${glew_inc}
                      ${glew_src}
                      ${glfw_inc}
                      ${glfw_src}
                      ${glm}
                      ${soil_lib}
                      ${soil_src}
                      ${PROJECT_ROOT}
                      ")
                  
                  # Add executable --------------------------------------------------------------
                  add_executable(main main.cpp)
                  

                  提供了以下错误:

                  CMake Error at CMakeLists.txt:46 (add_executable):
                    Cannot find source file:
                  
                      main.cpp
                  
                    Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
                    .hxx .in .txx
                  
                  
                  CMake Error: CMake can not determine linker language for target: main
                  CMake Error: Cannot determine link language for target "main".
                  

                  非常感谢任何和所有帮助.

                  Any and all help would be very much appreciated.

                  推荐答案

                  有几点我想提一下.

                  1. include_directories 有助于查找头文件.源文件必须始终具有完整的相对路径.

                  1. include_directories helps for finding header files. Source files must always have a complete relative path.

                  假设你的 main.cpp 在 src 中,正确的语法是

                  Assuming that your main.cpp is within src, the correct syntax is

                  add_executable(main ${PROJECT_SOURCE_DIR}/main.cpp)
                  

                • 包含 ${PROJECT_BINARY_DIR} 没有意义.

                  覆盖像 ${PROJECT_SOURCE_DIR} 这样的 CMake 默认变量不是好的做法.以后你会永远记得你做过这样的事情,对于另一个程序员来说是很意外的.

                  Overwriting CMake default variables like ${PROJECT_SOURCE_DIR} is no good practice. In future you will always remember that you have done such a thing and for another programmer it is quite unexpected.

                  希望有帮助.

                  这篇关于CMake 找不到源文件 (add_executable)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                • 上一篇:如何在 GLUT 上加载 bmp 以将其用作纹理? 下一篇:在 C++/OpenGL 中加载 tga/bmp 文件

                  相关文章

                  最新文章

                    <legend id='CvBu1'><style id='CvBu1'><dir id='CvBu1'><q id='CvBu1'></q></dir></style></legend>
                    <tfoot id='CvBu1'></tfoot>
                  1. <small id='CvBu1'></small><noframes id='CvBu1'>

                        <bdo id='CvBu1'></bdo><ul id='CvBu1'></ul>

                      <i id='CvBu1'><tr id='CvBu1'><dt id='CvBu1'><q id='CvBu1'><span id='CvBu1'><b id='CvBu1'><form id='CvBu1'><ins id='CvBu1'></ins><ul id='CvBu1'></ul><sub id='CvBu1'></sub></form><legend id='CvBu1'></legend><bdo id='CvBu1'><pre id='CvBu1'><center id='CvBu1'></center></pre></bdo></b><th id='CvBu1'></th></span></q></dt></tr></i><div id='CvBu1'><tfoot id='CvBu1'></tfoot><dl id='CvBu1'><fieldset id='CvBu1'></fieldset></dl></div>