Listing header files in Visual Studio C++ project generated by cmake

后端 未结 4 1159
南方客
南方客 2020-12-12 18:44

I\'m building a cmake based build system for our product. The problem is that Visual Studio project, generated by cmake, doesn\'t display header files in solution browser.

4条回答
  •  执念已碎
    2020-12-12 19:30

    Just add the header files along with the source files:

    PROJECT (Test)
    
    ADD_EXECUTABLE(Test test.cpp test.h)
    

    Or using variables:

    PROJECT (Test)
    
    SET(SOURCE
      test.cpp
    )
    
    SET(HEADERS
      test.h
    )
    
    ADD_EXECUTABLE(Test ${SOURCE} ${HEADERS})
    

提交回复
热议问题