Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] CMake variables without calling conan build #7112

Closed
Mirko-von-Leipzig opened this issue May 28, 2020 · 3 comments · Fixed by #7076
Closed

[question] CMake variables without calling conan build #7112

Mirko-von-Leipzig opened this issue May 28, 2020 · 3 comments · Fixed by #7076
Assignees

Comments

@Mirko-von-Leipzig
Copy link

We use the CMake generator with targets i.e.

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

We keep our conan build as bare bones as possible i.e.

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

This allows us to utilise our IDE's CMake support during development i.e. we can

  1. conan install
  2. use the IDE to re-build / integrate intellisense etc

This works great.
Otherwise we need to call conan build each time, which recompiles and is therefore slow.

We now have a situation where we need to pass optional variables to CMake depending on the configuration. So

    def build(self):
        cmake = CMake(self)
        if condition:
             cmake.definitions["XXX"] = "YYY"
        cmake.configure()
        cmake.build()

but then the logic isn't available for the IDE development work-flow.

Is there an appropriate work-around? I was considering appending the variable to the conanbuildinfo.cmake but I'm not entirely sure there is a post conan install method to do that?

One can obviously do it manually each time, but that's not great.

@memsharded memsharded self-assigned this May 28, 2020
@memsharded
Copy link
Member

Hi @Mirko-von-Leipzig

We are aiming to introduce this as experimental for next release: https://github.com/conan-io/conan/pull/7076/files

It is the "toolchain()" feature. It will allow to generate a toolchain file with your variables for better build-system native integration

@Mirko-von-Leipzig
Copy link
Author

Ah great, thank you!

@memsharded
Copy link
Member

Looking forward to hearing your feedback when it is released :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants