小编use*_*750的帖子

如何在CMake中明确指定树外源?

我查看了这篇文章:使用CMake静态链接到项目之外的库.但是我仍然无法解释这意味着什么:

add_subdirectory(/path/to/the/library/source/directory subproject/grzeslib)
Run Code Online (Sandbox Code Playgroud)

我假设"/ path/to/the/library/source/directory"表示来自硬盘的路径,但我不明白"subproject/grzeslib"的含义.现在我试过了:

include_directories(../path/to/dir)
add_subdirectory (../path/to/dir .) 
Run Code Online (Sandbox Code Playgroud)

但是我得到了一个精心的警告.有一个更好的方法吗?

c++ cmake

12
推荐指数
1
解决办法
2万
查看次数

如何使用CMake链接SDL2?

我使用了https://github.com/brendan-w/collector/tree/master/cmake中的.cmake文件,并将它们放在与我的CMakeLists.txt相同的目录中,然后我使用了代码:

set(CMAKE_MODULE_PATH FindSDL2.cmake FindSDL2_image.cmake)
find_package(SDL2 REQUIRED)
Run Code Online (Sandbox Code Playgroud)

但是我收到了错误:

CMake Error at CMakeLists.txt:26 (find_package):
  By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SDL2", but
  CMake did not find one.

  Could not find a package configuration file provided by "SDL2" with any of
  the following names:

    SDL2Config.cmake
    sdl2-config.cmake

  Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
  "SDL2_DIR" to a directory containing one of the above files.  If "SDL2" …
Run Code Online (Sandbox Code Playgroud)

cmake include dynamic-linking sdl-2

5
推荐指数
1
解决办法
1607
查看次数

标签 统计

cmake ×2

c++ ×1

dynamic-linking ×1

include ×1

sdl-2 ×1