Repository: dankamongmen/notcurses (language: python)

Issue:
CMake on OSX doesn't find pkg-config files from Homebrew
We require several things from Homebrew, but by default CMake doesn't find their `pkg-config` `.pc` files. Homebrews don't appear to install them into any single directory, either; to successfully run CMake, one currently first needs do

`export PKG_CONFIG_PATH=/usr/local/Cellar/ncurses/6.2/lib/pkgconfig:/usr/local//Cellar/readline/8.1/lib/pkgconfig`

i'm sure we're not the first people to need to do this; find the correct way. Maybe we shouldn't be using `pkg-config` for lookup on OS X at all? if anyone happens to know, please do chime in.
CMake on OSX doesn't find pkg-config files from Homebrew
We require several things from Homebrew, but by default CMake doesn't find their `pkg-config` `.pc` files. Homebrews don't appear to install them into any single directory, either; to successfully run CMake, one currently first needs do

`export PKG_CONFIG_PATH=/usr/local/Cellar/ncurses/6.2/lib/pkgconfig:/usr/local//Cellar/readline/8.1/lib/pkgconfig`

i'm sure we're not the first people to need to do this; find the correct way. Maybe we shouldn't be using `pkg-config` for lookup on OS X at all? if anyone happens to know, please do chime in.
CMake on OSX doesn't find pkg-config files from Homebrew
We require several things from Homebrew, but by default CMake doesn't find their `pkg-config` `.pc` files. Homebrews don't appear to install them into any single directory, either; to successfully run CMake, one currently first needs do

`export PKG_CONFIG_PATH=/usr/local/Cellar/ncurses/6.2/lib/pkgconfig:/usr/local//Cellar/readline/8.1/lib/pkgconfig`

i'm sure we're not the first people to need to do this; find the correct way. Maybe we shouldn't be using `pkg-config` for lookup on OS X at all? if anyone happens to know, please do chime in.


Discussion / hints:
If I run:
```
$ brew info ncurses
```
I get:
```
...

ncurses is keg-only... because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

...

For pkg-config to find ncurses you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"

...
```
If I run `brew info readline` I get the same kind of tip re: setting env vars, e.g. `PKG_CONFIG_PATH`.

For better or worse, this is par for the course when building with libraries installed via `brew`.  I will, though, research if there's a "more automatic" way or something re: wiring up `pkg-config` in the context of macOS and `brew`.

Note one thing: it's recommended to use the symlinks in `/usr/local/opt` rather than version-specific paths under `/usr/local/Cellar`.

So your export could be:
```
export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig"
```
You should be able to include defining the PATH for that env var as part of the build process so it can be automated.
@michaelsbradleyjr aye, i mean that would work (and is superior to the version-bound one i have now), but this all smells to me. surely homebrew programs can be made to work without this. perhaps it's because pkg-config isn't the preferred mechanism of working with homebrew libraries, and that's why they aren't usefully installed into a single place? and i should be using something else entirely? this just seems too crappy.
so i notice that e.g. `libavcodec.pc` gets picked up without me doing anything:

```
[cobra-la](1) $ pkg-config --libs libavcodec
-L/usr/local/Cellar/ffmpeg/4.4_2/lib -lavcodec
[cobra-la](0) $ find /usr/ -name libavcodec.pc
/usr//local/lib/pkgconfig/libavcodec.pc
/usr//local/Cellar/ffmpeg/4.4_2/lib/pkgconfig/libavcodec.pc
[cobra-la](1) $   
```

presumably because it gets installed into `/usr/local/lib/pkgconfig`. whereas `readline` does *not* get picked up, and indeed is not installed there:

```
[cobra-la](1) $ pkg-config --libs readline
Package readline was not found in the pkg-config search path.
Perhaps you should add the directory containing `readline.pc'
to the PKG_CONFIG_PATH environment variable
No package 'readline' found
[cobra-la](1) $ find /usr/ -name readline.pc
find: /usr//sbin/authserver: Permission denied
/usr//local/Cellar/readline/8.1/lib/pkgconfig/readline.pc
[cobra-la](1) $ 
```

so is this a bug in the `readline` brew, where it ought be installing to `/usr/local/lib/pkgconfig`? i find that kinda hard to believe, given how many programs rely on libreadline. i mean, readline is everywhere. it really doesn't seem it should be this difficult.

either way, i can find ncurses wtihout any trouble:

```
[cobra-la](2) $ pkg-config --libs ncurses
-lncurses
[cobra-la](0) $ 
```

so the only thing "missing" is readline. i'm tempted to go ahead and whip up a brew with `-DUSE_READLINE=off` to get us in there, and figure this out later, unless @michaelsbradleyjr  you manually symlinked some of these to `/usr/local`, and that's why they're working now (i could have sworn ncurses wasn't working before).
but yeah as pointed out above, it looks like

`export PKG_CONFIG_PATH=/usr/local/opt/readline/lib/pkgconfig/`

ought be enough to get everything working.
oh ok ncurses is being found because it's

```
[cobra-la](1) $ pkg-config --modversion ncurses
5.7.20081102
[cobra-la](0) $ 
```
so yeah it looks like the best we have thus far is

`export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig"`

