Skip to content

Conversation

@euclid-skyline
Copy link

This contribution allows to build from project root directory without switching to attachments folder. Also refactor the shaders target functions in attachments directory CMakeLists.txt to fix MSBuild warning messages (MSB8065/MSB8064). Also provide post-build targets to move the shaders/models/textures to correct executable directory for Visual Studio.

…dd project CMakeLists.txt to root directory to run cmake from root directory.
…MSBuild warning (MSB8065/MSB8064) and add post-build commands to move shaders/models/textures to correct executable directory for Visual Studio
@SaschaWillems
Copy link
Collaborator

Sorry for the late reply. This does look good to, but has some merge conflicts due to recent changes. Can you fix those so we can review this?

@SaschaWillems
Copy link
Collaborator

This fails for me on copying over assets when trying to build on root on Windows:

image

Can you confirm this works for you?

@euclid-skyline
Copy link
Author

Sorry It being long time since I worked on this project. I found out that after I fixed the conflict between my old CMakeLists.txt and the latest Github copy that there an issue in asset location. I correct the location of asset in CMakeList.txt and Now it is working. Please verify it and let me know if still there any further problem.

@euclid-skyline
Copy link
Author

I change the source directory from ${CMAKE_SOURCE_DIR}/attachments/assets/ to ${CMAKE_CURRENT_SOURCE_DIR}/assets/. This will work with cmake sourced from project root directory or from project attachments directory. Now CMakeLists.txt is prefect to work from anywhere.

@SaschaWillems
Copy link
Collaborator

Almost there. Shader compilation fails for me when building outside of the attachments folder.

@euclid-skyline
Copy link
Author

euclid-skyline commented Dec 20, 2025

Outside attachments folder? You meant the root project directory? or build directory inside in root directory (I never tried this from inside build directory)?

For me Outside attachments folder meant the project root directory.
use the following command from the project root directory

cmake --fresh -S . -B your-build-directory -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
cmake --build your-build-directory
OR -S attachments and point -B to anywhere you like (for this to work without issue you need to copy the vcpkg.json to directory where CMakeLists.txt of attachments folder)

@SaschaWillems
Copy link
Collaborator

Build directory inside root. I then open the Visual Studio solution in that build folder, and that's where CMake fails to build shaders.

Removed commands to remove shader, model, and texture directories after copying them to the executable directory. This allows Visual Studio to keep working correctly on subprojects (shader, model and texture) without failures.
@euclid-skyline
Copy link
Author

euclid-skyline commented Dec 21, 2025

The shaders were built by CMake. The problem was after post-build tasks in CMakeLists.txt which they cleaned up and removed the shaders build directory after copying them to executable directory. I removed these clean-up commands since they caused compilation issues when running the solution from inside the Visual Studio and Everything is working now as it is supposed to be. Please try and let me know if you facing further issues.

Copy link
Collaborator

@SaschaWillems SaschaWillems left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Can confirm this works for me now, both from a build folder under root as well as a build folder under attachments. 👍🏻

I can only test on Windows so I'll wait for others to test on different platforms.

@euclid-skyline
Copy link
Author

Okay no problem.
I just let you know I run it with Ninja/GCC and Ninja/LLVM and all working without any issues.

Note: Ninja is in single-configuration generator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants