I'll answer myself. As the answer is a little contra intuitive, I'll post it :)
After copying FindPkgConfig.cmake locally and adding a lot of message() to it, I discovered a couple of things: - As FindPkgConfig claims, CMAKE_PREFIX_PATH, etc are added to the search if CMAKE_MINIMUM_REQUIRED_VERSION >= 3.1. Now this was claimed 2.8.12 in my code, but in reality is 3.5. I changed that in the specific subdir to no avail. Also changed it in the main, to my suprise again, to no avail. Only after cheanging it to 3.5 in all subdirs this started working. So, it appears the effective CMAKE_MINIMUM_REQUIRED_VERSION is the lowest of all demanded versions in the entire project. That seems a bit odd to me. I had expected to be per directory or be the _highest_. - FindPkgConfig _does_ add CMAKE_LIBRARY_ARCHITECTURE, but only to the _extra_ directories. As CMAKE_PREFIX_PATH is empty (no special search places except for the CMAKE_LIBRARY_ARCHITECTURE to find the i386 libs), nothing is added. So, this works: set(CMAKE_PREFIX_PATH /usr) set(CMAKE_LIBRARY_ARCHITECTURE i386-linux-gnu) The first set seems very odd :( Possibly a more direct way to add directories to the start/end of the PKG_CONFIG_PATH is more intuitive? Cheers --- Jan On 17/01/2019 13:57, Jan Wielemaker wrote: > Hi, > > I'm trying to build a complicated package for 32-bits on 64-bit Ubuntu. > I got very far using > > set(CMAKE_C_FLAGS -m32) > set(CMAKE_LIBRARY_ARCHITECTURE i386-linux-gnu) > > But right now, find_package(OpenSSL) is failing. I think the problem is > with FindOpenSSL.cmake doing this (Ubuntu 18.04, CMake 3.10): > > if (UNIX) > find_package(PkgConfig QUIET) > pkg_check_modules(_OPENSSL QUIET openssl) > endif () > > Ubuntu has, I think compatibe with the Linux standard, these .pc files > for the multilib installed OpenSSL: > > $ dpkg -L libssl1.0-dev | grep openssl.pc > /usr/lib/x86_64-linux-gnu/pkgconfig/openssl.pc > $ dpkg -L libssl1.0-dev:i386 | grep openssl.pc > /usr/lib/i386-linux-gnu/pkgconfig/openssl.pc > > Should CMake not use CMAKE_LIBRARY_ARCHITECTURE? Is there some neat work > around? Best I can now think of is to create a script pkg-config.i386, > make that set the proper search path and tell CMake to use this script :( > > Thanks --- Jan > > -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: https://cmake.org/mailman/listinfo/cmake