CMake - 某些 boost 版本的补丁(复制)文件

问题描述 投票:0回答:1

Ubuntu 22.04 附带的 C++ Boost 1.74 具有与 C++20 不兼容的代码。在声明构建之前,我需要复制一个可用的备用文件。 以下是 CMakeLists.txt 文件的片段。

如果我注释掉“if($Boost_VERSION...”并保留文件,它可以正常工作,但不能证明未来。

我的问题是如何对boost版本进行比较。

set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_DEBUG TRUE)
set(Boost_NO_BOOST_CMAKE OFF)
find_package(Boost 1.74.0 REQUIRED COMPONENTS program_options locale)

include(wtOptions.txt)
# Patch the boost include library for a C++2z error.
#if(${Boost_VERSION_MINOR} > 75)
  file(COPY ${CMAKE_SOURCE_DIR}/files/storage.hpp DESTINATION /usr/include/boost/numeric/ublas)
#endif()

` 我得到的错误是

CMake Error at CMakeLists.txt:35 (if):
  if given arguments:

    "74" ">" "75"

  Unknown arguments specified

这个想法是,如果 boost 版本是 1.74,则自动修补。我不想使用更新版本的 boost,需要坚持使用基本安装版本。

cmake boost patch
1个回答
0
投票

我相信你需要像这样做条件:

if(${Boost_VERSION_MINOR} GREATER 75)
  # ...
endif()

使用

GREATER
而不是
>
进行数值比较。

© www.soinside.com 2019 - 2024. All rights reserved.