Brady Dean
Brady Dean

Reputation: 3573

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})

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?

Upvotes: 4

Views: 3280

Answers (1)

Aditya Basu
Aditya Basu

Reputation: 166

Add the following line to the end of your CMakeLists.txt.

file(COPY share DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

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

Upvotes: 7

Related Questions