conan-io / cmake-conan

CMake wrapper for conan C and C++ package manager
MIT License
823 stars 250 forks source link

Unable to find "conan_cmake_configure" command in CMake #546

Open alLiucb opened 1 year ago

alLiucb commented 1 year ago

I am using Ubuntu 20.04, Conan 1.60, and CMake 3.19.6. In my CMake project, I am attempting to configure Conan dependencies using conan.cmake. However, when I run CMake, I encounter the following error: -- Downloading conan.cmake from https://github.com/conan-io/cmake-conan CMake Error at cmake/BuildExternalDeps.cmake:22 (conan_cmake_configure): Unknown CMake command "conan_cmake_configure". Call Stack (most recent call first): CMakeLists.txt:39 (include)

Relevant Part of My CMake Script: conan_cmake_configure( REQUIRES zstd/1.5.0 zlib/1.2.11 doctest/2.4.6 pybind11/2.6.2 jsoncpp/1.9.4 nlohmann_json/3.10.2 eigen/3.3.9

boost/1.71.0

    cxxopts/2.2.1
    # glew/2.1.0
    # glfw/3.3.2
    glm/0.9.9.8
    # opencv/3.4.12
    tinyply/2.3.2
    qhullcpp/8.0.2@sxsong1207/stable
    #        cgal/5.0.3
    openmesh/8.1
    openvolumemesh/2.1@sxsong1207/stable
    fmt/8.0.1
    spdlog/1.9.2
    GENERATORS cmake_find_package)
memsharded commented 1 year ago

Hi @AlienLcb

It seems you could be missing or failing in your CMakeLists.txt file(DOWNLOAD or something like that. Please share your CMakeLists.txt so we can check.

In any case, this cmake-conan integration you are using is for 1.X, the recommendation is to move to the new one in the develop2 branch for Conan 2.0

alLiucb commented 1 year ago

this is BuildExternalDeps.cmake:

System Dependencies

if (UNIX) find_package(CGAL REQUIRED) find_package(OpenCV REQUIRED) find_package(GLEW REQUIRED) find_package(glfw3 REQUIRED) else () endif () find_package(PCL REQUIRED COMPONENTS common io octree search filters segmentation) ################

Conan.io

################

Download automatically, you can also just copy the conan.cmake file

if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake") endif ()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_configure( REQUIRES zstd/1.5.0 zlib/1.2.11 doctest/2.4.6 pybind11/2.6.2 jsoncpp/1.9.4 nlohmann_json/3.10.2 eigen/3.3.9

boost/1.71.0

    cxxopts/2.2.1
    # glew/2.1.0
    # glfw/3.3.2
    glm/0.9.9.8
    # opencv/3.4.12
    tinyply/2.3.2
    qhullcpp/8.0.2@sxsong1207/stable
    #        cgal/5.0.3
    openmesh/8.1
    openvolumemesh/2.1@sxsong1207/stable
    fmt/8.0.1
    spdlog/1.9.2
    GENERATORS cmake_find_package)

conan_cmake_autodetect(settings)

conan_cmake_install(PATH_OR_REFERENCE . BUILD missing REMOTE conancenter SETTINGS ${settings})

find_package(glm 0.9.9.8 EXACT REQUIRED) find_package(tinyply 2.3.2 EXACT REQUIRED) find_package(qhullcpp 8.0.2 EXACT REQUIRED) find_package(doctest 2.4.6 EXACT) find_package(jsoncpp 1.9.4 EXACT REQUIRED) find_package(nlohmann_json 3.10.2 EXACT REQUIRED) find_package(OpenMesh 8.1 EXACT REQUIRED) find_package(OpenVolumeMesh 2.1 EXACT REQUIRED) find_package(zstd 1.5.0 EXACT REQUIRED) find_package(ZLIB 1.2.11 EXACT REQUIRED) find_package(Eigen3 3.3.9 EXACT REQUIRED)

find_package(OpenCV 3.4.12 EXACT REQUIRED)

find_package(GLEW 2.1.0 EXACT REQUIRED)

find_package(glfw3 3.3.2 EXACT REQUIRED)

find_package(cxxopts 2.2.1 EXACT REQUIRED) find_package(spdlog 1.9.2 EXACT REQUIRED) find_package(fmt 8.0.1 EXACT REQUIRED) find_package(pybind11 2.6.2 EXACT REQUIRED)

and this is CmakeList.txt: cmake_minimum_required(VERSION 3.5)

Set policies

cmake_policy(SET CMP0072 NEW)

Start Project

project(VVMESH LANGUAGES CXX VERSION 0.8.0)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR}) list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

Compiler traits

