#Is this what I'm supposed to do on the CMake part of "Development Environment" page of Vulkan docs?

136 messages · Page 1 of 1 (latest)

neat zodiac
#

So I have this file structure. It's the workspace I was told to clone in the documentation, then I created my project's folder called "Result3D", inside I created a CMake folder and inside I moved the FindVulkan.cmake file from attachments/CMake/. Then, I created a CMakeLists.txt file inside my project folder, and pasted this code inside:

find_package (Vulkan REQUIRED)

# set up Vulkan C++ module (enabled when ENABLE_CPP20_MODULE=ON)
add_library(VulkanCppModule)
add_library(Vulkan::cppm ALIAS VulkanCppModule)

target_compile_definitions(VulkanCppModule PUBLIC
        VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1
        VULKAN_HPP_NO_STRUCT_CONSTRUCTORS=1
)

target_include_directories(VulkanCppModule PRIVATE "${Vulkan_INCLUDE_DIR}")

target_link_libraries(VulkanCppModule PUBLIC Vulkan::Vulkan)

set_target_properties(VulkanCppModule PROPERTIES CXX_STANDARD 20)

target_sources(VulkanCppModule
        PUBLIC
        FILE_SET cxx_modules TYPE CXX_MODULES
        BASE_DIRS "${Vulkan_INCLUDE_DIR}"
        FILES "${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm"
)
#

I'm asking this, because the CMake part in the docs are pretty much chinese for me as I never worked with CMake

lilac fractal
#

the cmake part is copy pasta, anything else and you are on your own

neat zodiac
#

so

#

is this correct or?

lilac fractal
neat zodiac
lilac fractal
#

if you want your own project structure then you delete everything after

function (add_shaders_target TARGET)

then you write your own target_sources and target_link_libraries

neat zodiac
#

okay so this is what it should be

#

as far as I understand

neat zodiac
#

I didn't create my own project directory I know I just don't wanna complicate anything for now

lilac fractal
#

yeah easiest is to follow exactly then delete all the add_chapter function calls at the bottom except the one you are on

#

it will then look for a file named ${CHAPTER_NAME}.cpp

neat zodiac
lilac fractal
#

cuz you are supposed to clone the repo, if you want a blank project then you need to delete them or it'll try to compile files that dont exist

neat zodiac
#

okay so I'll just delete all chapter calls

#

and the add_chapter function itself right?

neat zodiac
#

Because I already struggle with setting this shi up and I'm afraid of creating even more complications yk

lilac fractal
neat zodiac
#

oooh okay

#

and now

#

after I did this

#

do I just move the CMakeLists to my project folder?

#

and that's all? I run cmake -B build?

lilac fractal
#

you have nothing to build

neat zodiac
lilac fractal
#

i mean that's all you can do right now

#

you can't build an empty project

neat zodiac
#

ooooooh

neat zodiac
#

wait

#

why do they even say to clone the repo

#

and now just explain the creation of a blank project

#

anyways

#

thanks I can finally continue now

lilac fractal
neat zodiac
#

okay I see

neat zodiac
#

but where is that file?

#

there's no main.cpp

lilac fractal
#

then there's nothing to delete so ignore it

neat zodiac
neat zodiac
#

but

#

I have this error with glfw now..

lilac fractal
#

I'm going to consider that a separate issue and I'm not going to be here to walk you through the entire tutorial so I'm leaving it for somoene to chip in

neat zodiac
#

okay I'll leave it in setup for someone, thanks for your help

silent pier
#

Can you post the include paths of your project (from the IDEs project page)?

neat zodiac
silent pier
#

Well, that seems to miss some stuff. glfw is not part of the SDK, hence why the include is not working. Where did you install GLFW3?

neat zodiac
#

through vcpkg, I thought if I'm using a package manager I don't need to bother about include paths

silent pier
#

That's correct. So GLFW3 is instlled via vcpkg?

neat zodiac
#

yes

silent pier
#

Can you check if there is a GLFW folder in "YOUR VCPKG DIRECTORY\installed\platform (e.g. -windows)}include"?

neat zodiac
silent pier
#

I tried to make it work out of the box if you have the Vulkan SDK installed

neat zodiac
#

I'll stick up with this one

