首页 > 解决方案 > CMake 错误:找不到 ExtraCMakeModule

问题描述

提示:在syntax-highlight树枝上

KSyntaxHighlighting在我的项目中使用过。这取决于ExtraCMakeModule. 但是 CMake 提示我他找不到ECM.

提示:我的项目KSyntaxHighlighting这里

CMake Error at src/3rdparty/syntax-highlighting/CMakeLists.txt:8 (find_package):
  Could not find a package configuration file provided by "ECM" with any of
  the following names:
    ECMConfig.cmake
    ecm-config.cmake
  ...

但我认为ECM是执行的,因为我看到了上面的日志上面的日志:

提示:ECM这里

CMake Warning (dev) at src/3rdparty/syntax-highlighting/extra-cmake-modules/docs/CMakeLists.txt:41 (find_package):
  FindQCollectionGenerator.cmake must either be part of this project itself,
  in this case adjust CMAKE_MODULE_PATH so that it points to the correct
  location inside its source tree.

提示:您可以在CMake 错误日志中看到完整的日志

文件结构是这样的:

.
└── src
    ├── 3rdparty
    │   └── syntax-highlighting
    │       ├── extra-cmake-modules

这是项目的CMakeLists.txt

# CMakeLists.txt
cmake_minimum_required(VERSION 3.1.0)

project(notepanda)

list(GET VERSION_LIST 0 CMAKE_PROJECT_VERSION_MAJOR)
list(GET VERSION_LIST 1 CMAKE_PROJECT_VERSION_MINOR)
list(GET VERSION_LIST 2 CPACK_PACKAGE_VERSION_PATCH)

add_definitions(-DVERSION_STRING="${VERSION_STRING}")
add_definitions(-DXTOSTRUCT_QT)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

if(CMAKE_VERSION VERSION_LESS "3.7.0")
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()

add_subdirectory(src/3rdparty/syntax-highlighting)
add_subdirectory(src/3rdparty/syntax-highlighting/extra-cmake-modules)

find_package(Qt5 COMPONENTS Widgets Svg REQUIRED)
find_package(KF5SyntaxHighlighting)
find_package(ECM)

KSyntaxHighlighting的 CMakeLists.txt

cmake_minimum_required(VERSION 3.5)

add_subdirectory(extra-cmake-modules)

set(KF5_VERSION "5.70.0")
project(KSyntaxHighlighting VERSION ${KF5_VERSION})

find_package(ECM REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
if(POLICY CMP0063)
    cmake_policy(SET CMP0063 NEW)
endif()

include(KDEInstallDirs)
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
......

标签: c++qtcmake

解决方案


ecm

大家好,我现在有答案了。谢谢!


推荐阅读