- Is indeed a problem that we’ve been trying to sort out. It came about when I addressed #1505, so that samples build into whatever folder you’re currently in (such as
build/Debug/SampleAppor whatever), as this is the typical place where out-of-source cmake builds place the resulting binary. But yep, no assets can be found there because they live relative to the application directory. So lets discuss how to solve this.
The thing I don’t like about copying the assets folder to the build directory is that it will hinder the ability to update assets during runtime, whether with a filewatcher or just reloading your application. Either a) you’d mistakenly be modifying the assets that live in the sample’s directory, or b) you’d be modifying the assets in the build directory that aren’t versioned and will be overwritten during your next build.
What do people think about sym-linking the assets folder into the runtime output directory?
This isn’t just an issue for cinder’s samples and tests, by the way. I’m seeing the same thing in a personal project setup, which AFAICT is the recommended way to organize a project with many dependencies and executable targets. Basically this is the structure:
[root]
CMakeLists.txt # <- carries global flags and brings in all targets from sub-projects, including libcinder
app/ # main application
-- assets/
-- proj/cmake/CMakeLists.txt
-- src/
test/ # test suite for app's various components
-- assets/
-- proj/cmake/CMakeListst.txt
-- src/
common/ # shared library used by both app and test
-- proj/cmake/CMakeLists.txt
src/ # common source files
cinder/ # where cinder lives, as a dependency of common, test, and app
blocks/ # any cinderblocks live in here
-- OSC
-- Cinder-View/
-- -- assets/
In the layout above, both the app and test targets have separate assets folders, and they live relative to their project folder. So if all build products end up somewhere in [root]/build, they won’t be automatically found.
It’s also a problem if you want to run a target from a sub-project that needs to find its own assets, such as Cinder-View in this case. Its test suite is looking for some button images that live in blocks/Cinder-View/assets/images/, but the build product ends up in the root build dir.