CMake: Apply source groups using a function

This will add source groups to all projects, not only libraries.
And there is no need anymore to include it in every project file.
This commit is contained in:
Maarten Bent
2022-04-11 23:18:58 +02:00
parent 7683219f90
commit d61c9ee4bf
20 changed files with 22 additions and 51 deletions

View File

@@ -157,6 +157,7 @@ function(wx_set_common_target_properties target_name)
set_target_properties(${target_name} PROPERTIES LINK_FLAGS "-pthread")
endif()
endif()
wx_set_source_groups()
endfunction()
# Set common properties on wx library target

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../source_groups.cmake)
if(wxBUILD_MONOLITHIC)
# Initialize variables for monolithic build
set(wxMONO_SRC_FILES)

View File

@@ -7,6 +7,4 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_add_library(wxadv "${wxSOURCE_DIR}/src/common/dummy.cpp")

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(AUI_FILES AUI_CMN)
if(WXMSW)

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(BASE_FILES BASE_CMN)
wx_append_sources(BASE_FILES BASE_AND_GUI_CMN)

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(CORE_SRC GUI_CMN)
wx_append_sources(CORE_SRC BASE_AND_GUI_CMN)
if(WIN32)

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(GL_FILES OPENGL_CMN)
if(WXMSW)

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(HTML_FILES HTML_CMN)
if(WIN32 OR wxUSE_LIBMSPACK)

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(MEDIA_FILES MEDIA_CMN)
if(WXMSW)

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(NET_FILES NET_CMN)
if(WIN32)

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(PROPGRID_FILES PROPGRID)
wx_add_library(wxpropgrid ${PROPGRID_FILES})

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(QA_FILES QA)
wx_add_library(wxqa ${QA_FILES})

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(RIBBON_FILES RIBBON)
wx_add_library(wxribbon ${RIBBON_FILES})

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(RICHTEXT_FILES RICHTEXT)
wx_add_library(wxrichtext ${RICHTEXT_FILES})

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(STC_FILES STC_CMN)
if(WXOSX_COCOA)

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
function(wx_webview_copy_webview2_loader target)
if(NOT WXMSW OR NOT wxUSE_WEBVIEW_EDGE OR NOT TARGET ${target})
return()

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(XML_FILES XML)
wx_add_library(wxxml IS_BASE ${XML_FILES})
wx_lib_link_libraries(wxxml PRIVATE ${EXPAT_LIBRARIES})

View File

@@ -7,8 +7,6 @@
# Licence: wxWindows licence
#############################################################################
include(../../source_groups.cmake)
wx_append_sources(XRC_FILES XRC)
wx_add_library(wxxrc ${XRC_FILES})

View File

@@ -10,6 +10,7 @@
list(APPEND CMAKE_MODULE_PATH "${wxSOURCE_DIR}/build/cmake/modules")
include(build/cmake/files.cmake) # Files list
include(build/cmake/source_groups.cmake) # source group definitions
include(build/cmake/functions.cmake) # wxWidgets functions
include(build/cmake/toolkit.cmake) # Platform/toolkit settings
include(build/cmake/options.cmake) # User options

View File

@@ -9,20 +9,23 @@
# Define source groups for supported IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
source_group("Common Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/.*\\.h")
source_group("Common Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/common/.*")
source_group("GTK+ Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/gtk/.*")
source_group("MSW Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/msw/.*")
source_group("OSX Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/osx/.*")
source_group("Generic Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/generic/.*")
source_group("wxUniv Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/univ/.*")
source_group("wxHTML Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/html/.*")
source_group("Setup Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/.*/setup.h")
source_group("GTK+ Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/gtk/.*")
source_group("MSW Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/msw/.*")
source_group("OSX Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/osx/.*")
source_group("Generic Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/generic/.*")
source_group("wxUniv Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/univ/.*")
source_group("wxHTML Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/html/.*")
source_group("Setup Headers" FILES ${wxSETUP_HEADER_FILE})
source_group("Resource Files" REGULAR_EXPRESSION "${wxSOURCE_DIR}/[^.]*.(rc|ico|png|icns)$")
function(wx_set_source_groups)
source_group("Common Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/.*\\.h")
source_group("Common Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/common/.*")
source_group("GTK+ Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/gtk/.*")
source_group("MSW Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/msw/.*")
source_group("OSX Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/osx/.*")
source_group("Generic Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/generic/.*")
source_group("wxUniv Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/univ/.*")
source_group("wxHTML Sources" REGULAR_EXPRESSION "${wxSOURCE_DIR}/src/html/.*")
source_group("Setup Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/.*/setup.h")
source_group("GTK+ Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/gtk/.*")
source_group("MSW Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/msw/.*")
source_group("OSX Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/osx/.*")
source_group("Generic Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/generic/.*")
source_group("wxUniv Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/univ/.*")
source_group("wxHTML Headers" REGULAR_EXPRESSION "${wxSOURCE_DIR}/include/wx/html/.*")
source_group("Setup Headers" FILES ${wxSETUP_HEADER_FILE})
source_group("Resource Files" REGULAR_EXPRESSION "${wxSOURCE_DIR}/[^.]*.(rc|ico|png|icns)$")
endfunction()