0

Is the only way to get the headers to show up in the Visual Studio project by including them via add_library? If so, would that duplicate the build files?

Below is a snippet. The project compiles fine because target_include_directories is providing the headers as well as the source, but only the source files show up in Visual Studio. I can see my headers show up as "External Dependencies" but it's annoying to access them that way. Thus, I'm considering just adding them in add_library, but I fear I might be going about this wrong.

add_library (Foo SHARED
    # Headers here
    src/foo.cpp
)

target_include_directories(Foo
    PUBLIC
        $<INSTALL_INTERFACE:include>
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/src
)
Stradigos
  • 814
  • 1
  • 13
  • 29

0 Answers0