Skip to content

Commit 1134a53

Browse files
Use module misc_target
1 parent 40f1b6e commit 1134a53

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

CMakeLists.txt

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
cmake_minimum_required(VERSION 3.23...3.31)
22

33
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
4+
include(misc_target)
45
include(set_cxx_standard)
56
include(target_folder)
67
include(vs_startup_project)
@@ -21,30 +22,21 @@ if(BUILD_TESTING)
2122
add_subdirectory(tests)
2223
endif()
2324

24-
add_custom_target(Miscelleanous)
25-
target_sources(Miscelleanous PRIVATE
26-
".clang-format"
27-
".editorconfig"
28-
".gitignore"
29-
".gitmodules"
30-
".github/workflows/cmake.yml"
25+
misc_target(FILES
3126
"CMakePresets.json"
3227
"ReadMe.md"
33-
"vcpkg.json"
34-
"cmake/set_cxx_standard.cmake"
35-
"cmake/target_folder.cmake"
36-
"cmake/vs_startup_project.cmake")
37-
source_group("CMake Scripts" FILES
28+
misc_group_sources("CMake Scripts" FILES
29+
"cmake/misc_target.cmake"
3830
"cmake/set_cxx_standard.cmake"
3931
"cmake/target_folder.cmake"
4032
"cmake/vs_startup_project.cmake")
41-
source_group("Editing" FILES
33+
misc_group_sources("Editing" FILES
4234
".clang-format"
4335
".editorconfig")
44-
source_group("Git" FILES
36+
misc_group_sources("Git" FILES
4537
".gitignore"
4638
".gitmodules")
47-
source_group("GitHub" FILES
39+
misc_group_sources("GitHub" FILES
4840
".github/workflows/cmake.yml")
49-
source_group("VcPkg" FILES
41+
misc_group_sources("VcPkg" FILES
5042
"vcpkg.json")

cmake/misc_target.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Create a Miscellaneous target to organize files in the IDE
2+
function(misc_target)
3+
cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
4+
add_custom_target(Miscellaneous)
5+
if(ARG_FILES)
6+
target_sources(Miscellaneous PRIVATE ${ARG_FILES})
7+
endif()
8+
endfunction()
9+
10+
# Add files to the Miscellaneous target and group them in the IDE
11+
function(misc_group_sources group)
12+
cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
13+
if(ARG_FILES)
14+
target_sources(Miscellaneous PRIVATE ${ARG_FILES})
15+
source_group("${group}" FILES ${ARG_FILES})
16+
endif()
17+
endfunction()

0 commit comments

Comments
 (0)