CMake Warning (dev) at cmake/OpenCVUtils.cmake:146 (find_package): Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules are removed. Run "cmake --help-policy CMP0148" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): cmake/OpenCVDetectPython.cmake:64 (find_host_package) cmake/OpenCVDetectPython.cmake:271 (find_python) CMakeLists.txt:649 (include) This warning is for project developers. Use -Wno-dev to suppress it.

时间: 2025-07-04 12:48:11 浏览: 9
<think>嗯,用户遇到了CMake的CMP0148策略警告,需要解决这个问题。首先,我得回忆一下CMP0148是什么。CMake的策略通常和兼容性或者废弃的功能有关。根据用户提到的find_pythoninterp和find_pythonlibs被移除,这可能是因为在较新的CMake版本中,这些旧模块被弃用了,转而推荐使用FindPython模块。 查找一下CMake的文档,CMP0148确实涉及到FindPythonInterp和FindPythonLibs的移除。当用户升级CMake到3.27或更高版本时,这些旧模块不再可用,所以需要迁移到新的FindPython方法。用户需要修改他们的CMakeLists.txt文件,将find_package(PythonInterp)和find_package(PythonLibs)替换为find_package(Python COMPONENTS Interpreter Development)。 接下来,用户可能不知道如何具体修改代码。例如,原来的变量如PYTHON_EXECUTABLE现在应该用Python_EXECUTABLE代替,而PYTHON_INCLUDE_DIRS和PYTHON_LIBRARIES则会被Python_INCLUDE_DIRS和Python_LIBRARIES取代。此外,如果用户需要同时支持新旧CMake版本,他们可能需要条件判断,根据CMake版本来选择使用旧的还是新的模块。 另外,用户提到的策略警告可能需要在CMakeLists.txt开头设置策略CMP0148为NEW,这样可以消除警告。例如,添加if(POLICY CMP0148)和cmake_policy(SET CMP0148 NEW)这样的代码。同时,确保cmake_minimum_required的版本足够高,或者至少设置为支持新策略的版本,比如3.27或更高。 可能用户的项目中还依赖其他第三方库,比如pybind11,这些库可能还在使用旧的FindPythonInterp方法,这时候需要更新这些依赖库的版本,或者手动修改它们的CMakeLists.txt文件,类似用户之前处理CMP0127的策略问题一样。 最后,测试修改后的CMake配置是否正常工作,确保所有Python相关的路径和库都正确找到,项目能够成功构建。如果用户遇到其他问题,可能需要进一步调整变量名或路径设置。</think>### 解决方案:CMake CMP0148警告的修复方法 CMake的`CMP0148`策略警告源于旧版`FindPythonInterp`和`FindPythonLibs`模块的移除[^2][^4]。以下是逐步解决方法: --- #### 步骤 1:理解警告原因 - **触发条件**:CMake >=3.27版本中,`FindPythonInterp`和`FindPythonLibs`模块被废弃,改用统一的`FindPython`模块[^2]。 - **典型报错**:`find_package(PythonInterp)`或`find_package(PythonLibs)`时出现策略警告。 --- #### 步骤 2:修改CMakeLists.txt 将旧版Python检测逻辑替换为新的`FindPython`语法: ```cmake # 旧语法(触发CMP0148警告) find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) # 新语法(兼容CMP0148) find_package(Python COMPONENTS Interpreter Development REQUIRED) ``` --- #### 步骤 3:更新变量引用 替换旧版变量名以适配新模块: - `PYTHON_EXECUTABLE` → `Python_EXECUTABLE` - `PYTHON_INCLUDE_DIRS` → `Python_INCLUDE_DIRS` - `PYTHON_LIBRARIES` → `Python_LIBRARIES` 例如: ```cmake include_directories(${Python_INCLUDE_DIRS}) target_link_libraries(your_target ${Python_LIBRARIES}) ``` --- #### 步骤 4:强制策略兼容(可选) 在CMakeLists.txt开头添加策略设置: ```cmake if(POLICY CMP0148) cmake_policy(SET CMP0148 NEW) # 强制使用新策略 endif() ``` --- #### 步骤 5:验证构建 重新运行CMake生成命令: ```bash cmake .. -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug # 参考用户环境[^3] ``` --- ### 补充说明 - **多版本兼容**:若需支持CMake <3.27,可通过条件分支处理: ```cmake if(CMAKE_VERSION VERSION_LESS 3.27) find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) else() find_package(Python COMPONENTS Interpreter Development REQUIRED) endif() ``` - **第三方库适配**:若依赖库(如pybind11)触发此警告,需更新其CMake脚本或手动添加策略覆盖[^1][^4]。 ---
阅读全文

