Part of teh CMakeLists.txt are as followed:
add_library(pslite)
file(GLOB_RECURSE SOURCE "src/*.cc")
target_include_directories(pslite PUBLIC "${PROJECT_SOURCE_DIR}/include/")
target_sources(pslite PRIVATE ${SOURCE})
I am using vs2022 to develop this cmake project. From the cmake syntax above, the source and header files will be added to the pslite
project. vs2022 does indeed recognize source files in the src
directory.
However, when I added a new header file inside the include
folder, vs2022 recognized that header file as miscellaneous and not in pslite's project, which prevented me from accurately locating things like the definition of the code.
Another interesting point is that the header files in the src
directory are recognized, but the new header files are not. Why?
I tried to import the header file directly in CMakeLists.txt, like this:
target_sources(psquic PRIVATE ${SOURCE} "src/test.h")
Although the test.h
header appears in the src
directory of the pslite
library in the cmake project view, it is still a miscellaneous file.