CLion如何将资源文件移动到构建目录中

时间:2015-08-21 15:06:41

标签: cmake clion

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复制到构建目录?

1 个答案:

答案 0 :(得分:6)

将以下行添加到CMakeLists.txt

的末尾
file(COPY share DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

尝试重新加载cmake配置,以防副本无效。使用File -> Reload CMake Project重新加载cmake配置。