Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

macos

cmake

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?

like image 228
ipmcc Avatar asked Oct 20 '22 08:10

ipmcc


1 Answers

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 .
like image 101
m.s. Avatar answered Nov 03 '22 19:11

m.s.