diff options
author | Brad King <brad.king@kitware.com> | 2018-03-21 17:37:20 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-03-21 17:57:45 (GMT) |
commit | 99bf77f49c18f9947b2386c4f5b6308da793de9f (patch) | |
tree | 52b3cad33b13e8845d52bb4cc6fc52ec0b8b9052 /Source/Checks/Curses.cmake | |
parent | a13cfa246fee1ba99eeecda8b8e8d158d29841df (diff) | |
download | CMake-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.cmake')
-rw-r--r-- | Source/Checks/Curses.cmake | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Source/Checks/Curses.cmake b/Source/Checks/Curses.cmake new file mode 100644 index 0000000..46dc770 --- /dev/null +++ b/Source/Checks/Curses.cmake @@ -0,0 +1,41 @@ +message(STATUS "Checking for curses support") + +# Try compiling a simple project using curses. +# Pass in any cache entries that the user may have set. +set(CMakeCheckCurses_ARGS "") +foreach(v + CURSES_INCLUDE_PATH + CURSES_CURSES_LIBRARY + CURSES_NCURSES_LIBRARY + CURSES_EXTRA_LIBRARY + CURSES_FORM_LIBRARY + ) + if(${v}) + list(APPEND CMakeCheckCurses_ARGS -D${v}=${${v}}) + endif() +endforeach() +file(REMOVE_RECURSE "${CMake_BINARY_DIR}/Source/Checks/Curses-build") +try_compile(CMakeCheckCurses_COMPILED + ${CMake_BINARY_DIR}/Source/Checks/Curses-build + ${CMake_SOURCE_DIR}/Source/Checks/Curses + CheckCurses # project name + CheckCurses # target name + CMAKE_FLAGS + "-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}" + ${CMakeCheckCurses_ARGS} + OUTPUT_VARIABLE CMakeCheckCurses_OUTPUT + ) + +# Covnert result from cache entry to normal variable. +set(CMakeCheckCurses_COMPILED "${CMakeCheckCurses_COMPILED}") +unset(CMakeCheckCurses_COMPILED CACHE) + +if(CMakeCheckCurses_COMPILED) + message(STATUS "Checking for curses support - Success") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Checking for curses support passed with the following output:\n${CMakeCheckCurses_OUTPUT}\n\n") +else() + message(STATUS "Checking for curses support - Failed") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Checking for curses support failed with the following output:\n${CMakeCheckCurses_OUTPUT}\n\n") +endif() |