as provided by @michaelsbradleyjr above. which i guess i'm fine with, if that's truly the best we can do, but is that kind of grotesquery going to be allowed in a brew?
[![we're the brews](http://img.youtube.com/vi/KdqEbdglqhI/0.jpg)](http://www.youtube.com/watch?v=KdqEbdglqhI "we're the brews")
> as provided by @michaelsbradleyjr above. which i guess i'm fine with, if that's truly the best we can do, but is that kind of grotesquery going to be allowed in a brew?

I'm not sure. I'll have to do some more research.
If I run:
```
$ brew info ncurses
```
I get:
```
...

ncurses is keg-only... because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

...

For pkg-config to find ncurses you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"

...
```
If I run `brew info readline` I get the same kind of tip re: setting env vars, e.g. `PKG_CONFIG_PATH`.

For better or worse, this is par for the course when building with libraries installed via `brew`.  I will, though, research if there's a "more automatic" way or something re: wiring up `pkg-config` in the context of macOS and `brew`.

Note one thing: it's recommended to use the symlinks in `/usr/local/opt` rather than version-specific paths under `/usr/local/Cellar`.

So your export could be:
```
export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig"
```
You should be able to include defining the PATH for that env var as part of the build process so it can be automated.
@michaelsbradleyjr aye, i mean that would work (and is superior to the version-bound one i have now), but this all smells to me. surely homebrew programs can be made to work without this. perhaps it's because pkg-config isn't the preferred mechanism of working with homebrew libraries, and that's why they aren't usefully installed into a single place? and i should be using something else entirely? this just seems too crappy.
so i notice that e.g. `libavcodec.pc` gets picked up without me doing anything:

```
[cobra-la](1) $ pkg-config --libs libavcodec
-L/usr/local/Cellar/ffmpeg/4.4_2/lib -lavcodec
[cobra-la](0) $ find /usr/ -name libavcodec.pc
/usr//local/lib/pkgconfig/libavcodec.pc
/usr//local/Cellar/ffmpeg/4.4_2/lib/pkgconfig/libavcodec.pc
[cobra-la](1) $   
```

presumably because it gets installed into `/usr/local/lib/pkgconfig`. whereas `readline` does *not* get picked up, and indeed is not installed there:

```
[cobra-la](1) $ pkg-config --libs readline
Package readline was not found in the pkg-config search path.
Perhaps you should add the directory containing `readline.pc'
to the PKG_CONFIG_PATH environment variable
No package 'readline' found
[cobra-la](1) $ find /usr/ -name readline.pc
find: /usr//sbin/authserver: Permission denied
/usr//local/Cellar/readline/8.1/lib/pkgconfig/readline.pc
[cobra-la](1) $ 
```

so is this a bug in the `readline` brew, where it ought be installing to `/usr/local/lib/pkgconfig`? i find that kinda hard to believe, given how many programs rely on libreadline. i mean, readline is everywhere. it really doesn't seem it should be this difficult.

either way, i can find ncurses wtihout any trouble:

```
[cobra-la](2) $ pkg-config --libs ncurses
-lncurses
[cobra-la](0) $ 
```

so the only thing "missing" is readline. i'm tempted to go ahead and whip up a brew with `-DUSE_READLINE=off` to get us in there, and figure this out later, unless @michaelsbradleyjr  you manually symlinked some of these to `/usr/local`, and that's why they're working now (i could have sworn ncurses wasn't working before).
but yeah as pointed out above, it looks like

`export PKG_CONFIG_PATH=/usr/local/opt/readline/lib/pkgconfig/`

ought be enough to get everything working.
oh ok ncurses is being found because it's

```
[cobra-la](1) $ pkg-config --modversion ncurses
5.7.20081102
[cobra-la](0) $ 
```
so yeah it looks like the best we have thus far is

`export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig"`

as provided by @michaelsbradleyjr above. which i guess i'm fine with, if that's truly the best we can do, but is that kind of grotesquery going to be allowed in a brew?
[![we're the brews](http://img.youtube.com/vi/KdqEbdglqhI/0.jpg)](http://www.youtube.com/watch?v=KdqEbdglqhI "we're the brews")
> as provided by @michaelsbradleyjr above. which i guess i'm fine with, if that's truly the best we can do, but is that kind of grotesquery going to be allowed in a brew?

I'm not sure. I'll have to do some more research.
If I run:
```
$ brew info ncurses
```
I get:
```
...

ncurses is keg-only... because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

...

For pkg-config to find ncurses you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"

...
```
If I run `brew info readline` I get the same kind of tip re: setting env vars, e.g. `PKG_CONFIG_PATH`.

For better or worse, this is par for the course when building with libraries installed via `brew`.  I will, though, research if there's a "more automatic" way or something re: wiring up `pkg-config` in the context of macOS and `brew`.

Note one thing: it's recommended to use the symlinks in `/usr/local/opt` rather than version-specific paths under `/usr/local/Cellar`.

So your export could be:
```
export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig"
```
You should be able to include defining the PATH for that env var as part of the build process so it can be automated.
@michaelsbradleyjr aye, i mean that would work (and is superior to the version-bound one i have now), but this all smells to me. surely homebrew programs can be made to work without this. perhaps it's because pkg-config isn't the preferred mechanism of working with homebrew libraries, and that's why they aren't usefully installed into a single place? and i should be using something else entirely? this just seems too crappy.
so i notice that e.g. `libavcodec.pc` gets picked up without me doing anything:

```
[cobra-la](1) $ pkg-config --libs libavcodec
-L/usr/local/Cellar/ffmpeg/4.4_2/lib -lavcodec
[cobra-la](0) $ find /usr/ -name libavcodec.pc
/usr//local/lib/pkgconfig/libavcodec.pc
/usr//local/Cellar/ffmpeg/4.4_2/lib/pkgconfig/libavcodec.pc
[cobra-la](1) $   
```

presumably because it gets installed into `/usr/local/lib/pkgconfig`. whereas `readline` does *not* get picked up, and indeed is not installed there:

```
[cobra-la](1) $ pkg-config --libs readline
Package readline was not found in the pkg-config search path.
Perhaps you should add the directory containing `readline.pc'
to the PKG_CONFIG_PATH environment variable
No package 'readline' found
[cobra-la](1) $ find /usr/ -name readline.pc
find: /usr//sbin/authserver: Permission denied
/usr//local/Cellar/readline/8.1/lib/pkgconfig/readline.pc
[cobra-la](1) $ 
```

so is this a bug in the `readline` brew, where it ought be installing to `/usr/local/lib/pkgconfig`? i find that kinda hard to believe, given how many programs rely on libreadline. i mean, readline is everywhere. it really doesn't seem it should be this difficult.

either way, i can find ncurses wtihout any trouble:

```
[cobra-la](2) $ pkg-config --libs ncurses
-lncurses
[cobra-la](0) $ 
```

so the only thing "missing" is readline. i'm tempted to go ahead and whip up a brew with `-DUSE_READLINE=off` to get us in there, and figure this out later, unless @michaelsbradleyjr  you manually symlinked some of these to `/usr/local`, and that's why they're working now (i could have sworn ncurses wasn't working before).
but yeah as pointed out above, it looks like

`export PKG_CONFIG_PATH=/usr/local/opt/readline/lib/pkgconfig/`

ought be enough to get everything working.
oh ok ncurses is being found because it's

```
[cobra-la](1) $ pkg-config --modversion ncurses
5.7.20081102
[cobra-la](0) $ 
```
so yeah it looks like the best we have thus far is

`export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig"`

as provided by @michaelsbradleyjr above. which i guess i'm fine with, if that's truly the best we can do, but is that kind of grotesquery going to be allowed in a brew?
[![we're the brews](http://img.youtube.com/vi/KdqEbdglqhI/0.jpg)](http://www.youtube.com/watch?v=KdqEbdglqhI "we're the brews")
> as provided by @michaelsbradleyjr above. which i guess i'm fine with, if that's truly the best we can do, but is that kind of grotesquery going to be allowed in a brew?

I'm not sure. I'll have to do some more research.

Fix patch:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9aab6a2598..cc12897bdd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -63,6 +63,13 @@ endif()
 
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
 set(PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+elseif(APPLE)
+# surely there's a better way to do this? alas, seems necessary to pull the
+# pkg-config files out of Homebrew.
+if(NOT DEFINED ENV{PKG_CONFIG_PATH})
+set(ENV{PKG_CONFIG_PATH} "/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig")
+endif()
+set(PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
 else()
 set(PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig")
 endif()


Test patch:
diff --git a/.github/workflows/macos_test.yml b/.github/workflows/macos_test.yml
index 888928828c..fbf0566202 100644
--- a/.github/workflows/macos_test.yml
+++ b/.github/workflows/macos_test.yml
@@ -47,7 +47,6 @@ jobs:
 
       - name: cmake
         run: |
-          export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig"
           mkdir build && cd build
           cmake .. \
             -DCMAKE_BUILD_TYPE=Release \