相关推荐

(openpose) root@cnshaw2404:~/Documents/openpose/build# cmake .. -DBUILD_PYTHON=true -DUSE_CUDNN=off CMake Warning (dev) at CMakeLists.txt:19 (project): cmake_minimum_required() should be called prior to this top-level project() call. Please see the cmake-commands(7) manual for usage documentation of both commands. This warning is for project developers. Use -Wno-dev to suppress it. CMake Deprecation Warning at CMakeLists.txt:34 (cmake_minimum_required): Compatibility with CMake < 3.10 will be removed from a future version of CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. -- GCC detected, adding compile flags -- GCC detected, adding compile flags CMake Warning (dev) at CMakeLists.txt:214 (find_package): Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake --help-policy CMP0146" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it. -- Building with CUDA. CMake Warning (dev) at CMakeLists.txt:353 (find_package): Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake --help-policy CMP0146" for policy details. Use the cmake_policy command to set the policy and suppress this warning. This warning is for project developers. Use -Wno-dev to suppress it. CMake Warning (dev) at cmake/Cuda.cmake:282 (find_package): Policy CMP0146 is not set: The FindCUDA module is removed. Run "cmake --help-policy CMP0146" for policy details. Use the cmake_policy command to set the policy and suppress this warning. Call Stack (most recent call first): CMakeLists.txt:424 (include) This warning is for project developers. Use -Wno-dev to suppress it. -- CUDA detected: 11.8 -- Added CUDA NVCC flags for: sm_86 -- cuDNN not found -- Found gfl

colcon build source install/setup.bash Starting >>> diyiban_sldasm --- stderr: diyiban_sldasm CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. CMake Warning (dev) at /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:41 (if): Policy CMP0057 is not set: Support new IN_LIST if() operator. Run "cmake --help-policy CMP0057" for policy details. Use the cmake_policy command to set the policy and suppress this warning. IN_LIST will be interpreted as an operator when the policy is set to NEW. Since the policy is not set the OLD behavior will be used. Call Stack (most recent call first): /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_package.cmake:66 (ament_execute_extensions) CMakeLists.txt:7 (ament_package) This warning is for project developers. Use -Wno-dev to suppress it. CMake Error at /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:41 (if): if given arguments: "ament_cmake_core" "IN_LIST" "_ARG_AMENT_EXECUTE_EXTENSIONS_EXCLUDE" Unknown arguments specified Call Stack (most recent call first): /opt/ros/humble/share/ament_cmake_core/cmake/core/ament_package.cmake:66 (ament_execute_extensions) CMakeLists.txt:7 (ament_package) --- Failed <<< diyiban_sldasm [0.95s, exited with code 1] Summary: 0 packages finished [1.39s] 1 package failed: diyiban_sldasm 1 package had stderr output: diyiban_sldasm