#

don't wanna change routes

#

so

#

I did this

#

all this point

#

and now I add the packages to vcpkg config?

#

Okay so here is my project structure and the vcpkg.json file

silent pier
#

I don't think you need to re-add

#

The env variable is there so VSCode can find your vcpkg packages.

neat zodiac
#

oh yeah right, so basically it already takes the packages from vcpkg directory and I don't need them specified in the vcpkg.json file. Do I clear it then?

#

and also what do I do next?

silent pier
#

I don't think you need to clea them.

#

With that setup, the glfw3 include should work

neat zodiac
#

well, not really apparently

#

and yes the vulkan_raii does this too

#

for some reason only now

silent pier
#

Did you restart VSCode?

#

Might be required for it to pick up changes to env variables

neat zodiac
#

that was extremely obvious Idk why I didn't do it

#

I think it's different now

#

before it just said that there's no such library

#

I think

silent pier
#

If not, try reinstalling the glfw vcpkg package

#

If none of that works, you can download glfw3 instead and have the include/library path point to that instead

neat zodiac
#

I mean

#

my problem right now, is VSCode not accessing libraries correctly right?

silent pier
#

Yes, I did post the wrong link, sry.

neat zodiac
#

oh that makes sense

silent pier
#

Can you open a terminal in VSCode and output the value of the VCPKG_ROOT env variable?

neat zodiac
#

wait, how?..

#

what's the command

silent pier
#

Get-Item Env:Vulkan_SDK

#

If you're using Windows Terminal (not CMD)

neat zodiac
#

Oh wait!!! It's pointing to another vcpkg but not the one I installed with all packages

silent pier
#

Do you also have the non-Code Visual Studio installed?

neat zodiac
#

yees

silent pier
#

If so, that comes with it's own variant of vcpkg

#

Then you're better off using that Visual Studio instead of Code. Makes things easier.

#

With all the issues surrounding vcpkg we'll probably remove it from the tutorial

#

I don't like it myself, as it has caused me all sorts of issues too

neat zodiac
#

considering that visual studio is scary

#

I mean there's so much more in comparison with vscode

silent pier
#

Yes, it's easier to do C/C++ in the "big" Visual Studio

#

And no, it's not that much different

neat zodiac
#

so. Do I just open Vulkan-Tutorial folder in it?

silent pier
#

depends on what you want to do? Do you wanna start from scratch?

neat zodiac
#

and, tf is solution supposed to be. Is it like their fancy term to say "project"?

silent pier
#

A solution can contain multiple projects

neat zodiac
silent pier
#

If you run the CMake for the tutorial, CMake will generate a solution to use with Visual Studio

#

If you want to start from scratch, create a new project and select the C++ template

neat zodiac
#

and then?

silent pier
#

You start writing code.

neat zodiac
#

yes but do I need to redo ALL of the setup tutorial?

silent pier
#

Best is to start with the CMakeLists.txt from the tutorial. That does all of the project setup for you.

neat zodiac
#

Also, my libraries are installed on the other vcpkg so that probably means I have to move the packages

neat zodiac
silent pier
#

No, you do the generation step first

#

Best download CMake's official GUI

neat zodiac
#

I have to enter the source code of the tutorial?

silent pier
#

select the CMakeLists.txt

neat zodiac
#

now generate?

silent pier
#

Yes, or read the help for cmake-gui. I do love helping with Vulkan things, but tooling is out of scope (as I do all of this in my spare time).

neat zodiac
#

CMake Error: The source "C:/Users/samir/Bureau/Vulkan/Vulkan-Tutorial/attachments/CMakeLists.txt" does not match the source "C:/Users/samir/Bureau/Vulkan/Vulkan-Tutorial/Result3D/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.

I get this after changing the source for some reason. So at first it was wrong I think, I got an error and I realised that it might be because I chosed a cmakelists file inside my project folder, but there was nothing else like the other cmake files it needs so I then chosed the cmakelists file that was in the attachments folder and now it says that they don't match

#

but I changed them? Why is he still about the old source path

silent pier
#

CMake does cache things. Delete the cache (somewhere under files afair)

neat zodiac
silent pier
#

Too bad. I prob. can't help any further. @nimble marten might be able to help.