From 303d50c1976f40601c0b35f19f9e6d410a4cac47 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Mon, 6 Nov 2017 12:07:13 -0500 Subject: [PATCH] Use FindCurses.cmake to discover the right way to build with libcurses. --- platform-independent/cli-c/CMakeLists.txt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/platform-independent/cli-c/CMakeLists.txt b/platform-independent/cli-c/CMakeLists.txt index eaecbc3e..ff7377a5 100644 --- a/platform-independent/cli-c/CMakeLists.txt +++ b/platform-independent/cli-c/CMakeLists.txt @@ -40,10 +40,21 @@ function( use_mpw_sodium t r ) endfunction() function( use_mpw_color t ) + find_package( CURSES ) if( USE_COLOR ) - target_link_libraries( ${t} curses) - target_compile_definitions( ${t} PUBLIC -DMPW_COLOR=1 ) - message(STATUS "${t}: USE_COLOR is enabled.") + if ( CURSES_FOUND ) + target_include_directories( ${t} PUBLIC ${CURSES_INCLUDE_DIR} ) + target_link_libraries( ${t} ${CURSES_LIBRARIES} ) + target_compile_definitions( ${t} PUBLIC -DMPW_COLOR=1 ${CURSES_DEFINITIONS} ) + message(STATUS "${t}: USE_COLOR is enabled.") + + elseif( r STREQUAL "required" ) + message(FATAL_ERROR "${t}: USE_COLOR was enabled but is missing libcurses. Please install this library before continuing.") + + else() + message(WARNING "${t}: USE_COLOR was enabled but is missing libcurses. Will continue with USE_COLOR disabled!") + + endif() elseif( r STREQUAL "required" ) message(FATAL_ERROR "${t}: USE_COLOR was required but is not enabled. Please enable the option or remove this target.")