From d61c9ee4bf36669ed91dbbc07a99d4995cb9d59b Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Mon, 11 Apr 2022 23:18:58 +0200 Subject: [PATCH] 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. --- build/cmake/functions.cmake | 1 + build/cmake/lib/CMakeLists.txt | 2 -- build/cmake/lib/adv/CMakeLists.txt | 2 -- build/cmake/lib/aui/CMakeLists.txt | 2 -- build/cmake/lib/base/CMakeLists.txt | 2 -- build/cmake/lib/core/CMakeLists.txt | 2 -- build/cmake/lib/gl/CMakeLists.txt | 2 -- build/cmake/lib/html/CMakeLists.txt | 2 -- build/cmake/lib/media/CMakeLists.txt | 2 -- build/cmake/lib/net/CMakeLists.txt | 2 -- build/cmake/lib/propgrid/CMakeLists.txt | 2 -- build/cmake/lib/qa/CMakeLists.txt | 2 -- build/cmake/lib/ribbon/CMakeLists.txt | 2 -- build/cmake/lib/richtext/CMakeLists.txt | 2 -- build/cmake/lib/stc/CMakeLists.txt | 2 -- build/cmake/lib/webview/CMakeLists.txt | 2 -- build/cmake/lib/xml/CMakeLists.txt | 2 -- build/cmake/lib/xrc/CMakeLists.txt | 2 -- build/cmake/main.cmake | 1 + build/cmake/source_groups.cmake | 37 +++++++++++++------------ 20 files changed, 22 insertions(+), 51 deletions(-) diff --git a/build/cmake/functions.cmake b/build/cmake/functions.cmake index 9b493593ad..f0b680f5c3 100644 --- a/build/cmake/functions.cmake +++ b/build/cmake/functions.cmake @@ -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 diff --git a/build/cmake/lib/CMakeLists.txt b/build/cmake/lib/CMakeLists.txt index 41471190fe..0f876fb9d1 100644 --- a/build/cmake/lib/CMakeLists.txt +++ b/build/cmake/lib/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../source_groups.cmake) - if(wxBUILD_MONOLITHIC) # Initialize variables for monolithic build set(wxMONO_SRC_FILES) diff --git a/build/cmake/lib/adv/CMakeLists.txt b/build/cmake/lib/adv/CMakeLists.txt index c00e69abb5..eca93d9cb6 100644 --- a/build/cmake/lib/adv/CMakeLists.txt +++ b/build/cmake/lib/adv/CMakeLists.txt @@ -7,6 +7,4 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_add_library(wxadv "${wxSOURCE_DIR}/src/common/dummy.cpp") diff --git a/build/cmake/lib/aui/CMakeLists.txt b/build/cmake/lib/aui/CMakeLists.txt index f24b674bc7..10828136cd 100644 --- a/build/cmake/lib/aui/CMakeLists.txt +++ b/build/cmake/lib/aui/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(AUI_FILES AUI_CMN) if(WXMSW) diff --git a/build/cmake/lib/base/CMakeLists.txt b/build/cmake/lib/base/CMakeLists.txt index dc512f23e2..cfa538fcb8 100644 --- a/build/cmake/lib/base/CMakeLists.txt +++ b/build/cmake/lib/base/CMakeLists.txt @@ -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) diff --git a/build/cmake/lib/core/CMakeLists.txt b/build/cmake/lib/core/CMakeLists.txt index ad456924e7..acdf31a1b3 100644 --- a/build/cmake/lib/core/CMakeLists.txt +++ b/build/cmake/lib/core/CMakeLists.txt @@ -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) diff --git a/build/cmake/lib/gl/CMakeLists.txt b/build/cmake/lib/gl/CMakeLists.txt index 550a37c53d..dc49b18345 100644 --- a/build/cmake/lib/gl/CMakeLists.txt +++ b/build/cmake/lib/gl/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(GL_FILES OPENGL_CMN) if(WXMSW) diff --git a/build/cmake/lib/html/CMakeLists.txt b/build/cmake/lib/html/CMakeLists.txt index d364d891c7..3fd0ebd041 100644 --- a/build/cmake/lib/html/CMakeLists.txt +++ b/build/cmake/lib/html/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(HTML_FILES HTML_CMN) if(WIN32 OR wxUSE_LIBMSPACK) diff --git a/build/cmake/lib/media/CMakeLists.txt b/build/cmake/lib/media/CMakeLists.txt index fd28b06dbc..0c5e59184a 100644 --- a/build/cmake/lib/media/CMakeLists.txt +++ b/build/cmake/lib/media/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(MEDIA_FILES MEDIA_CMN) if(WXMSW) diff --git a/build/cmake/lib/net/CMakeLists.txt b/build/cmake/lib/net/CMakeLists.txt index 3043e369da..169c46b8ad 100644 --- a/build/cmake/lib/net/CMakeLists.txt +++ b/build/cmake/lib/net/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(NET_FILES NET_CMN) if(WIN32) diff --git a/build/cmake/lib/propgrid/CMakeLists.txt b/build/cmake/lib/propgrid/CMakeLists.txt index 95cb8f1e58..71f2690d6b 100644 --- a/build/cmake/lib/propgrid/CMakeLists.txt +++ b/build/cmake/lib/propgrid/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(PROPGRID_FILES PROPGRID) wx_add_library(wxpropgrid ${PROPGRID_FILES}) diff --git a/build/cmake/lib/qa/CMakeLists.txt b/build/cmake/lib/qa/CMakeLists.txt index 2d33f35962..1efa85e255 100644 --- a/build/cmake/lib/qa/CMakeLists.txt +++ b/build/cmake/lib/qa/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(QA_FILES QA) wx_add_library(wxqa ${QA_FILES}) diff --git a/build/cmake/lib/ribbon/CMakeLists.txt b/build/cmake/lib/ribbon/CMakeLists.txt index 2d07d3f73a..a35e551614 100644 --- a/build/cmake/lib/ribbon/CMakeLists.txt +++ b/build/cmake/lib/ribbon/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(RIBBON_FILES RIBBON) wx_add_library(wxribbon ${RIBBON_FILES}) diff --git a/build/cmake/lib/richtext/CMakeLists.txt b/build/cmake/lib/richtext/CMakeLists.txt index ad85244e9f..89c618fd69 100644 --- a/build/cmake/lib/richtext/CMakeLists.txt +++ b/build/cmake/lib/richtext/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(RICHTEXT_FILES RICHTEXT) wx_add_library(wxrichtext ${RICHTEXT_FILES}) diff --git a/build/cmake/lib/stc/CMakeLists.txt b/build/cmake/lib/stc/CMakeLists.txt index 7d3b39c205..1116186833 100644 --- a/build/cmake/lib/stc/CMakeLists.txt +++ b/build/cmake/lib/stc/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(STC_FILES STC_CMN) if(WXOSX_COCOA) diff --git a/build/cmake/lib/webview/CMakeLists.txt b/build/cmake/lib/webview/CMakeLists.txt index 356b8458fa..0408ee7741 100644 --- a/build/cmake/lib/webview/CMakeLists.txt +++ b/build/cmake/lib/webview/CMakeLists.txt @@ -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() diff --git a/build/cmake/lib/xml/CMakeLists.txt b/build/cmake/lib/xml/CMakeLists.txt index 12dd3fed51..d4690a0afb 100644 --- a/build/cmake/lib/xml/CMakeLists.txt +++ b/build/cmake/lib/xml/CMakeLists.txt @@ -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}) diff --git a/build/cmake/lib/xrc/CMakeLists.txt b/build/cmake/lib/xrc/CMakeLists.txt index 1196c35616..453525eab5 100644 --- a/build/cmake/lib/xrc/CMakeLists.txt +++ b/build/cmake/lib/xrc/CMakeLists.txt @@ -7,8 +7,6 @@ # Licence: wxWindows licence ############################################################################# -include(../../source_groups.cmake) - wx_append_sources(XRC_FILES XRC) wx_add_library(wxxrc ${XRC_FILES}) diff --git a/build/cmake/main.cmake b/build/cmake/main.cmake index 4a871a7ed8..f152a4f212 100644 --- a/build/cmake/main.cmake +++ b/build/cmake/main.cmake @@ -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 diff --git a/build/cmake/source_groups.cmake b/build/cmake/source_groups.cmake index 7e8ba95f4b..c8e2ec6261 100644 --- a/build/cmake/source_groups.cmake +++ b/build/cmake/source_groups.cmake @@ -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()