在 CMake 中获取 wxWidgets 的版本

发布于 2024-11-04 11:26:01 字数 1227 浏览 0 评论 0原文

我试图确定 CMake 找到的 wxWidgets 版本是否 >= 2.9。我尝试了这个:(

find_package(wxWidgets 2.9 COMPONENTS core base REQUIRED)
if(wxWidgets_FOUND)
  message("wxWidgets found successfully.")
  include( ${wxWidgets_USE_FILE} )
else()
  message(FATAL_ERROR "wxWidgets was not found!")
endif()

if(wxWidgets_VERSION LESS 2.9)
  message(FATAL_ERROR "wxWidgets is not a high enough version!")
else()
  message("wxWidgets Version ${wxWidgets_VERSION}")
  message("wxWidgets Major version ${wxMAJOR_VERSION}")
  message("release number ${wxRELEASE_NUMBER}")
  message("check version ${wxCHECK_VERSION}")
  message("wxWidgets version ${WX_WIDGETS_VERSION}")
  message("wxWidgets major version ${WX_MAJOR_VERSION}")
  message("wxWidgets version string ${WX_VERSION_STRING}")
endif()

我的系统有wx2.8,所以这应该失败)。

if(wxWidgets_FOUND) 返回 TRUE,到目前为止一切顺利。然而,if(wxWidgets_VERSION LESS 2.9)失败了,但这并不是因为wxWidgets_VERSION < 2.9。 2.9.这是因为wxWidgets_VERSION是空的。事实上,整个输出是:(

wxWidgets Version 
wxWidgets Major version 
release number 
check version 
wxWidgets version 
wxWidgets major version 
wxWidgets version string 

即所有变量都是空的)

有谁知道通过CMake检查wxWidgets版本的正确方法?

谢谢,

大卫

I am trying to determine if the version of wxWidgets found by CMake is >= 2.9. I tried this:

find_package(wxWidgets 2.9 COMPONENTS core base REQUIRED)
if(wxWidgets_FOUND)
  message("wxWidgets found successfully.")
  include( ${wxWidgets_USE_FILE} )
else()
  message(FATAL_ERROR "wxWidgets was not found!")
endif()

if(wxWidgets_VERSION LESS 2.9)
  message(FATAL_ERROR "wxWidgets is not a high enough version!")
else()
  message("wxWidgets Version ${wxWidgets_VERSION}")
  message("wxWidgets Major version ${wxMAJOR_VERSION}")
  message("release number ${wxRELEASE_NUMBER}")
  message("check version ${wxCHECK_VERSION}")
  message("wxWidgets version ${WX_WIDGETS_VERSION}")
  message("wxWidgets major version ${WX_MAJOR_VERSION}")
  message("wxWidgets version string ${WX_VERSION_STRING}")
endif()

(My system has wx2.8, so this should fail).

The if(wxWidgets_FOUND) returns TRUE, so so far so good. However, the if(wxWidgets_VERSION LESS 2.9) fails, but it is not because wxWidgets_VERSION is < 2.9. It is because wxWidgets_VERSION is empty. In fact, the whole output is:

wxWidgets Version 
wxWidgets Major version 
release number 
check version 
wxWidgets version 
wxWidgets major version 
wxWidgets version string 

(i.e. all of the variables are empty)

Does anyone know the correct way to check for the wxWidgets version through CMake?

Thanks,

David

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

深空失忆 2024-11-11 11:26:01

在我的 Ubuntu 18.04.2 LTS 上
CMake 命令:

find_package(wxWidgets REQUIRED)

调用宏:

/usr/share/cmake-3.10/Modules/FindwxWidgets.cmake

设置以下变量:

wxWidgets_VERSION_STRING   # 3.0.4
wxWidgets_VERSION_MAJOR    # 3
wxWidgets_VERSION_MINOR    # 0
wxWidgets_VERSION_PATCH    # 4

因此以下代码检查版本:

find_package(wxWidgets REQUIRED)
include(${wxWidgets_USE_FILE})

if (wxWidgets_VERSION_STRING LESS 2.9)
    message("Version < 2.9")
endif()

# Or
if (wxWidgets_VERSION_STRING GREATER_EQUAL 2.9)
    message("Version >= 2.9")
endif()

On my Ubuntu 18.04.2 LTS
CMake command:

find_package(wxWidgets REQUIRED)

calls macro:

/usr/share/cmake-3.10/Modules/FindwxWidgets.cmake

which sets following variables:

wxWidgets_VERSION_STRING   # 3.0.4
wxWidgets_VERSION_MAJOR    # 3
wxWidgets_VERSION_MINOR    # 0
wxWidgets_VERSION_PATCH    # 4

So following code checks the version:

find_package(wxWidgets REQUIRED)
include(${wxWidgets_USE_FILE})

if (wxWidgets_VERSION_STRING LESS 2.9)
    message("Version < 2.9")
endif()

# Or
if (wxWidgets_VERSION_STRING GREATER_EQUAL 2.9)
    message("Version >= 2.9")
endif()
夜访吸血鬼 2024-11-11 11:26:01

打开终端并写入

wx-config --version

Open terminal and write

wx-config --version
灼疼热情 2024-11-11 11:26:01

有人建议了一个名为 wxArt2d 的项目,它有更好的 wxWidgets cmake。不幸的是,这些东西并不容易/更好地维护:(

Someone suggested a project named wxArt2d that has a bit better wxWidgets cmake. It is unfortunate that these things are not easier/better maintained :(

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文