mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-11 01:29:36 -06:00
FindwxWidgets: Move extracting version number to a macro
This commit is contained in:
@@ -215,6 +215,29 @@ else()
|
|||||||
set(wxWidgets_USE_FILE UsewxWidgets)
|
set(wxWidgets_USE_FILE UsewxWidgets)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
macro(wx_extract_version)
|
||||||
|
unset(_wx_filename)
|
||||||
|
find_file(_wx_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
|
||||||
|
dbg_msg("_wx_filename: ${_wx_filename}")
|
||||||
|
|
||||||
|
if(NOT _wx_filename)
|
||||||
|
message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
file(READ "${_wx_filename}" _wx_version_h)
|
||||||
|
unset(_wx_filename CACHE)
|
||||||
|
|
||||||
|
string(REGEX REPLACE "^(.*\n)?#define +wxMAJOR_VERSION +([0-9]+).*"
|
||||||
|
"\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" )
|
||||||
|
string(REGEX REPLACE "^(.*\n)?#define +wxMINOR_VERSION +([0-9]+).*"
|
||||||
|
"\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" )
|
||||||
|
string(REGEX REPLACE "^(.*\n)?#define +wxRELEASE_NUMBER +([0-9]+).*"
|
||||||
|
"\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" )
|
||||||
|
set(wxWidgets_VERSION_STRING
|
||||||
|
"${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" )
|
||||||
|
dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
#=====================================================================
|
#=====================================================================
|
||||||
# Determine whether unix or win32 paths should be used
|
# Determine whether unix or win32 paths should be used
|
||||||
#=====================================================================
|
#=====================================================================
|
||||||
@@ -981,26 +1004,7 @@ unset(_wx_lib_missing)
|
|||||||
|
|
||||||
# Check if a specific version was requested by find_package().
|
# Check if a specific version was requested by find_package().
|
||||||
if(wxWidgets_FOUND)
|
if(wxWidgets_FOUND)
|
||||||
unset(_wx_filename)
|
wx_extract_version()
|
||||||
find_file(_wx_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
|
|
||||||
dbg_msg("_wx_filename: ${_wx_filename}")
|
|
||||||
|
|
||||||
if(NOT _wx_filename)
|
|
||||||
message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
file(READ "${_wx_filename}" _wx_version_h)
|
|
||||||
unset(_wx_filename CACHE)
|
|
||||||
|
|
||||||
string(REGEX REPLACE "^(.*\n)?#define +wxMAJOR_VERSION +([0-9]+).*"
|
|
||||||
"\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" )
|
|
||||||
string(REGEX REPLACE "^(.*\n)?#define +wxMINOR_VERSION +([0-9]+).*"
|
|
||||||
"\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" )
|
|
||||||
string(REGEX REPLACE "^(.*\n)?#define +wxRELEASE_NUMBER +([0-9]+).*"
|
|
||||||
"\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" )
|
|
||||||
set(wxWidgets_VERSION_STRING
|
|
||||||
"${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" )
|
|
||||||
dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Debug output:
|
# Debug output:
|
||||||
|
|||||||
Reference in New Issue
Block a user