CLion如何将资源文件移动到构建目录 [英] CLion How to move resource files into build directory

查看:380
本文介绍了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 复制到构建目录?

I have a share folder which should be in the same directory as Brendan-C-SFML.exe but CLion builds out-of-source so share is not accessible. Is there a way to set up CLion to copy share to the build directory?

推荐答案

CMakeLists.txt 的末尾添加以下行。

file(COPY share DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

尝试重新加载 cmake 配置,以防复制不起作用。使用 File->重新加载CMake项目以重新加载cmake配置。

Try reloading the cmake config in case the copy doesn't work. Use File -> Reload CMake Project to reload the cmake config.

这篇关于CLion如何将资源文件移动到构建目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