CMake Error at /usr/share/cmake-3.16/Modules/Platform/Android-Determine.cmake:194 (list): list GET given empty list Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:129 (include) CMakeLists.txt:30 (project) CMake Error at /usr/share/cmake-3.16/Modules/Platform/Android-Determine.cmake:198 (message): Android: The API specified by CMAKE_SYSTEM_VERSION='' is not an integer. Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:129 (include) CMakeLists.txt:30 (project) CMake Warning (dev) in /usr/share/cmake-3.16/Modules/Platform/Android-Determine.cmake: Policy CMP0011 is not set: Included scripts do automatic cmake_policy PUSH and POP. Run "cmake --help-policy CMP0011" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The included script /usr/share/cmake-3.16/Modules/Platform/Android-Determine.cmake affects policy settings. CMake is implying the NO_POLICY_SCOPE option for compatibility, so the effects are applied to the including context. Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/CMakeDetermineSystem.cmake:129 (include) CMakeLists.txt:30 (project) This warning is for project developers. Use -Wno-dev to suppress it. CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool. CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage -- Configuring incomplete, errors occurred! 什么意思

cd ~/ros2_ws colcon build --packages-select diyiban source install/setup.bash Starting >>> diyiban --- stderr: diyiban CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 2.8.12 will be removed from a future version of CMake. Update the VERSION argument <min> value or use a ...<max> suffix to tell CMake that the project does not need compatibility with older versions. CMake Warning (dev) at CMakeLists.txt:3 (project): Policy CMP0048 is not set: project() command manages VERSION variables. Run "cmake --help-policy CMP0048" for policy details. Use the cmake_policy command to set the policy and suppress this warning. The following variable(s) would be set to empty: CMAKE_PROJECT_VERSION CMAKE_PROJECT_VERSION_MAJOR CMAKE_PROJECT_VERSION_MINOR CMAKE_PROJECT_VERSION_PATCH This warning is for project developers. Use -Wno-dev to suppress it. Traceback (most recent call last): File "/home/ros2/catkin_ws/install/catkin/share/catkin/cmake/parse_package_xml.py", line 115, in <module> main() File "/home/ros2/catkin_ws/install/catkin/share/catkin/cmake/parse_package_xml.py", line 101, in main package = parse_package(args.package_xml) File "/usr/local/lib/python3.10/dist-packages/catkin_pkg/package.py", line 584, in parse_package return parse_package_string(xml, filename, warnings=warnings) File "/usr/local/lib/python3.10/dist-packages/catkin_pkg/package.py", line 788, in parse_package_string pkg.validate(warnings=warnings) File "/usr/local/lib/python3.10/dist-packages/catkin_pkg/package.py", line 330, in validate raise InvalidPackage('\n'.join(errors), self.filename) catkin_pkg.package.InvalidPackage: Error(s) in package '/home/ros2/ros2_ws/src/diyiban/package.xml': Package name "diyiban.SLDASM" does not follow naming conventions CMake Error at /home/ros2/catkin_ws/install/catkin/share/catkin/cmake/safe_execute_process.cmake:11 (message):

最新推荐

recommend-type

2021年计算机二级无纸化选择题题库.doc

2021年计算机二级无纸化选择题题库.doc
recommend-type

2022java实训心得体会.docx

2022java实训心得体会.docx
recommend-type

2022cad绘图实训心得体会_.docx

2022cad绘图实训心得体会_.docx
recommend-type

毕业设计-179 SSM 驾校预约管理系统.zip

毕业设计-179 SSM 驾校预约管理系统.zip
recommend-type

2022IT软件公司员工辞职申请书.docx

2022IT软件公司员工辞职申请书.docx
recommend-type

ChmDecompiler 3.60:批量恢复CHM电子书源文件工具

