cmake找不到这个软件包

hfyxw5xn  于 2023-03-08  发布在  其他
关注(0)|答案(1)|浏览(254)

我正在编译一些机器人软件示例。CMakelist应该从github下载这个包cppzmq,如下所示

FetchContent_Declare(cppzmq
    GIT_REPOSITORY https://github.com/zeromq/cppzmq
    SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/cppzmq
)

当我构建示例时,我收到以下警告

CMake Warning at build/cppzmq/examples/CMakeLists.txt:13 (find_package):
  By not providing "Findcppzmq.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "cppzmq", but
  CMake did not find one.

Could not find a package configuration file provided by "cppzmq" with any
  of the following names:

    cppzmqConfig.cmake
    cppzmq-config.cmake

  Add the installation prefix of "cppzmq" to CMAKE_PREFIX_PATH or set
  "cppzmq_DIR" to a directory containing one of the above files.  If "cppzmq"
  provides a separate development package or SDK, be sure it has been
  installed.

包似乎已下载到build文件夹。但是,没有编译错误。此警告是否值得关注?CMakelists文件是

cmake_minimum_required(VERSION 3.5)
project(zmqRemoteApi-client-cpp3)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_CXX_STANDARD 17)

find_package(Eigen3 REQUIRED)

if(NOT LIBPLUGIN_DIR)
    if(DEFINED ENV{COPPELIASIM_ROOT_DIR})
        set(LIBPLUGIN_DIR $ENV{COPPELIASIM_ROOT_DIR}/programming/libPlugin)
    else()
        message(FATAL_ERROR "Environment variable COPPELIASIM_ROOT_DIR is not set")
    endif()
endif()
list(APPEND CMAKE_MODULE_PATH
    ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
    ${LIBPLUGIN_DIR}/cmake)
find_package(CoppeliaSim 4.1.0.0 REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Interpreter)

option(GENERATE "Generate wrappers for objects and methods (requires CoppeliaSim to be running)")

include(FetchContent)

FetchContent_Declare(jsoncons
    GIT_REPOSITORY https://github.com/danielaparker/jsoncons
    SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/jsoncons
)
FetchContent_GetProperties(jsoncons)
if(NOT jsoncons_POPULATED)
    FetchContent_Populate(jsoncons)
    #add_subdirectory(${jsoncons_SOURCE_DIR} ${jsoncons_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

FetchContent_Declare(cppzmq
    GIT_REPOSITORY https://github.com/zeromq/cppzmq
    SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/cppzmq
)
FetchContent_GetProperties(cppzmq)
if(NOT cppzmq_POPULATED)
    FetchContent_Populate(cppzmq)
    add_subdirectory(${cppzmq_SOURCE_DIR} ${cppzmq_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated)

add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/calltips.json"
    COMMAND
        ${CMAKE_COMMAND} -E env
        PYTHONPATH="${CMAKE_CURRENT_SOURCE_DIR}/../python"
        ${Python3_EXECUTABLE}
        "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/get_raw_calltips.py"
        "${CMAKE_CURRENT_BINARY_DIR}/generated/calltips.json"
    DEPENDS
        "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/get_raw_calltips.py"
)
add_custom_command(
    OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/constants.json"
    COMMAND
        ${CMAKE_COMMAND} -E env
        PYTHONPATH="${CMAKE_CURRENT_SOURCE_DIR}/../python"
        ${Python3_EXECUTABLE}
        "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/get_constants.py"
        "${CMAKE_CURRENT_BINARY_DIR}/generated/constants.json"
    DEPENDS
        "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/get_constants.py"
)

