cellml / libcellml

Repository for libCellML development.
https://libcellml.org
Apache License 2.0
16 stars 21 forks source link

CMake: allow zlib to be found using ZLIB_ROOT #975

Closed agarny closed 2 years ago

agarny commented 2 years ago

If we want to tell CMake where to look for zlib, we can pass ZLIB_ROOT to it. However, this results in the following CMake warning:

CMake Warning (dev) at cmake/environmentchecks.cmake:147 (find_package):
  Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
  Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  CMake variable ZLIB_ROOT is set to:

    /Users/Alan/libOpenCOR/build/zlib

  For compatibility, CMake is ignoring the variable.
Call Stack (most recent call first):
  CMakeLists.txt:40 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.
nickerso commented 2 years ago

you shouldn't be using ZLIB_ROOT right? isn't it ZLIB_DIR ? and in general I don't even set it as it is picked up in the config dependencies for libXml2...

agarny commented 2 years ago

Apparently, you can (see here). Different libraries can be found in different ways with CMake (!!). For libxml2, you can help CMake to find it by passing LIBXML2_INCLUDE_DIR and LIBXML2_LIBRARY to it (see here).

The reason I need this is that for libOpenCOR, I want to use "my" copy of the dependencies.

agarny commented 2 years ago

FTR, I appreciate that one might prefer to use the XxxConfig.cmake to configure Xxx, but such a file is not always available (e.g., it's not for the zlib implementation that I use in libOpenCOR). In fact, even if there was to be such a file, I couldn't use it since I build libCellML using ExternalProject_Add(). So, all I can do is to pass it some CMake arguments and this is where ZLIB_ROOT comes in as being very handy.