summaryrefslogtreecommitdiffstats
path: root/Source/Checks/Curses.cmake
blob: d35dd2a6e1ef6d51c51f8a6ddb88e1c69ec9e867 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
include(${CMAKE_CURRENT_LIST_DIR}/cm_message_checks_compat.cmake)
cm_message_checks_compat(
  "Checking for curses support" __checkStart __checkPass __checkFail)
message(${__checkStart})

# 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
  )

# Convert result from cache entry to normal variable.
set(CMakeCheckCurses_COMPILED "${CMakeCheckCurses_COMPILED}")
unset(CMakeCheckCurses_COMPILED CACHE)

if(CMakeCheckCurses_COMPILED)
  message(${__checkPass} "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(${__checkFail} "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()