ilya
ilya

Reputation: 1133

Connecting Conan package with ordinary Qt directory

I've studied creating package in the official Conan tutorial. I'd like to create my own package for a static library (CMake-based project). It supports Linux and Windows. But it depends on Qt LTS 5.9x. CMakeLists.txt contains a call to find_package. Usually I passed

-DCMAKE_PREFIX_PATH=path_to_qt_cmake_modules

to cmake utility. Conan has no official Qt 5.9 support. What is the correct way to pass CMAKE_PREFIX_PATH to conan during package install?

Upvotes: 0

Views: 807

Answers (1)

drodri
drodri

Reputation: 5972

If you are using the CMake helper you can define any cmake variable in the build() method:

from conans import ConanFile, CMake

class ExampleConan(ConanFile):
    ...

    def build(self):
        cmake = CMake(self)
        cmake.definitions["CMAKE_PREFIX_PATH"] = <your-prefix-path>
        cmake.configure()
        cmake.build()
        cmake.install() # Build --target=install

If you want a parameterizable path to your Qt local install, you can use normal env-vars. They can be defined in the system, but for convenience they can also be defined in your profile:

[settings]
...
[env]
QT_PATH=my/path/to/qt

And then use something like:

cmake.definitions["CMAKE_PREFIX_PATH"] = os.environ["QT_PATH"]

Upvotes: 1

Related Questions