summaryrefslogtreecommitdiffstats
path: root/Source/Checks/Curses
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-21 17:37:20 (GMT)
committerBrad King <brad.king@kitware.com>2018-03-21 17:57:45 (GMT)
commit99bf77f49c18f9947b2386c4f5b6308da793de9f (patch)
tree52b3cad33b13e8845d52bb4cc6fc52ec0b8b9052 /Source/Checks/Curses
parenta13cfa246fee1ba99eeecda8b8e8d158d29841df (diff)
downloadCMake-99bf77f49c18f9947b2386c4f5b6308da793de9f.zip
CMake-99bf77f49c18f9947b2386c4f5b6308da793de9f.tar.gz
CMake-99bf77f49c18f9947b2386c4f5b6308da793de9f.tar.bz2
ccmake: Check for curses more robustly before enabling
Compute a default for `BUILD_CursesDialog` by building a small test project that uses curses. Disable `ccmake` by default if it fails, and do not search for Curses as part of the main build. This avoids creating FindCurses cache entries when we are not considering ccmake. If `BUILD_CursesDialog` is enabled (e.g. by the user) then warn if curses cannot be found.
Diffstat (limited to 'Source/Checks/Curses')
-rw-r--r--Source/Checks/Curses/CMakeLists.txt25
-rw-r--r--Source/Checks/Curses/CheckCurses.c15
2 files changed, 40 insertions, 0 deletions
diff --git a/Source/Checks/Curses/CMakeLists.txt b/Source/Checks/Curses/CMakeLists.txt
new file mode 100644
index 0000000..17318a3
--- /dev/null
+++ b/Source/Checks/Curses/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.1)
+if(POLICY CMP0060)
+ cmake_policy(SET CMP0060 NEW)
+endif()
+project(CheckCurses C)
+
+set(CURSES_NEED_NCURSES TRUE)
+find_package(Curses)
+if(NOT CURSES_FOUND)
+ return()
+endif()
+include_directories(${CURSES_INCLUDE_DIRS})
+add_executable(CheckCurses CheckCurses.c)
+target_link_libraries(CheckCurses ${CURSES_LIBRARIES})
+
+foreach(h
+ CURSES_HAVE_CURSES_H
+ CURSES_HAVE_NCURSES_H
+ CURSES_HAVE_NCURSES_NCURSES_H
+ CURSES_HAVE_NCURSES_CURSES_H
+ )
+ if(${h})
+ target_compile_definitions(CheckCurses PRIVATE ${h})
+ endif()
+endforeach()
diff --git a/Source/Checks/Curses/CheckCurses.c b/Source/Checks/Curses/CheckCurses.c
new file mode 100644
index 0000000..857ae28
--- /dev/null
+++ b/Source/Checks/Curses/CheckCurses.c
@@ -0,0 +1,15 @@
+#if defined(CURSES_HAVE_NCURSES_H)
+#include <ncurses.h>
+#elif defined(CURSES_HAVE_NCURSES_NCURSES_H)
+#include <ncurses/ncurses.h>
+#elif defined(CURSES_HAVE_NCURSES_CURSES_H)
+#include <ncurses/curses.h>
+#else
+#include <curses.h>
+#endif
+
+int main()
+{
+ curses_version();
+ return 0;
+}