### 知识点详细说明 #### 标题说明 1. **Chm电子书批量反编译器(ChmDecompiler) 3.60**: 这里提到的是一个软件工具的名称及其版本号。软件的主要功能是批量反编译CHM格式的电子书。CHM格式是微软编译的HTML文件格式,常用于Windows平台下的帮助文档或电子书。版本号3.60说明这是该软件的一个更新的版本,可能包含改进的新功能或性能提升。 #### 描述说明 2. **专门用来反编译CHM电子书源文件的工具软件**: 这里解释了该软件的主要作用,即用于解析CHM文件,提取其中包含的原始资源,如网页、文本、图片等。反编译是一个逆向工程的过程,目的是为了将编译后的文件还原至其原始形态。 3. **迅速地释放包括在CHM电子书里面的全部源文件**: 描述了软件的快速处理能力,能够迅速地将CHM文件中的所有资源提取出来。 4. **恢复源文件的全部目录结构及文件名**: 这说明软件在提取资源的同时,会尝试保留这些资源在原CHM文件中的目录结构和文件命名规则,以便用户能够识别和利用这些资源。 5. **完美重建.HHP工程文件**: HHP文件是CHM文件的项目文件,包含了编译CHM文件所需的所有元数据和结构信息。软件可以重建这些文件,使用户在提取资源之后能够重新编译CHM文件,保持原有的文件设置。 6. **多种反编译方式供用户选择**: 提供了不同的反编译选项,用户可以根据需要选择只提取某些特定文件或目录,或者提取全部内容。 7. **支持批量操作**: 在软件的注册版本中,可以进行批量反编译操作,即同时对多个CHM文件执行反编译过程,提高了效率。 8. **作为CHM电子书的阅读器**: 软件还具有阅读CHM电子书的功能,这是一个附加特点,允许用户在阅读过程中直接提取所需的文件。 9. **与资源管理器无缝整合**: 表明ChmDecompiler能够与Windows的资源管理器集成,使得用户可以在资源管理器中直接使用该软件的功能,无需单独启动程序。 #### 标签说明 10. **Chm电子书批量反编译器**: 这是软件的简短标签,用于标识软件的功能类型和目的,即批量反编译CHM电子书。 #### 文件名称列表说明 11. **etextwizard.cdsetup.exe**: 这是一个安装程序的文件名,带有.exe扩展名,表明它是一个可执行文件。这可能是用户安装ChmDecompiler软件的安装包。 12. **说明_Readme.html**: 这是一个包含说明文档的HTML文件,通常包含软件的安装指南、使用方法、常见问题解答等。用户应该在安装或使用软件之前仔细阅读该文档。 综合来看,ChmDecompiler是一款功能强大的工具软件,它可以处理CHM电子书的反编译需求,支持多种反编译方式,同时提供方便的用户界面和功能集成,极大地降低了用户进行电子书资料恢复或二次编辑的难度。此外,软件的安装程序和说明文档也遵循了行业标准,方便用户使用和理解。
recommend-type

【数据融合技术】:甘肃土壤类型空间分析中的专业性应用

# 摘要 数据融合技术作为一种集成多源数据信息的方法,在土壤类型空间分析中发挥着关键作用。本文介绍了数据融合技术的基本概念及其理论基础,阐述了数据预处理、同步整合及冲突解决等关键技术,并详细描述了甘肃土壤类型数据准备的流程,包括数据采集、质量评估、空间化处理及融合实践准备。通过具体案例分析,展示了数据融合在土壤类型空间分布分析、土壤质量评估及土壤保护规划中的应用。同时,文
recommend-type

redistemplate.opsForValue()返回值

<think>嗯,用户想知道RedisTemplate.opsForValue()方法的返回值类型。首先,我需要回忆一下Spring Data Redis的相关知识。记得RedisTemplate提供了不同数据结构的操作类,比如opsForValue对应字符串类型。opsForValue()方法返回的是一个ValueOperations对象,这个对象负责操作字符串类型的数据。 接下来,我需要确认返回类型的具体信息。根据官方文档,ValueOperations是一个接口,它定义了set、get等方法。当用户调用RedisTemplate.opsForValue()时,实际上会返回一个实现该接口
recommend-type

ktorrent 2.2.4版本Linux客户端发布

