aws-sdk-cpp icon indicating copy to clipboard operation
aws-sdk-cpp copied to clipboard

cmake: don't set PACKAGE_VERSION in Config.cmake

Open flixr opened this issue 6 years ago • 10 comments

don't include the ConfigVersion.cmake in Config.cmake as this sets e.g. PACKAGE_VERSION in other projects find_package-ing AWSSDK.

Use AWSDK_VERSION for printing the found version instead it is supposed to be.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

flixr avatar Mar 01 '19 13:03 flixr

friendly ping...

flixr avatar Apr 07 '19 23:04 flixr

ping...

flixr avatar Apr 28 '20 16:04 flixr

Hi @flixr I was looking into the PR, and it seems from CMake doc: https://cmake.org/cmake/help/latest/command/find_package.html#version-selection The PACKAGE_VERSION is not alive after find_packaging. Can you provide a short code-sample showing the bug?

sdavtaker avatar Aug 18 '21 16:08 sdavtaker

The PACKAGE_VERSION is not alive after find_packaging.

Unless you explicitly include the version file in the config file... which you should you not do and is not needed.

A minimal sample showing this should look something like this:

cmake_minimum_required (VERSION 3.1)

project(my_project 1.0)

find_package(AWSSDK REQUIRED COMPONENTS transfer)

message(STATUS "my_project version: ${PROJECT_VERSION}")

Now PROJECT_VERSION is not the version of my_project, but of the AWSSDK

flixr avatar Aug 19 '21 08:08 flixr

https://github.com/aws/aws-sdk-cpp/issues/1888

jmklix avatar Apr 22 '22 18:04 jmklix

To be precise, project(<project_name> VERSION <version>) sets PROJECT_VERSION.

Meanwhile, find_package(AWSSDK) sets an unrelated PACKAGE_VERSION, which it sets globally.

It does make sense to rename it to AWSSDK_VERSION, but it does not conflict with PROJECT_VERSION.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.5)

project(my_project VERSION 1.1)

message(STATUS "PACKAGE_VERSION: ${PACKAGE_VERSION}")
message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}")

find_package(AWSSDK REQUIRED s3)

message(STATUS "PACKAGE_VERSION: ${PACKAGE_VERSION}")
message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}")

find_package(PkgConfig)

message(STATUS "PACKAGE_VERSION: ${PACKAGE_VERSION}")
message(STATUS "PROJECT_VERSION: ${PROJECT_VERSION}")

Output:

$ cmake . -DCMAKE_PREFIX_PATH=/where/aws-sdk-cpp/is/installed

-- The C compiler identification is GNU 11.2.1
-- The CXX compiler identification is GNU 11.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- PACKAGE_VERSION:
-- PROJECT_VERSION: 1.1
-- Found AWS SDK for C++, Version: 1.9.234, Install Root:/opt/aws, Platform Prefix:, Platform Dependent Libraries: pthread;crypto;ssl;z;curl
-- Components specified for AWSSDK: s3, application will be depending on libs: aws-cpp-sdk-s3;aws-cpp-sdk-core;aws-crt-cpp;aws-c-auth;aws-c-cal;aws-c-common;aws-c-compression;aws-c-event-stream;aws-c-http;aws-c-io;aws-c-mqtt;aws-c-s3;aws-checksums;pthread;crypto;ssl;z;curl
-- Try finding aws-cpp-sdk-core
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found LibCrypto: /usr/lib/libcrypto.so
-- LibCrypto Include Dir: /usr/include
-- LibCrypto Shared Lib:  /usr/lib/libcrypto.so
-- LibCrypto Static Lib:  /usr/lib/libcrypto.so

... [ more output ]

-- LibCrypto Shared Lib:  /usr/lib/libcrypto.so
-- LibCrypto Static Lib:  /usr/lib/libcrypto.so
-- Found aws-cpp-sdk-core
-- Try finding aws-cpp-sdk-s3
-- Found aws-cpp-sdk-s3
-- PACKAGE_VERSION: 1.9.234
-- PROJECT_VERSION: 1.1
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.0")
-- PACKAGE_VERSION: 1.9.234
-- PROJECT_VERSION: 1.1
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/work

specious avatar Aug 19 '22 19:08 specious

Actually, AWSSDK_VERSION is also being set, as this will show:

cmake_minimum_required(VERSION 3.5)

project(my_project)

find_package(AWSSDK)
message(STATUS "AWSSDK_VERSION: ${AWSSDK_VERSION}") 

specious avatar Aug 19 '22 20:08 specious

yes, and to not set PACKAGE_VERSION globally (which was only used to print the AWSSDK_VERSION), the config version file should not be included in the config file. That is fixed by this PR

flixr avatar Aug 24 '22 06:08 flixr

https://github.com/aws/aws-sdk-cpp/blob/e4b4b310d8631bc7e9a797b6ac03a73c6f210bf6/cmake/AWSSDKConfig.cmake#L27

I can't seem to figure out where this .cmake file actually comes from.

specious avatar Aug 24 '22 12:08 specious

IIRC this is automatically created by cmake and this should not be include in the XConfig.cmake file

flixr avatar Aug 24 '22 13:08 flixr

@specious can this be merged? The the version file should not be included and it's not needed... the only var that is used from there is PROJECT_VERSION and that is only used to print the message.

With the current CMake config file it messes up any project where we find_packge awssdk!

flixr avatar Jan 25 '23 16:01 flixr

I'm not a maintainer of this project and I'm not sure what the correct decision would be.

specious avatar Jan 26 '23 23:01 specious

@sdavtaker , could you pleas take a look at this PR?

SergeyRyabinin avatar Jan 26 '23 23:01 SergeyRyabinin