Visual studio project for header only library

后端 未结 2 1149
生来不讨喜
生来不讨喜 2021-01-03 12:29

I\'m creating a CMake project whose two main files are:

cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
project(CPP_Algorithms_and_Data_Structures)

set( CM         


        
2条回答
  •  青春惊慌失措
    2021-01-03 13:06

    As far as I know there is no normal way to do it. Only a hackish one. So you create a custom target which will force MSVC to show the project in the solution tree. Something like this:

    add_custom_target(${PROJECT_NAME}_ SOURCES ${PROJECT_SOURCES})
    

    Note the underscore in the name: it is there to differentiate it from the name in the add_library command. Of course you need to replace the variables in my example to yours actual ones.

提交回复
热议问题