set(generatedFiles)
file(GLOB templateFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/templates/ ${CMAKE_CURRENT_SOURCE_DIR}/templates/*)
foreach(templateFile ${templateFiles})
    add_custom_command(
        OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/${templateFile}"
        COMMAND
            ${Python3_EXECUTABLE}
            "${LIBPLUGIN_DIR}/simStubsGen/external/pycpp/pycpp.py"
            -p "calltips_json=${CMAKE_CURRENT_BINARY_DIR}/generated/calltips.json"
            -p "constants_json=${CMAKE_CURRENT_BINARY_DIR}/generated/constants.json"
            -i "${CMAKE_CURRENT_SOURCE_DIR}/templates/${templateFile}"
            -o "${CMAKE_CURRENT_BINARY_DIR}/generated/${templateFile}"
            -P "${CMAKE_CURRENT_SOURCE_DIR}/../../tools"
            -P "${CMAKE_CURRENT_SOURCE_DIR}"
        DEPENDS
            "${LIBPLUGIN_DIR}/simStubsGen/external/pycpp/pycpp.py"
            "${CMAKE_CURRENT_SOURCE_DIR}/templates/${templateFile}"
            "${CMAKE_CURRENT_BINARY_DIR}/generated/calltips.json"
            "${CMAKE_CURRENT_BINARY_DIR}/generated/constants.json"
            "${CMAKE_CURRENT_SOURCE_DIR}/cpp_utils.py"
            "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/calltip.py"
            "${CMAKE_CURRENT_SOURCE_DIR}/../../tools/calltip.lark"
    )
    list(APPEND generatedFiles "${CMAKE_CURRENT_BINARY_DIR}/generated/${templateFile}")
endforeach()
add_custom_target(generate_code DEPENDS ${generatedFiles})

add_library(RemoteAPIClient STATIC RemoteAPIClient.cpp)
if(GENERATE)
    add_dependencies(RemoteAPIClient generate_code)
else()
    foreach(templateFile ${templateFiles})
        if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${templateFile}")
            message(FATAL_ERROR "File ${CMAKE_CURRENT_SOURCE_DIR}/${templateFile} is missing")
        endif()
    endforeach()
endif()
target_compile_definitions(RemoteAPIClient PUBLIC -DSIM_REMOTEAPICLIENT_OBJECTS)
target_include_directories(RemoteAPIClient PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/jsoncons/include)
target_include_directories(RemoteAPIClient BEFORE PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/generated)
target_link_libraries(RemoteAPIClient PUBLIC cppzmq)

add_executable(example example.cpp)
target_link_libraries(example PRIVATE RemoteAPIClient)

add_executable(synchronousImageTransmission synchronousImageTransmission.cpp)
target_link_libraries(synchronousImageTransmission PRIVATE RemoteAPIClient)

add_executable(bubbleRobClient bubbleRobClient.cpp)
target_link_libraries(bubbleRobClient PRIVATE RemoteAPIClient)

find_package(OpenCV COMPONENTS core imgproc highgui)
if(OpenCV_FOUND)
    add_executable(opencv opencv.cpp)
    target_include_directories(opencv PRIVATE ${OpenCV_INCLUDE_DIRS})
    target_link_libraries(opencv PRIVATE RemoteAPIClient)
    target_link_libraries(opencv PRIVATE ${OpenCV_LIBS})
endif()

find_package(Qt5 COMPONENTS Core Widgets Gui)
if(Qt5_FOUND)
    add_executable(qt qt.cpp)
    target_link_libraries(qt PRIVATE RemoteAPIClient)
    target_link_libraries(qt PRIVATE Qt5::Widgets)
endif()

我用的是cmake 3.25.2 . Ubuntu 18.04.

lnlaulya

lnlaulya1#

Soooo不包含和构建cppzmq测试和示例,请参见https://github.com/zeromq/cppzmq/blob/master/examples/CMakeLists.txt#L13和https://github.com/zeromq/cppzmq/blob/master/CMakeLists.txt#L104。

cmake_minimum_required(VERSION 3.10)
project(zmqRemoteApi-client-cpp3)
include(FetchContent)
set(CMAKE_CXX_STANDARD 17)

# vvvvvvvvvvvvvvvvvvvvvvvvv this is the important part
set(CPPZMQ_BUILD_TESTS OFF)
# ^^^^^^^^^^^^^^^^^^^^^^^^^

FetchContent_Declare(cppzmq
    GIT_REPOSITORY https://github.com/zeromq/cppzmq
    SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/cppzmq
)
FetchContent_GetProperties(cppzmq)
if(NOT cppzmq_POPULATED)
    FetchContent_Populate(cppzmq)
    add_subdirectory(${cppzmq_SOURCE_DIR} ${cppzmq_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()

相关问题