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 tasks to move the shaders/models/textures to correct executable directory for Visual Studio generator or Ninja Multi-Config generator

…chapters in Visual Studio generator and Ninja Multi-Config generator
…ization by removing dependency on any previous tasks (executable build task or shaders targets). The post-build task will garntee only the copy-if-different of shader/texture/modele files to proper location in case of Visual Studio or Ninja Multi-Config.
@euclid-skyline
Copy link
Author

euclid-skyline commented Jan 30, 2026

This is the same intent of PR#165. But I resolve many issues were in that previous PR. I already closed that PR#165 and all purposes in that PR are here, but they apply on latest state of source code in main branch. Please review and give me your feedback and comment if exist.

Copy link
Contributor

@gpx1000 gpx1000 left a comment

Choose a reason for hiding this comment

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

Hi sorry reviewing took so long the first time. My queue gets quite long and I get unintentionally back logged. I'll try to keep iterating quickly for you.

Thanks for the effort on this. I'll test this across all platforms and ensure it works for Windows, Linux and Android (for the Android chapters). Additionally, we need to think about how this might impact the newly released Game Engine. I don't know if simply adding it as a subproject is the right path forward; but it is certainly a design decision that might work.
The run directory might be a bit confusing to students. I'll post more of a review after I test on all platforms. For now, this is just eyeballing responses. The CMake looks right; so it should work.
Maybe recommend investigating using CPack instead of copying assets over. That might be a more elegant solution and what we use to get the game engine, and the ML tutorial (when that comes) to work with this.


project (VulkanTutorialRoot)
# This is to allow the CMakeLists.txt files in attachments/ to be accessed from root level
# Use command: cmake -S . -B build to configure from root level
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't you just be able to cmake -S attachments -B build from the root level and achieve the same thing?

Copy link
Author

@euclid-skyline euclid-skyline Jan 30, 2026

Choose a reason for hiding this comment

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

Hi gpx1000
Yes, you can do that too. The idea here is to be able to cmake from root and from attachments directory or any decent directory if it is having CMakeLists.txt. But if you select to cmake from root it will be going into massive configuration stage for all projects under the root. But in cmake build stage I think I will go with selecting the target more than cmake all targets for time saving. Anyway, my recommendation will not break anything except just the notes I provided below.
Here is commands from the root directory
cmake -S attachments -B attachments/build/msvc -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"

OR from attachments directory cmake -S . -B build/msvc -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" -DVCPKG_MANIFEST_DIR="../"

Also if you want to use root CMakeLists.txt
cmake -S . -B build/msvc -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"

# Need to be carefull using CMAKE_SOURCE_DIR is points to the root level CMakeLists.txt
# Use CMAKE_CURRENT_SOURCE_DIR to point to the current directory instead
# For Simple Vulkan Engine project please uncomment the following line
# add_subdirectory(attachments/simple_engine) No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm... I didn't test having both projects setup like this. One that builds the main tutorial and the other that builds the engine. I can't think why it wouldn't work. However, the "working directory" for when you "run" the engine or the tutorial might feel a bit odd.
I see below that the idea is to copy the assets to the directory local to the build folder. That does lead me to believe that it would make the tutorial chapters able to be run from the build directory. I don't think we sanitized the code in the tutorial to allow running from any directory; so I think the build process would be:
cmake -S . -B build
make
cd build
./run.exe

I think for the game engine, that pattern might not be pleasant as the map and assets are quite large. We do provide a script to download the project. Maybe a pattern to enable the game engine to work with this is to include the packaging phase of CMake. Thus, this constraint would have a side benefit of demonstrating how to create an install for a non-trivial Vulkan project. That might feel a bit beyond the scope for the game engine so will ask for feedback on if that's a wise idea.
We'll have to think that through for other Tutorials currently in the works.

Copy link
Author

Choose a reason for hiding this comment

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

Honestly, I did not test to cmake the engine from the root directory. But my setup work with main tutorial at the attachments directory smoothly. For time being I do not suggest doing cmake from root directory for engine because I do not know what is there and what it will be break. But the suggestion in comment is valid and could be implanted very easily any time if you be carefully following the suggestion I put in the comment. Meanwhile I'm trying to make live easy for tutorial part.
If I don't answer your comment correctly let me know in comment what is exactly your question.

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