I'm on MacOS and I'm coding a C++ project using SDL2 containing a src file main.cpp, a spritesheet.png and a .txt file.
They're all in the same "src" directory.
When I compile and run my program from the terminal with g++, it runs smoothly, no issues, the image is rendered and the text file is open and read.
Now, I am new with CMake and I'm just starting to understand the very basic but when I use CMake to create a .app and compile my code:
set_target_properties(myApp PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_FRAMEWORK_IDENTIFIER org.cmake.ExecutableTarget
RESOURCE "${RESOURCE_FILES}")
the image and the .txt files are put into the "Resources" folder and the .exe goes in the MacOS folder.
When I run my .app, the image is displayed but the .txt cannot be opened.
I have tried to use in my CMakeLists.txt the following command which copies my .txt file in the same dir as my final .unix exe file (in the MacOS folder of my .app) rather than putting it in the "Resources" dir:
add_custom_command(TARGET myApp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/lazy.txt $<TARGET_FILE_DIR:myApp>)
But my .txt still does not open when running my .app file.
In my code, the path for the .txt file is "lazy.txt" (as the .txt file is in the same dir as main.cpp)
Could this just be due to the path in the src code or am I missing something else here?