if (NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif () set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ version selection") # or 11, 14, 17, 20 set(CMAKE_CXX_STANDARD_REQUIRED ON) # optional, ensure standard is supported set(CMAKE_CXX_EXTENSIONS OFF) # optional, keep compiler extensionsn off set(CMAKE_POSITION_INDEPENDENT_CODE ON) if (WIN32) add_definitions(-D_USE_MATH_DEFINES -DNOMINMAX) endif ()

RPath

set(CMAKE_SKIP_BUILD_RPATH FALSE) set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")

Options

option(BUILD_SHARED_PLUGINS "BUILD Plugins as shared libraries" ON)

###############################

Solve dependencies

include(BuildExternalDeps)

find_package(Threads REQUIRED) find_package(OpenMP) if (OPENMP_FOUND) message("++ Enable OpenMP support") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") add_definitions(-D_USE_OPENMP) set(_USE_OPENMP TRUE) else () message("-- Can't find OpenMP. Continuing without it.") endif ()

if (WIN32) find_package(unofficial-angle CONFIG REQUIRED) find_package(OpenGL REQUIRED COMPONENTS OpenGL) else () find_package(OpenGL REQUIRED COMPONENTS OpenGL EGL) endif ()

if (OPENGL_FOUND) message("++ Enable OpenGL support") include_directories(${OPENGL_INCLUDE_DIR}) add_definitions(${OpenGL_DEFINITIONS}) add_definitions(-D_USE_OPENGL) set(_USE_OPENGL TRUE) else () message("-- Can't find OpenGL. Continuing without it.") endif ()

find_package(CUDA)

if(CUDA_FOUND)

include_directories(${CUDA_INCLUDE_DIRS})

add_definitions(-D_USE_CUDA)

set(_USE_CUDA TRUE)

else()

set(CUDA_CUDA_LIBRARY "")

message("-- Can't find CUDA. Continuing without it.")

endif()

if(QHULL_FOUND) message("++ Enable QHULL support") include_directories(${QHULL_INCLUDE_DIRS}) add_definitions(${QHULL_DEFINITIONS}) endif()

if (Boost_FOUND) message("++ Enable Boost support") include_directories(${Boost_INCLUDE_DIRS}) add_definitions(${Boost_DEFINITIONS} -D_USE_BOOST) link_directories(${Boost_LIBRARY_DIRS}) SET(_USE_BOOST TRUE) endif ()

if (EIGEN_FOUND) message("++ Enable Eigen3 support") include_directories(${EIGEN3_INCLUDE_DIRS}) add_definitions(${EIGEN3_DEFINITIONS}) add_definitions(-D_USE_EIGEN) endif ()

if (PCL_FOUND) message("++ Enable PCL support") include_directories(${PCL_INCLUDE_DIRS}) add_definitions(${PCL_DEFINITIONS}) endif()

if (OpenCV_FOUND) message("++ Enable OpenCV support") include_directories(${opencv_INCLUDE_DIRS}) add_definitions(-D_USE_OPENCV) endif ()

if (spdlog_FOUND) include_directories(${spdlog_INCLUDE_DIRS}) add_definitions(${spdlog_DEFINITIONS}) endif ()

if(fmt_FOUND) include_directories(${fmt_INCLUDE_DIRS}) endif()

Please uncomment following line and supply compressed_streams package

add_definitions(-D_USE_COMPRESSED_STREAMS)

if(jsoncpp_FOUND) message("++ Enable Jsoncpp") include_directories(${jsoncpp_INCLUDE_DIRS}) endif() if (zstd_FOUND) message("++ Enable ZSTDStream Archive Format") add_definitions(-D_USE_ZSTDSTREAM) include_directories(${zstd_INCLUDE_DIRS}) endif () if (ZLIB_FOUND) message("++ Enable GZStream Archive Format") add_definitions(-D_USE_GZSTREAM) endif ()

################### End Dependancy enable_testing()

include_directories(src)

add_subdirectory(src) add_subdirectory(apps)

├─apps │ ├─bundle_packing │ ├─glrender │ ├─simplecamcreator │ ├─visibility_filter │ ├─visibility_network │ │ └─debug │ └─vvtool │ └─pybind11 ├─cmake │ └─conan │ ├─openvolumemesh │ ├─pcl │ ├─qhullcpp │ └─vtk └─src ├─FBORender │ ├─glsl │ └─pybind11 ├─filesystem │ ├─ghc │ └─glob ├─MVArchive │ ├─gzstream │ ├─pybind11 │ └─zstdstream ├─OBJFile │ └─test └─Plugin └─test

memsharded commented 1 year ago

Hi @AlienLcb

The above text is very difficult to read. Could you please try to have a quick read to the Github or markdown docs, and try to format a little bit your message? It should look like something like:

CMakeLists.txt:

# My cmake file
add_library(mylib

Command output:

$ cmake ...
CMake executing...
Cmake doing other thing...