标题:“ktorrent”指的是一个流行的BitTorrent客户端软件,通常运行在类Unix操作系统上,特别是在Linux系统中。BitTorrent是一种点对点(P2P)文件共享协议,它允许用户之间共享文件,并且使用一种高效的“分片”下载技术,这意味着用户可以从许多其他用户那里同时下载文件的不同部分,从而加快下载速度并减少对单一源服务器的压力。 描述:提供的描述部分仅包含了重复的文件名“ktorrent-2.2.4.tar.gz”,这实际上表明了该信息是关于特定版本的ktorrent软件包,即版本2.2.4。它以.tar.gz格式提供,这是一种常见的压缩包格式,通常用于Unix-like系统中。在Linux环境下,tar是一个用于打包文件的工具,而.gz后缀表示文件已经被gzip压缩。用户需要先解压缩.tar.gz文件,然后才能安装软件。 标签:“ktorrent,linux”指的是该软件包是专为Linux操作系统设计的。标签还提示用户ktorrent可以在Linux环境下运行。 压缩包子文件的文件名称列表:这里提供了一个文件名“ktorrent-2.2.4”,该文件可能是从互联网上下载的,用于安装ktorrent版本2.2.4。 关于ktorrent软件的详细知识点: 1. 客户端功能:ktorrent提供了BitTorrent协议的完整实现,用户可以通过该客户端来下载和上传文件。它支持创建和管理种子文件(.torrent),并可以从其他用户那里下载大型文件。 2. 兼容性:ktorrent设计上与KDE桌面环境高度兼容,因为它是用C++和Qt框架编写的,但它也能在非KDE的其他Linux桌面环境中运行。 3. 功能特点:ktorrent提供了多样的配置选项,比如设置上传下载速度限制、选择存储下载文件的目录、设置连接数限制、自动下载种子包内的多个文件等。 4. 用户界面:ktorrent拥有一个直观的图形用户界面(GUI),使得用户可以轻松地管理下载任务,包括启动、停止、暂停以及查看各种统计数据,如下载速度、上传速度、完成百分比等。 5. 插件系统:ktorrent支持插件系统,因此用户可以扩展其功能,比如添加RSS订阅支持、自动下载和种子管理等。 6. 多平台支持:虽然ktorrent是为Linux系统设计的,但有一些类似功能的软件可以在不同的操作系统上运行,比如Windows和macOS。 7. 社区支持:ktorrent拥有活跃的社区,经常更新和改进软件。社区提供的支持包括论坛、文档以及bug跟踪。 安装和配置ktorrent的步骤大致如下: - 首先,用户需要下载相应的.tar.gz压缩包文件。 - 然后,使用终端命令解压该文件。通常使用命令“tar xzvf ktorrent-2.2.4.tar.gz”。 - 解压后,用户进入解压得到的目录并可能需要运行“qmake”来生成Makefile文件。 - 接着,使用“make”命令进行编译。 - 最后,通过“make install”命令安装软件。某些情况下可能需要管理员权限。 在编译过程中,用户可以根据自己的需求配置编译选项,比如选择安装路径、包含特定功能等。在Linux系统中,安装和配置过程可能会因发行版而异,有些发行版可能通过其包管理器直接提供对ktorrent的安装支持。
recommend-type

【空间分布规律】:甘肃土壤类型与农业生产的关联性研究

# 摘要 本文对甘肃土壤类型及其在农业生产中的作用进行了系统性研究。首先概述了甘肃土壤类型的基础理论,并探讨了土壤类型与农业生产的理论联系。通过GIS技术分析,本文详细阐述了甘肃土壤的空间分布规律,并对其特征和影响因素进行了深入分析。此外,本文还研究了甘肃土壤类型对农业生产实际影响,包括不同区域土壤改良和作物种植案例,以及土壤养分、水分管理对作物生长周期和产量的具体影响。最后,提出了促进甘肃土壤与农业可持续发展的策略,包括土壤保护、退化防治对策以及土壤类型优化与农业创新的结合。本文旨在为