From 35d90784e9be0879a818d71bbc8d7ee1a9c5871a Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Tue, 31 Oct 2023 21:38:49 +0100 Subject: FindwxWidgets: use IN_LIST --- Modules/FindwxWidgets.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 78fa481..89ba725 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -188,6 +188,9 @@ macro(DBG_MSG_V _MSG) # "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}") endmacro() +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + # Clear return values in case the module is loaded more than once. set(wxWidgets_FOUND FALSE) set(wxWidgets_INCLUDE_DIRS "") @@ -441,8 +444,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") endif() DBG_MSG_V("OpenGL") - list(FIND ${_LIBS} gl WX_USE_GL) - if(NOT WX_USE_GL EQUAL -1) + if(gl IN_LIST ${_LIBS}) DBG_MSG_V("- is required.") list(APPEND wxWidgets_LIBRARIES opengl32 glu32) endif() @@ -1215,3 +1217,5 @@ function(WXWIDGETS_ADD_RESOURCES _outfiles) set(${_outfiles} ${${_outfiles}} PARENT_SCOPE) endfunction() + +cmake_policy(POP) -- cgit v0.12 From 625023cacee4aaaa9f991207b294b49336f1f646 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Fri, 6 Oct 2023 21:01:08 +0200 Subject: FindwxWidgets: Include hotfix number Add it to the wxWidgets_VERSION_STRING when it is not 0. Include hotfix numbers when searching for installation paths, for example wxWidgets-3.2.2.1. Fixes: #24823 --- Modules/FindwxWidgets.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 89ba725..845845c 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -247,8 +247,14 @@ macro(wx_extract_version) "\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" ) string(REGEX REPLACE "^(.*\n)?#define +wxRELEASE_NUMBER +([0-9]+).*" "\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" ) + string(REGEX REPLACE "^(.*\n)?#define +wxSUBRELEASE_NUMBER +([0-9]+).*" + "\\2" wxWidgets_VERSION_TWEAK "${_wx_version_h}" ) + set(wxWidgets_VERSION_STRING "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" ) + if(${wxWidgets_VERSION_TWEAK} GREATER 0) + string(APPEND wxWidgets_VERSION_STRING ".${wxWidgets_VERSION_TWEAK}") + endif() dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}") endmacro() @@ -460,6 +466,9 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") foreach(version ${wx_versions}) foreach(patch RANGE 15 0 -1) list(APPEND wx_paths "wxWidgets-${version}.${patch}") + foreach(tweak RANGE 3 1 -1) + list(APPEND wx_paths "wxWidgets-${version}.${patch}.${tweak}") + endforeach() endforeach() endforeach() -- cgit v0.12 From c5e3d12213f7362a99e29d58b2cd01f613206e50 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 8 Oct 2023 18:22:33 +0200 Subject: FindwxWidgets: Move wx-config specific checks inside UNIX find-style --- Modules/FindwxWidgets.cmake | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 845845c..82ae07f 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -948,29 +948,29 @@ if(wxWidgets_FIND_STYLE STREQUAL "unix") endif() unset(_cygpath_exe CACHE) endif() -endif() -# Check that all libraries are present, as wx-config does not check it -set(_wx_lib_missing "") -foreach(_wx_lib_ ${wxWidgets_LIBRARIES}) - if("${_wx_lib_}" MATCHES "^-l(.*)") - set(_wx_lib_name "${CMAKE_MATCH_1}") - unset(_wx_lib_found CACHE) - find_library(_wx_lib_found NAMES ${_wx_lib_name} HINTS ${wxWidgets_LIBRARY_DIRS}) - if(_wx_lib_found STREQUAL _wx_lib_found-NOTFOUND) - list(APPEND _wx_lib_missing ${_wx_lib_name}) - endif() - unset(_wx_lib_found CACHE) - endif() -endforeach() + # Check that all libraries are present, as wx-config does not check it + set(_wx_lib_missing "") + foreach(_wx_lib_ ${wxWidgets_LIBRARIES}) + if("${_wx_lib_}" MATCHES "^-l(.*)") + set(_wx_lib_name "${CMAKE_MATCH_1}") + unset(_wx_lib_found CACHE) + find_library(_wx_lib_found NAMES ${_wx_lib_name} HINTS ${wxWidgets_LIBRARY_DIRS}) + if(_wx_lib_found STREQUAL _wx_lib_found-NOTFOUND) + list(APPEND _wx_lib_missing ${_wx_lib_name}) + endif() + unset(_wx_lib_found CACHE) + endif() + endforeach() -if (_wx_lib_missing) - string(REPLACE ";" " " _wx_lib_missing "${_wx_lib_missing}") - DBG_MSG_V("wxWidgets not found due to following missing libraries: ${_wx_lib_missing}") - set(wxWidgets_FOUND FALSE) - unset(wxWidgets_LIBRARIES) + if (_wx_lib_missing) + string(REPLACE ";" " " _wx_lib_missing "${_wx_lib_missing}") + DBG_MSG_V("wxWidgets not found due to following missing libraries: ${_wx_lib_missing}") + set(wxWidgets_FOUND FALSE) + unset(wxWidgets_LIBRARIES) + endif() + unset(_wx_lib_missing) endif() -unset(_wx_lib_missing) # Check if a specific version was requested by find_package(). if(wxWidgets_FOUND) -- cgit v0.12 From 55072adf16231cc27befe4370d0ec261a59138c9 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 8 Oct 2023 18:26:08 +0200 Subject: FindwxWidgets: Improve linking with scintilla Treat scintilla like any other common lib. Only add it when the stc component is specified. Add imm32 to the list of required libraries when stc is used. Fixes: #23519 --- Modules/FindwxWidgets.cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 82ae07f..933f14e 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -37,7 +37,7 @@ select a configuration): wxWidgets_EXCLUDE_COMMON_LIBRARIES - Set to TRUE to exclude linking of commonly required libs (e.g., png tiff - jpeg zlib regex expat). + jpeg zlib regex expat scintilla). @@ -286,8 +286,10 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") # Add the common (usually required libs) unless # wxWidgets_EXCLUDE_COMMON_LIBRARIES has been set. if(NOT wxWidgets_EXCLUDE_COMMON_LIBRARIES) - list(APPEND wxWidgets_FIND_COMPONENTS - ${wxWidgets_COMMON_LIBRARIES}) + if(stc IN_LIST wxWidgets_FIND_COMPONENTS) + list(APPEND wxWidgets_FIND_COMPONENTS scintilla) + endif() + list(APPEND wxWidgets_FIND_COMPONENTS ${wxWidgets_COMMON_LIBRARIES}) endif() #------------------------------------------------------------------- @@ -455,6 +457,10 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") list(APPEND wxWidgets_LIBRARIES opengl32 glu32) endif() + if(stc IN_LIST ${_LIBS}) + list(APPEND wxWidgets_LIBRARIES imm32) + endif() + list(APPEND wxWidgets_LIBRARIES winmm comctl32 uuid oleacc uxtheme rpcrt4 shlwapi version wsock32) endmacro() -- cgit v0.12 From d76242ed9fa180ae14f796b406cf913ef4a02db9 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 8 Oct 2023 18:27:25 +0200 Subject: FindwxWidgets: Prevent searching libraries multiple times If the user has specified common libraries, remove the duplicates. --- Modules/FindwxWidgets.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 933f14e..2c0dfd1 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -292,6 +292,9 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") list(APPEND wxWidgets_FIND_COMPONENTS ${wxWidgets_COMMON_LIBRARIES}) endif() + # Remove duplicates, for example when user has specified common libraries. + list(REMOVE_DUPLICATES wxWidgets_FIND_COMPONENTS) + #------------------------------------------------------------------- # WIN32: Helper MACROS #------------------------------------------------------------------- -- cgit v0.12 From f8831a0c9eec8fd5b4a9d96a547b6d0e1f5736f7 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 8 Oct 2023 18:28:56 +0200 Subject: FindwxWidgets: Convert include and library paths to cmake-style This fixes DBG_MSG errors when a path uses \ instead of /. --- Modules/FindwxWidgets.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index 2c0dfd1..a91dc0a 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -986,6 +986,9 @@ if(wxWidgets_FOUND) wx_extract_version() endif() +file(TO_CMAKE_PATH "${wxWidgets_INCLUDE_DIRS}" wxWidgets_INCLUDE_DIRS) +file(TO_CMAKE_PATH "${wxWidgets_LIBRARY_DIRS}" wxWidgets_LIBRARY_DIRS) + # Debug output: DBG_MSG("wxWidgets_FOUND : ${wxWidgets_FOUND}") DBG_MSG("wxWidgets_INCLUDE_DIRS : ${wxWidgets_INCLUDE_DIRS}") -- cgit v0.12 From 90b77e3783aa72c1d99cc3c2d6854a97aae21046 Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 8 Oct 2023 18:30:06 +0200 Subject: FindwxWidgets: link with lexilla In wxWidgets 3.3 (development version) the Scintilla library has been split into two components: Scintilla and Lexilla. --- Modules/FindwxWidgets.cmake | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index a91dc0a..b42a85e 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -37,7 +37,7 @@ select a configuration): wxWidgets_EXCLUDE_COMMON_LIBRARIES - Set to TRUE to exclude linking of commonly required libs (e.g., png tiff - jpeg zlib regex expat scintilla). + jpeg zlib regex expat scintilla lexilla). @@ -274,6 +274,9 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") # Useful common wx libs needed by almost all components. set(wxWidgets_COMMON_LIBRARIES png tiff jpeg zlib regex expat) + # Libraries needed by stc component + set(wxWidgets_STC_LIBRARIES scintilla lexilla) + # DEPRECATED: Use find_package(wxWidgets COMPONENTS mono) instead. if(NOT wxWidgets_FIND_COMPONENTS) if(wxWidgets_USE_MONOLITHIC) @@ -287,7 +290,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") # wxWidgets_EXCLUDE_COMMON_LIBRARIES has been set. if(NOT wxWidgets_EXCLUDE_COMMON_LIBRARIES) if(stc IN_LIST wxWidgets_FIND_COMPONENTS) - list(APPEND wxWidgets_FIND_COMPONENTS scintilla) + list(APPEND wxWidgets_FIND_COMPONENTS ${wxWidgets_STC_LIBRARIES}) endif() list(APPEND wxWidgets_FIND_COMPONENTS ${wxWidgets_COMMON_LIBRARIES}) endif() @@ -326,7 +329,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") # FIXME: What if both regex libs are available. regex should be # found outside the loop and only wx${LIB}${_UCD}${_DBG}. # Find wxWidgets common libraries. - foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla) + foreach(LIB ${wxWidgets_COMMON_LIBRARIES} ${wxWidgets_STC_LIBRARIES}) find_library(WX_${LIB}${_DBG} NAMES wx${LIB}${_UCD}${_DBG} # for regex @@ -385,7 +388,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32") # Clear all debug or release library paths (arguments are "d" or ""). macro(WX_CLEAR_ALL_LIBS _DBG) # Clear wxWidgets common libraries. - foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla) + foreach(LIB ${wxWidgets_COMMON_LIBRARIES} ${wxWidgets_STC_LIBRARIES}) WX_CLEAR_LIB(WX_${LIB}${_DBG}) endforeach() -- cgit v0.12