-
Notifications
You must be signed in to change notification settings - Fork 762
cmake: surface headers in Visual Studio solution #1222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,51 @@ target_compile_features(GSL INTERFACE "cxx_std_14") | |
| # Setup include directory | ||
| add_subdirectory(include) | ||
|
|
||
| target_sources(GSL INTERFACE $<BUILD_INTERFACE:${GSL_SOURCE_DIR}/GSL.natvis>) | ||
| file(GLOB GSL_HEADER_FILES | ||
| RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include" | ||
| "${CMAKE_CURRENT_SOURCE_DIR}/include/gsl/*" | ||
| ) | ||
| list(SORT GSL_HEADER_FILES) | ||
|
|
||
| # Build/install interface lists ensure CMake is happy when exporting headers via | ||
| # INTERFACE sources. Absolute paths would be rejected by newer CMake versions | ||
|
||
| # (discovered while testing with 4.1). | ||
carsonRadtke marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| set(GSL_HEADER_INTERFACE_SOURCES) | ||
| foreach(header ${GSL_HEADER_FILES}) | ||
| list(APPEND GSL_HEADER_INTERFACE_SOURCES | ||
| $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/${header}> | ||
| $<INSTALL_INTERFACE:include/${header}> | ||
| ) | ||
| endforeach() | ||
|
|
||
| target_sources(GSL INTERFACE | ||
| ${GSL_HEADER_INTERFACE_SOURCES} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: According to https://github.com/microsoft/GSL/pull/1112/files#r1190452831 this only affects VS solutions. Let's move it into your new |
||
| $<BUILD_INTERFACE:${GSL_SOURCE_DIR}/GSL.natvis> | ||
| ) | ||
|
|
||
| if (CMAKE_GENERATOR MATCHES "Visual Studio") | ||
carsonRadtke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Visual Studio still needs concrete file paths for solution grouping. | ||
| set(GSL_HEADER_ABSOLUTE_PATHS) | ||
| foreach(header ${GSL_HEADER_FILES}) | ||
| list(APPEND GSL_HEADER_ABSOLUTE_PATHS ${GSL_SOURCE_DIR}/include/${header}) | ||
| endforeach() | ||
| source_group(TREE ${GSL_SOURCE_DIR}/include PREFIX "Header Files" FILES ${GSL_HEADER_ABSOLUTE_PATHS}) | ||
|
||
|
|
||
| set(GSL_SOLUTION_FILES | ||
| ${GSL_SOURCE_DIR}/.clang-format | ||
| ${GSL_SOURCE_DIR}/.gitattributes | ||
| ${GSL_SOURCE_DIR}/.gitignore | ||
| ${GSL_SOURCE_DIR}/CMakeSettings.json | ||
| ${GSL_SOURCE_DIR}/CONTRIBUTING.md | ||
| ${GSL_SOURCE_DIR}/LICENSE | ||
| ${GSL_SOURCE_DIR}/README.md | ||
| ${GSL_SOURCE_DIR}/SECURITY.md | ||
| ${GSL_SOURCE_DIR}/ThirdPartyNotices.txt | ||
| ) | ||
|
|
||
| set_property(DIRECTORY PROPERTY VS_SOLUTION_ITEMS ${GSL_SOLUTION_FILES}) | ||
|
||
| source_group("Solution Items" FILES ${GSL_SOLUTION_FILES}) | ||
| endif() | ||
|
|
||
| if (GSL_TEST) | ||
| enable_testing() | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: According to the docs, the result of
file(GLOB, ...is already sorted.https://cmake.org/cmake/help/latest/command/file.html#filesystem