microsoft / microsoft/ifc

Missing files in Visual Studio solutiun/projects when generated from Cmake

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
76
Forks
19
PR merge metrics
No merged PRs in 30d

Description

If you generate a Visual Studio project using a command like cmake --preset=test-msvc and then open the generated solution in Visual Studio a number of files are missing. This is mostly header files which is reasonable as most build systems like ninja or make don't need to "see" the header files and a #include will find them fine. However if you want to edit them in an IDE it's a pain no having them.

So the PR I will submit does the following

  1. Files like src/ifc-dom/common.hxx are added to the relevant project
  2. Adds the following custom target. This is a target that does nothing in the build. It does however show up in the IDE
add_custom_target(ifc-include SOURCES
    include/ifc/abstract-sgraph.hxx
    include/ifc/assertions.hxx
    include/ifc/basic-types.hxx
    include/ifc/file.hxx
    include/ifc/index-utils.hxx
    include/ifc/operators.hxx
    include/ifc/pathname.hxx
    include/ifc/pp-forms.hxx
    include/ifc/reader.hxx
    include/ifc/source-word.hxx
    include/ifc/tooling.hxx
    include/ifc/underlying.hxx
    include/ifc/util.hxx
    include/ifc/version.hxx
    include/ifc/dom/node.hxx
)
  1. Add the following VS_SOLUTION_ITEMS property. This makes the files show up as solution files in the VS IDE. VS_SOLUTION_ITEMS is a new cmake 4.0 feature. If you use an older cmake or generate for ninja or similar the VS_SOLUTION_ITEMS property is just ignored.
set( SolutionItems
    .clang-format
    .gitignore
    CMakePresets.json
    LICENSE.txt
    README.md
    vcpkg.json)
set_property(DIRECTORY APPEND PROPERTY VS_SOLUTION_ITEMS ${SolutionItems})
source_group("Solution Items" FILES ${SolutionItems})
  1. Stop the files in a project being put into sub folders with names like "Sources" and "Headers". This may be useful if you have a lot of file in a project but is extremely annoying if you don't. I don't think this would have an effect on other generators but there is a guard just in case
# By default we don't want the Visual Studio default "sources" and "headers" folders, the following put's everything directly in the project. 
if (${CMAKE_GENERATOR} MATCHES "^Visual Studio")
    source_group( " "  REGULAR_EXPRESSION .*)
endif()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running cmake --preset=test-msvc and opening the generated solution in Visual Studio to reproduce the missing files and folder layout. Review the CMake configuration that defines the relevant projects, including the ifc-include target and VS_SOLUTION_ITEMS example in the issue. Done means the listed headers and solution items appear in Visual Studio, without unwanted Sources or Headers folders, while other generators remain unaffected.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.