CLion 如何将资源文件移动到构建目录中
CLion How to move resource files into build directory
project(Brendan-C-SFML)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{SFML_ROOT}/cmake/Modules")
find_package(SFML REQUIRED COMPONENTS main system window graphics audio)
add_executable(Brendan-C-SFML brendan-c.cpp)
target_include_directories(Brendan-C-SFML PRIVATE ${SFML_INCLUDE_DIR})
target_link_libraries(Brendan-C-SFML ${SFML_LIBRARIES})
我有一个 share
文件夹,该文件夹应与 Brendan-C-SFML.exe
位于同一目录中,但 CLion 是在源代码外构建的,因此无法访问 share
。有没有办法设置 CLion 将 share
复制到构建目录?
将以下行添加到 CMakeLists.txt
.
的末尾
file(COPY share DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
如果副本不起作用,请尝试重新加载 cmake
配置。使用 File -> Reload CMake Project
重新加载 cmake 配置。
project(Brendan-C-SFML)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "$ENV{SFML_ROOT}/cmake/Modules")
find_package(SFML REQUIRED COMPONENTS main system window graphics audio)
add_executable(Brendan-C-SFML brendan-c.cpp)
target_include_directories(Brendan-C-SFML PRIVATE ${SFML_INCLUDE_DIR})
target_link_libraries(Brendan-C-SFML ${SFML_LIBRARIES})
我有一个 share
文件夹,该文件夹应与 Brendan-C-SFML.exe
位于同一目录中,但 CLion 是在源代码外构建的,因此无法访问 share
。有没有办法设置 CLion 将 share
复制到构建目录?
将以下行添加到 CMakeLists.txt
.
file(COPY share DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
如果副本不起作用,请尝试重新加载 cmake
配置。使用 File -> Reload CMake Project
重新加载 cmake 配置。