在 CMake 中获取 wxWidgets 的版本
我试图确定 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在我的 Ubuntu 18.04.2 LTS 上
CMake 命令:
调用宏:
设置以下变量:
因此以下代码检查版本:
On my Ubuntu 18.04.2 LTS
CMake command:
calls macro:
which sets following variables:
So following code checks the version:
打开终端并写入
Open terminal and write
有人建议了一个名为 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 :(