[CMake] CMake 3.11.3: set properties on the command line?

Paul Smith paul at mad-scientist.net
Mon Dec 17 14:42:37 EST 2018


Hi all.

I'm using cmake with a cross-compiler environment, but building third
party packages that are configured with CMake.  So when I invoke cmake
for those packages I add this options to the command line:

  -DCMAKE_FIND_ROOT_PATH=/my/sysroot

However, this is not working because it's finding 32bit libraries.  For
example if the package's CMakeLists.txt file contains this:

  find_package(ZLIB REQUIRED)

then my link line ends up containing:

  /my/sysroot/usr/lib/libz.so

which is the 32bit version and the link fails.  The 64bit version DOES
exist exactly as it should:

  $ ls -1 /my/sysroot/usr/lib*/libz.so*
  /my/sysroot/tools/usr/lib/libz.so
  /my/sysroot/tools/usr/lib64/libz.so

and the link works if I do it by hand with the right path.  I don't
know why it's not automatically looking for lib64; I checked and CMake
knows I want a 64bit build.  For example I see this after running:

  CMakeFiles/3.11.3/CMakeCXXCompiler.cmake:set(CMAKE_CXX_SIZEOF_DATA_PTR "8")

Actually I wish cmake would just add "-lz" to the command line and let
the linker figure it all out rather than trying to second-guess things.
Then it would "just work".

In any event, if I edit the CMakeLists.txt in the package to set the
global property FIND_LIBRARY_USE_LIB64_PATHS to ON, then it all works
fine:

  set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)

But I can't see any way to set that property from the command line,
without editing the package's CMakeLists.txt file which I obviously
don't want to do.

Help for either (a) figuring out why cmake incorrectly chooses 32bit
libraries or (b) setting the property without editing third-party
CMakeLists.txt files would be much appreciated!!



More information about the CMake mailing list