conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.17k stars 974 forks source link

[question] how to get build directory after running conan create so that I can run ctest? #16414

Open wuziq opened 4 months ago

wuziq commented 4 months ago

What is your question?

After running conan create, I'd like to run ctest. I need the cmake cache directory for this. conan cache path is close, but it doesn't give me the build directory. Am I missing something?

Have you read the CONTRIBUTING guide?

memsharded commented 3 months ago

Hi @wuziq

Thanks for your question.

This is not generally how it works. If you run conan create the package is created, only the public headers are available, for example. The way to run unittests is generally within the package creation process, while building the package, like in the recipe:

def build(self):
    cmake = CMake(self)
    cmake.configure()
    cmake.build()
    cmake.ctest()

Note that there is also cmake.test() to run them from the target, not from ctest, and there is the tools.build:skip_test configuration, that you can set to True to disable/skip the building and execution of tests when you want to skip them.

memsharded commented 1 month ago

Hi @wuziq

Any further question or issue here? May we close the ticket? Thanks for the feedback!