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 <package>_VERSION output variable to cmake_find_package generator #4257

Conversation

Manu343726
Copy link
Contributor

@Manu343726 Manu343726 commented Jan 9, 2019

Changelog: Feature: Added xxxx_VERSION output variable for cmake_find_package generator. Improved also using find_package_handle_standard_args helper.
Docs: conan-io/docs#1005

This standard find_package() output variable allows users to query
the found library version. Note this variable is defined for requested
packages only, no _VERSION variables are defined for the package
dependencies:

# Example Hello2 package that depends on Hello1 package:
find_package(Hello2 REQUIRED)
message("Found Hello2 v${Hello2_VERSION}")
if(NOT Hello1_VERSION)
    message(WARNING "See? No version variable for dependencies")
endif()

This standard find_package() output variable allows users to query
the found library version. Note this variable is defined for requested
packages only, not _VERSION variables are defined for the package
dependencies.
SET({name}_INCLUDE_DIRS {deps.include_paths})
SET({name}_INCLUDES {deps.include_paths})
SET({name}_DEFINITIONS {deps.defines})
SET({name}_LIBRARIES "") # Will be filled later
SET({name}_LIBRARIES_TARGETS "") # Will be filled later, if CMake 3
SET({name}_LIBS "") # Same as {name}_LIBRARIES

mark_as_advanced({name}_FOUND {name}_INCLUDE_DIRS {name}_INCLUDES
{name}_DEFINITIONS {name}_LIBRARIES {name}_LIBS)
find_package_handle_standard_args({name}
Copy link
Member

Choose a reason for hiding this comment

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

Could this (https://cmake.org/cmake/help/v3.0/module/FindPackageHandleStandardArgs.html) additionally help with the casing of the package names when using this generator or nothing to do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is that more recent versions of cmake mark that FOUND_VARIABLE parameter as obsolete. See for example https://cmake.org/cmake/help/v3.13/module/FindPackageHandleStandardArgs.html which states "This exists only for compatibility with older versions of CMake and is now ignored. Result variables of both names are always set for compatibility."

@lasote lasote self-assigned this Feb 5, 2019
@lasote lasote added this to the 1.13 milestone Feb 5, 2019
@lasote lasote requested a review from memsharded February 5, 2019 13:21
Copy link
Contributor

@lasote lasote left a comment

Choose a reason for hiding this comment

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

Great! Kudos to @Manu343726 er niñol templei

@lasote lasote merged commit 9a1d780 into conan-io:develop Feb 26, 2019
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.

3 participants