CMake packaging problem

Hi all! I’m trying to package new versions of foundationdb, here: Comparing NixOS:master...Hjdskes:foundationdb · NixOS/nixpkgs · GitHub

I’ve been able to work my way through some problems, but I am now running into one that I don’t know how to solve. Even though CMake is able to locate openssl (libressl, but I tried with openssl too), it’s failing eventually on

CMake Error at flow/CMakeLists.txt:143 (target_link_libraries):
  Target "flow" links to:

    OpenSSL::SSL

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

I can compile foundationdb locally, outside of nix, just fine. I suspect it’s an interaction between cmake and nix, but I don’t know how to troubleshoot this. Can anyone give me some pointers? I’m afraid I’m not familiar enough with cmake. To be explicit, I am doing this on Apple Silicon, but as I said I can compile locally just fine, so I doubt it’s that.

Looks like CMake uses pkg-config for finding OpenSSL, so you might try adding pkg-config to nativeBuildInputs.

Thanks! That did solve that specific problem. Now I’m running into a similar one, but this time it’s for boost:

CMake Error at cmake/CompileBoost.cmake:121 (target_link_libraries):
  The link interface of target "boost_target" contains:

    Boost::context

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

Call Stack (most recent call first):
  CMakeLists.txt:173 (include)

Since I’ve already added pkg-config to nativeBuildInputs, I’m guessing this is yet another detection failure. I tried setting the options -DBOOST_ROOT=${boost} and -DBoost_USE_STATIC_LIBS=FALSE but to no avail.

This is for both foundationdb 7.0.0 and 7.1.27, who depend on boost172 and boost178 respectively.

Maybe try -DBOOST_ROOT=${boost.dev} since the headers are in a different output?

Thanks for the suggestion, but unfortunately that does not make a difference.

I found that I can enable debug logging for CMake finding Boost using -DBoost_DEBUG:BOOL=ON. Now I see in the logs:

-- Using g++ version of boost::context
-- Found Boost 1.78.0 at /nix/store/p6l3sj29lv195v8glyw9fa64bi7fvyn0-boost-1.78.0-dev/lib/cmake/Boost-1.78.0
--   Requested configuration: QUIET COMPONENTS context
-- BoostConfig: find_package(boost_headers 1.78.0 EXACT CONFIG  QUIET HINTS /nix/store/p6l3sj29lv195v8glyw9fa64bi7fvyn0-boost-1.78.0-dev/lib/cmake)
-- Found boost_headers 1.78.0 at /nix/store/p6l3sj29lv195v8glyw9fa64bi7fvyn0-boost-1.78.0-dev/lib/cmake/boost_headers-1.78.0
-- BoostConfig: find_package(boost_context 1.78.0 EXACT CONFIG  QUIET HINTS /nix/store/p6l3sj29lv195v8glyw9fa64bi7fvyn0-boost-1.78.0-dev/lib/cmake)
-- Found boost_context 1.78.0 at /nix/store/p6l3sj29lv195v8glyw9fa64bi7fvyn0-boost-1.78.0-dev/lib/cmake/boost_context-1.78.0
-- Boost toolset is xgcc11 (GNU 11.3.0)
-- Scanning /nix/store/p6l3sj29lv195v8glyw9fa64bi7fvyn0-boost-1.78.0-dev/lib/cmake/boost_context-1.78.0/libboost_context-variant*.cmake
--   Including /nix/store/p6l3sj29lv195v8glyw9fa64bi7fvyn0-boost-1.78.0-dev/lib/cmake/boost_context-1.78.0/libboost_context-variant-shared.cmake
--   [ ] libboost_context.dylib

To me it looks like it’s able to find boost_context just fine, but that [ ] maybe is a pointer that it isn’t being included? :thinking: