cpp-redis / cpp_redis

C++11 Lightweight Redis client: async, thread-safe, no dependency, pipelining, multi-platform
MIT License
720 stars 199 forks source link

CMP0048 policy warning if used in a project, that uses this policy. #47

Closed jxsl13 closed 1 year ago

jxsl13 commented 5 years ago

cpp-redis & tacopie issue

I'm using this library in a project, that uses CMP0048 NEW policy and getting warnings regarding that:

CMake Error (dev) at src/engine/external/cpp_redis/CMakeLists.txt:41 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    PROJECT_VERSION
    PROJECT_VERSION_MAJOR
    PROJECT_VERSION_MINOR
    PROJECT_VERSION_PATCH
    PROJECT_VERSION_TWEAK
This error is for project developers. Use -Wno-error=dev to suppress it.

CMake Error (dev) at src/engine/external/cpp_redis/tacopie/CMakeLists.txt:41 (project):
  Policy CMP0048 is not set: project() command manages VERSION variables.
  Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  The following variable(s) would be set to empty:

    PROJECT_VERSION
    PROJECT_VERSION_MAJOR
    PROJECT_VERSION_MINOR
    PROJECT_VERSION_PATCH
    PROJECT_VERSION_TWEAK
This error is for project developers. Use -Wno-error=dev to suppress it.

I'm building my project with AppVeyor and it's explicitly handling warnings as errors and turning that off seems to be a bad option security-wise.

A litte bit of googling told me that this might help? https://github.com/Tencent/rapidjson/issues/1154#issuecomment-354762193

if (POLICY CMP0048)
  cmake_policy(SET CMP0048 OLD)
endif()

Edit: https://github.com/SRombauts/SQLiteCpp/issues/184#issue-410282500

It seems to be a bad idea to use POLICY OLD, as it will be deprecated in the future. Setting a proper version number seems to be the correct way to solve this.

lindblandro commented 4 years ago

IMO the whole CMakeLists.txt should be rewritten for newer CMake versions to better support inclusion in other projects. I forked this (and tacopie, which basically duplicates all build files) since I'd like to use this as a submodule. The whole branch is currnetly probably too large for a single merge, cmake_minimum_required() is currently based on what I had on hand, and I didn't have the time to test any Windows builds. Tried an arm cross compile on Yocto and everything went smoothly, though.

I'd like to know if there actually are developers who are forced to use CMake < 3, but still wish to use cpp_redis.