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

Added [buildenv] Field Generation #554

Open
wants to merge 1 commit into
base: develop2
Choose a base branch
from

Conversation

jelin-sh
Copy link

@jelin-sh jelin-sh commented Sep 5, 2023

Modified the detect_host_profile function in conan_provider.cmake to support the generation of the [buildenv] field. This enhancement allows for a closer integration with the compilers configured in CMake, thereby improving usability for cross-compilation and cross-platform scenarios.

@CLAassistant
Copy link

CLAassistant commented Sep 5, 2023

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@memsharded memsharded left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @skjsnb

We need to check what would be the best, most general approach to this, but I think it is worth to pursue this improvement.

Comment on lines +206 to +209
string(APPEND PROFILE "[buildenv]\n")
string(APPEND PROFILE "CC=${CMAKE_C_COMPILER}\n")
string(APPEND PROFILE "CXX=${CMAKE_CXX_COMPILER}\n")
string(APPEND PROFILE "LD=${CMAKE_LINKER}\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now Conan provides a compiler_executables configuration that might be a better mechanism to define this (it can work even with build systems that will not listen to CC/CXX env-vars). Setting the env-vars might not be necessarily bad, but we need to discuss the best approach.

@memsharded memsharded added this to the cmake-conan2-0.1 milestone Sep 5, 2023
@jcar87
Copy link
Contributor

jcar87 commented Sep 22, 2023

Please note that as of #566 - the compiler_executables configuration variable is set and propagated - this should negate the need for CC and CXX. Note that this needs CMake to be aware of both compilers (which is not always the case), so requires both to be specified (either by defining CMAKE_<LANG>_COMPILER, or letting CMake find it if it is defined as a language in the project() call or an enable_language().

The linker is more tricky - since in a lot of scenarios CMake performs linking via the compiler, and CMAKE_LINKER is, to the best of my knowledge, not documented. For cases where it is necessary to define these (via [buildenv] or similar, I would suggest looking at the just-merged feature of customizing the profile:
https://github.com/conan-io/cmake-conan/tree/develop2#customizing-conan-profiles

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 this pull request may close these issues.

4 participants