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

Add 'cpp_info.<config>' information to 'cmake_find_package[_multi]' generators #6230

merged 7 commits into from Dec 20, 2019


Copy link

@jgsogo jgsogo commented Dec 13, 2019

Changelog: Fix: Add cpp_info.<config> information to cmake_find_package_multi and cmake_find_package generators.
Docs: conan-io/docs#1508

  • At least update docs at "Note" here

Closes #6136

When a recipe contains information specific per configuration:

class Requirement(ConanFile):
    name = "requirement"
    version = "version"
    settings = "os", "arch", "compiler", "build_type"
    def package_info(self):
        self.cpp_info.libs = ["lib_both"]
        self.cpp_info.debug.libs = ["lib_debug"]
        self.cpp_info.release.libs = ["lib_release"]
        self.cpp_info.cxxflags = ["-req_both"]
        self.cpp_info.debug.cxxflags = ["-req_debug"]
        self.cpp_info.release.cxxflags = ["-req_release"]

this information is now propagated to the corresponding build-type file (see tests)

@jgsogo jgsogo added this to the 1.22 milestone Dec 16, 2019
@jgsogo jgsogo self-assigned this Dec 16, 2019
Copy link
Member Author

@jgsogo jgsogo commented Dec 16, 2019

  • Order matters, who has precedence?

Check behavior of other generators:

CMake plain generators:

  • cmake + TARGETS:

                                                                  $<$<CONFIG:Release>:${CONAN_C_FLAGS_REQUIREMENT_RELEASE_LIST} ${CONAN_CXX_FLAGS_REQUIREMENT_RELEASE_LIST}>
                                                                  $<$<CONFIG:RelWithDebInfo>:${CONAN_C_FLAGS_REQUIREMENT_RELWITHDEBINFO_LIST} ${CONAN_CXX_FLAGS_REQUIREMENT_RELWITHDEBINFO_LIST}>
                                                                  $<$<CONFIG:MinSizeRel>:${CONAN_C_FLAGS_REQUIREMENT_MINSIZEREL_LIST} ${CONAN_CXX_FLAGS_REQUIREMENT_MINSIZEREL_LIST}>
                                                                  $<$<CONFIG:Debug>:${CONAN_C_FLAGS_REQUIREMENT_DEBUG_LIST}  ${CONAN_CXX_FLAGS_REQUIREMENT_DEBUG_LIST}>)
  • cmake without TARGETS: it lets CMake use its defaults:

    macro(conan_set_flags build_type)
        set(CMAKE_CXX_FLAGS${build_type} "${CMAKE_CXX_FLAGS${build_type}} ${CONAN_CXX_FLAGS${build_type}}")
        set(CMAKE_C_FLAGS${build_type} "${CMAKE_C_FLAGS${build_type}} ${CONAN_C_FLAGS${build_type}}")
        set(CMAKE_SHARED_LINKER_FLAGS${build_type} "${CMAKE_SHARED_LINKER_FLAGS${build_type}} ${CONAN_SHARED_LINKER_FLAGS${build_type}}")
        set(CMAKE_EXE_LINKER_FLAGS${build_type} "${CMAKE_EXE_LINKER_FLAGS${build_type}} ${CONAN_EXE_LINKER_FLAGS${build_type}}")

    There will be CMAKE_CXX_FLAGS, CMAKE_CXX_FLAGS_DEBUG and CMAKE_CXX_FLAGS_RELEASE, each one with its own variables.

  • cmake_multi, generates only CONAN_*****_RELEASE/DEBUG variables, appending the Release/Debug info to the general one:

    set(CONAN_CXX_FLAGS_REQUIREMENT_RELEASE "-req_both -req_release")

    Then it uses the same TARGETS population and/or the same conan_set_flags function.

CMake find_package generators:

  • cmake_find_package: doesn't use Release/Debug information
  • cmake_find_package_multi: idem

@jgsogo jgsogo changed the title Add 'cpp_info.<config>' information to 'cmake_find_package_multi' generator content Add 'cpp_info.<config>' information to 'cmake_find_package[_multi]' generators Dec 16, 2019
@jgsogo jgsogo marked this pull request as ready for review Dec 16, 2019
@jgsogo jgsogo requested a review from memsharded Dec 16, 2019
Copy link

@memsharded memsharded left a comment

Looks perfect, can be merged.

@jgsogo jgsogo assigned lasote and unassigned jgsogo Dec 18, 2019
lasote approved these changes Dec 20, 2019
Copy link

@lasote lasote left a comment

Add docs and merge

@lasote lasote assigned jgsogo and unassigned lasote Dec 20, 2019
@jgsogo jgsogo merged commit ae282c4 into conan-io:develop Dec 20, 2019
2 checks passed
@jgsogo jgsogo deleted the fix/cmake_find_package-propagation branch Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

3 participants