添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

[question] Problems combining Conan packages with CMake External Project #7636

Closed
@akalali

Description

I'm currently trying to migrate our dependency handling to use Conan as package manager. Previously we were using CMake and external project.
My idea was to start with an already existing recipe to have a quick proof of concept. I chose DCMTK as a first package.
The packaging is done using CMake Conan .
However, I want to test this first before I switch to Conan recipes for all dependencies. Also, I need to write some recipes on my own (and will hopefully provide them at the Conan center ) but I would like to do this step by step.
The consequence is that I have a single Conan package while other dependencies are still created using CMake External Project.

For example, we are depending on DCMQI , which itself is dependent on DCMTK. And here is the problem that I have:
In my top-level CMakeLists.txt -file I use the mentioned CMake Conan wrapper to define my dependency to DCMTK and the CMake generators, which looks something like this:

include(${CMAKE_BINARY_DIR}/Conan/conan.cmake)
conan_cmake_run(REQUIRES dcmtk/3.6.5
				BASIC_SETUP
				CMAKE_TARGETS
				GENERATORS cmake_find_package cmake_paths
				OPTIONS ${CONAN_OPTIONS}
				BUILD missing

This installs the required package (with transitive dependency openjpeg) and creates some output files, like conan_paths.cmake, conanbuildinfo.cmake, FindDCMTK.cmake and some more. The result is, that I can use

find_package(DCMTK)
if(TARGET DCMTK::DCMTK)
endif()

where the condition is true.

This is done before the superbuild starts. After installing Conan packages I include my SuperBuild.cmake, which again includes something like CMakeExternals/DCMQI.cmake. This file does nothing more than calling

ExternalProject_Add(DCMQI

with DEPENDS DCMTK::DCMTK.

What happens now is that I get the following error message:

Make Error at CMakeLists.txt:271 (find_package):
Could not find a package configuration file provided by "DCMTK" with any of the following names:
    DCMTKConfig.cmake
    dcmtk-config.cmake
  Add the installation prefix of "DCMTK" to CMAKE_PREFIX_PATH or set
  "DCMTK_DIR" to a directory containing one of the above files.  If "DCMTK"
  provides a separate development package or SDK, be sure it has been
  installed.
-- Configuring incomplete, errors occurred!

The relevant file / line is here.

So I was hoping that DCMQI uses the FindDCMTK.cmake that was automatically created by Conan but I don't know how to point DCMQI to this file. In our current setup we have a customized FindDCMTK.cmake but CMake also provides a FindDCMTK.cmake.
Here a DCMTK_DIR is defined.

I found DCMTKConfig.cmake inside .conan/data/dcmtk/3.6.5/_/_/build/a77c0a86db5a3776d765c3fb20cfeda3833b0e78\build_subfolder and hard-coding this path also makes the error go away.
But using fixed paths is not an option. I was trying to find a variable created by Conan (inside FindDCMTK.cmake) that would allow me to point DCMQI to DCMTKConfig.cmake but all I see is variables pointing to .conan/data/dcmtk/3.6.5/_/_/package/a77c0a86db5a3776d765c3fb20cfeda3833b0e78/ (package instead of build).

I'm missing some insights here and would like to understand how to resolve this error and what the different package directories are used for (build and package).
Also I would like to know why DCMTK_DIR needs to be set and why the Conan-created FindDCMTK.cmake does not set the variable.

To make things more clear I will probably push the code I have so far this week and post a link to the repository here.

  • I've read the CONTRIBUTING guide.
  •