# Avoid Macport dependencies on MacOS

**URL:** https://discourse.cmake.org/t/avoid-macport-dependencies-on-macos/1335
**Category:** Code
**Created:** [June 5, 2020, 1:16pm UTC](https://discourse.cmake.org/t/avoid-macport-dependencies-on-macos/1335 "2020-06-05T13:16:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![JanWielemaker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/janwielemaker/32/438_2.png) [@JanWielemaker](https://discourse.cmake.org/u/JanWielemaker)
#### Post date: [June 5, 2020, 1:16pm UTC](https://discourse.cmake.org/t/avoid-macport-dependencies-on-macos/1335/1 "2020-06-05T13:16:14Z")

</div>

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` ☹

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`"

---

<div class="post-metadata">

### Author: ![sszabo](https://discourse.cmake.org/user_avatar/discourse.cmake.org/sszabo/32/6030_2.png) [@sszabo](https://discourse.cmake.org/u/sszabo)
#### Post date: [June 5, 2020, 2:06pm UTC](https://discourse.cmake.org/t/avoid-macport-dependencies-on-macos/1335/2 "2020-06-05T14:06:02Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![JanWielemaker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/janwielemaker/32/438_2.png) [@JanWielemaker](https://discourse.cmake.org/u/JanWielemaker)
#### Post date: [June 5, 2020, 3:23pm UTC](https://discourse.cmake.org/t/avoid-macport-dependencies-on-macos/1335/3 "2020-06-05T15:23:33Z")

</div>

Fixed perfectly using (diff snippet)

```auto
   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!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [June 8, 2020, 1:03pm UTC](https://discourse.cmake.org/t/avoid-macport-dependencies-on-macos/1335/4 "2020-06-08T13:03:51Z")

</div>

> [@JanWielemaker](#):
>
> Slightly worrying is that cmake seems to be happy finding gcc and ninja from /opt/local/bin.

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).
