Skip to content

Commit 8fce2e7

Browse files
committed
cmake: avoid VS solution items property
1 parent d43635b commit 8fce2e7

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

CMakeLists.txt

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ file(GLOB GSL_HEADER_FILES
2121
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/include"
2222
"${CMAKE_CURRENT_SOURCE_DIR}/include/gsl/*"
2323
)
24-
list(SORT GSL_HEADER_FILES)
2524

2625
# Build/install interface lists ensure CMake is happy when exporting headers via
27-
# INTERFACE sources. Absolute paths would be rejected by newer CMake versions
28-
# (discovered while testing with 4.1).
26+
# INTERFACE sources. Absolute paths would be rejected starting with CMake 4.1.2.
2927
set(GSL_HEADER_INTERFACE_SOURCES)
3028
foreach(header ${GSL_HEADER_FILES})
3129
list(APPEND GSL_HEADER_INTERFACE_SOURCES
@@ -40,14 +38,8 @@ target_sources(GSL INTERFACE
4038
)
4139

4240
if (CMAKE_GENERATOR MATCHES "Visual Studio")
43-
# Visual Studio still needs concrete file paths for solution grouping.
44-
set(GSL_HEADER_ABSOLUTE_PATHS)
45-
foreach(header ${GSL_HEADER_FILES})
46-
list(APPEND GSL_HEADER_ABSOLUTE_PATHS ${GSL_SOURCE_DIR}/include/${header})
47-
endforeach()
48-
source_group(TREE ${GSL_SOURCE_DIR}/include PREFIX "Header Files" FILES ${GSL_HEADER_ABSOLUTE_PATHS})
49-
50-
set(GSL_SOLUTION_FILES
41+
file(GLOB GSL_WORKSPACE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/gsl/*")
42+
list(APPEND GSL_WORKSPACE_FILES
5143
${GSL_SOURCE_DIR}/.clang-format
5244
${GSL_SOURCE_DIR}/.gitattributes
5345
${GSL_SOURCE_DIR}/.gitignore
@@ -59,8 +51,14 @@ if (CMAKE_GENERATOR MATCHES "Visual Studio")
5951
${GSL_SOURCE_DIR}/ThirdPartyNotices.txt
6052
)
6153

62-
set_property(DIRECTORY PROPERTY VS_SOLUTION_ITEMS ${GSL_SOLUTION_FILES})
63-
source_group("Solution Items" FILES ${GSL_SOLUTION_FILES})
54+
target_sources(GSL PRIVATE ${GSL_WORKSPACE_FILES})
55+
56+
set(GSL_HEADER_ABSOLUTE_PATHS)
57+
foreach(header ${GSL_HEADER_FILES})
58+
list(APPEND GSL_HEADER_ABSOLUTE_PATHS ${GSL_SOURCE_DIR}/include/${header})
59+
endforeach()
60+
source_group(TREE ${GSL_SOURCE_DIR}/include PREFIX "Header Files" FILES ${GSL_HEADER_ABSOLUTE_PATHS})
61+
source_group("Solution Items" FILES ${GSL_WORKSPACE_FILES})
6462
endif()
6563

6664
if (GSL_TEST)

0 commit comments

Comments
 (0)