Improve CMake for IDE Projects (Visual Studio) (#13704)

This commit is contained in:
Joshua T. Fisher
2025-08-14 08:19:14 -07:00
committed by GitHub
parent f934b3e066
commit f053be22be
2 changed files with 484 additions and 107 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,21 @@
add_library(SDL3-collector INTERFACE)
add_library(SDL3_test-collector INTERFACE)
function(sdl_source_group prefix_directory)
set(prefixed_list)
file(TO_CMAKE_PATH ${prefix_directory} normalized_prefix_path)
foreach(file in ${ARGN})
file(TO_CMAKE_PATH ${file} normalized_path)
string(FIND "${normalized_path}" ${normalized_prefix_path} position)
if("${position}" EQUAL 0)
list(APPEND prefixed_list ${file})
endif()
endforeach()
if(prefixed_list)
source_group(TREE ${prefix_directory} FILES ${prefixed_list})
endif()
endfunction()
# Use sdl_glob_sources to add glob sources to SDL3-shared, to SDL3-static, or to both.
function(sdl_glob_sources)
cmake_parse_arguments(ARGS "" "" "SHARED;STATIC" ${ARGN})
@@ -13,6 +28,7 @@ function(sdl_glob_sources)
if(TARGET SDL3-static)
target_sources(SDL3-static PRIVATE ${static_sources} ${both_sources})
endif()
sdl_source_group(${PROJECT_SOURCE_DIR} ${shared_sources} ${shared_sources} ${both_sources})
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SOURCES ${shared_sources} ${static_sources} ${both_sources})
endfunction()
@@ -25,6 +41,7 @@ function(sdl_sources)
if(TARGET SDL3-static)
target_sources(SDL3-static PRIVATE ${ARGS_STATIC} ${ARGS_UNPARSED_ARGUMENTS})
endif()
sdl_source_group(${PROJECT_SOURCE_DIR} ${ARGS_SHARED} ${ARGS_STATIC} ${ARGS_UNPARSED_ARGUMENTS})
set_property(TARGET SDL3-collector APPEND PROPERTY INTERFACE_SOURCES ${ARGS_SHARED} ${ARGS_STATIC} ${ARGS_UNPARSED_ARGUMENTS})
endfunction()