Avoid Macport dependencies on MacOS

I’m trying to build a bundle for MacOS. To do so, I’ve built the project dependencies in some local directory setting the minimal deployment target to 10.12 and do the same for the project itself, hoping to end up with project that depends on my explicitly build dependencies and core MacOS. To do this, I set CMAKE_LIBRARY_PATH and CMAKE_INCLUDE_PATH to the dir I created with dependencies.

The build uses CMake, gcc-10 and Ninja, which I get from Macports. Unfortunately though, it picks e.g., libncurses.dylib from Macports, while I just want it to pick the MacOS version. This is due to pkg-config from Macports. I found a hack to disable pkg-config, but it still finds /opt/local/lib :frowning:

I thought about removing /opt/local/bin from $PATH, but then I get lots of issues due to the Macport tools I want to use.

Does anyone know a good way around this? Right now all I can think of figuring out all the CMake variables it gets wrong and overruling these explicitly. What I would like is "Do not look for libs and include files in /opt/local"

You could also try adding the affected paths into CMAKE_IGNORE_PATH. That doesn’t take a prefix so you’d have to add each individual path (like lib and include), but might work.

Fixed perfectly using (diff snippet)

   set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}
       "${MACOSX_DEPENDENCIES_FROM}/include")
+  set(CMAKE_IGNORE_PATH
+      /opt/local/lib
+      /opt/local/include
+      /opt/local/bin)
 else()

Slightly worrying is that cmake seems to be happy finding gcc and ninja from /opt/local/bin. This is what I want. I’ve excluded /opt/local/bin because I do not want configure to be using Macport’s pkg-config (which indeed CMake doesn’t find).

Thanks!

CMake just finds what is first in your PATH for host tools. You can lower MacPorts’ prevalence in your PATH to avoid this. Or don’t load MacPorts in your iOS development environments (guessing iOS based on your other questions).

1 Like