ipmcc
ipmcc

Reputation: 29926

Right way to tell CMake to find (n)curses in non-default location?

I have a CMake project that uses FindCurses.cmake. I am on OS X where the OS ships with an older version of ncurses (and doesn't appear to include the C++ bindings) and the code I'm trying to build requires ncurses 5.9. I've used homebrew to install 5.9, but like a good neighbor, homebrew doesn't overwrite the curses/ncurses resources that ship with the OS (nor do I want it to.)

My instinct is that this is something I ought to be able to do without editing the CMake files, right? (Because this change in behavior is specific to my build environment and isn't a change to the project itself, right?) With an autoconf project I would probably add CFLAGS and LDFLAGS environment variables before running ./configure, but CMake seems to have a lot more going on.

What's the idiomatic way to do this in CMake?

Upvotes: 5

Views: 910

Answers (2)

Joel
Joel

Reputation: 2035

You can add in your CMakeLists.txt include_directories and link_directories pointing to your ncurses version.

Also I would try to find if ncurses 5.9 has a pkg-config module. See with pkg-config --list-all.

Upvotes: 1

m.s.
m.s.

Reputation: 16344

You can provide additional search paths through CMAKE_PREFIX_PATH. Paths within CMAKE_PREFIX_PATH are searched first.

You can specify CMAKE_PREFIX_PATH either hardcoded in the CMakeLists.txt file or, preferably, through:

cmake -D CMAKE_PREFIX_PATH=/path/where/brew/installed/curses .

Upvotes: 2

Related Questions