not on a lot of sleep so maybe this is a simple problem but i have no idea why my include is not working, for context i am using clang, on vs code and am new to using vs as i used to use vs code 2022, i have my root dir, with a src dir, and a headers dir, i am trying to learn cmake, and make use of the target_sources command inside of the cmakelists.txt file but that is not my issues at least it think its not, i am just trying to do a simple include of a header file inside of my headers dir, the names line up and i have tried headers/header.hxx to no avail i just keep getting file not found error
#I am genuinely losing my mind to this
17 messages · Page 1 of 1 (latest)
When your question is answered use !solved or the button below to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
@green tangle
Screenshots!
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
error 'header.hxx' file not found
#include "../headers/header.hxx"
/ for root?
No it's a relative path
What do you have in your CMakeLists.txt?
Did you add headers as an include directory?
just started learning cmake this is the file content ```cmake_minimum_required(VERSION 3.16)
project name and init setup
project(MyFirstCmake)
creates a "target" the target is the what gets complied usign the build system and src files you add
add_executable(MyFirstCmake)
used to later modify and add files to an existing target
target_sources(MyFirstCmake
PRIVATE
src/main.cxx
PUBLIC
FILE_SET Headers
TYPE HEADERS
BASE_DIRS headers
FILES headers/myHeader.hxx)```
Uh, target_include_directories(MyFirstCmake PRIVATE headers) I think
this works but i don't understand why this was not somthing i needed to do on vs 2022 , also new to vscode
the cmake part i did not even get to test yet since i could not figure out why the include was not working
Because in VS the source/header directories you see in a project are not actual directories. They are just groups of files and have nothing to do with actual places where files are stored.
i going to need to read more on vs, it has been a huge pain in the ass to use since, alot learning was on the other platform i will look for a guide or somthing, thanks for the help on this
You can also use cmake in VS just like you do in VSC.
only just started on cmake so hopefully it goes a bit smoother as i learn, it seems like a lot of docs/tutorials just assume you already know what u doing but thanks again 👍