diff --git a/CMakeLists.txt b/CMakeLists.txt index 340398a..7a679d1 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,22 +115,25 @@ set_property(TARGET "${CMAKE_PROJECT_NAME}" PROPERTY CXX_STANDARD 17) #======================================================================================== # CHANGE RESOURCES DEFINITION #======================================================================================== -# You will change which line is commented depending -# on if the compiled binary is for development or -# production. -# -# Uncomment the line below when in development, this uses the resources folder -# in the CMake project for the RESOURCES_PATH definition -target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC RESOURCES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/") -# -# Uncomment the line below when in production, this uses a folder in the same working -# directory of the binary called "resources". Effectively RESOURCES_PATH -# becomes ./resources/. You would copy the resources folder of the cmake project -# and ship it will the compiled binary -#target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC RESOURCES_PATH="./resources/") +# By default, when in debug mode. Resources are pulled from the folder in the root of +# the project. This is statically mapped. The value of RESOURCES_PATH become +# /home/user1/Projects/Project. Thats not very usefull for shipping the application as +# the user is unlikely to have your same folder structure. # +# So in release mode, the value of RESOURCES_PATH become ./resources/ so it will use the +# resources folder in the same folder as the executable +target_compile_definitions("${CMAKE_PROJECT_NAME}" PUBLIC + RESOURCES_PATH="$<$:${CMAKE_CURRENT_SOURCE_DIR}/resources/>$<$:./resources/>" +) - +# This copis the resources folder to the build location when in release mode +add_custom_command(TARGET "${CMAKE_PROJECT_NAME}" POST_BUILD + COMMAND $<$:${CMAKE_COMMAND}> + $<$:-E> + $<$:copy_directory> + $<$:"${CMAKE_CURRENT_SOURCE_DIR}/resources"> + $<$:"$/resources"> +) # Add our sources