3 EXECUTE_PROCESS(COMMAND "date" "+%F" OUTPUT_VARIABLE ${RESULT} OUTPUT_STRIP_TRAILING_WHITESPACE)
5 set(${RESULT} "????-??-??")
10 set(MAN1_PATH ${CMAKE_BINARY_DIR}/man/man1)
11 file(MAKE_DIRECTORY ${MAN1_PATH})
14 FILE(READ "${CMAKE_SOURCE_DIR}/admin/programs.txt" contents)
16 # Convert file contents into a CMake list. First escape ;
17 STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
18 STRING(REGEX REPLACE "\n" ";" contents "${contents}")
21 foreach(line ${contents})
22 if (${line} MATCHES "^HEAD\\|")
23 string(REGEX REPLACE "^HEAD\\|" "" DESC ${line})
24 set(PROGMANPAGES "${PROGMANPAGES}.Sh \"${DESC}\"\n.IX Subsection \"${DESC}\"\n.Vb\n.ta 16n\n")
25 elseif(${line} MATCHES "^END$")
26 set(PROGMANPAGES "${PROGMANPAGES}.Ve\n")
27 elseif(${line} MATCHES "\\|")
28 string(REGEX REPLACE "\\|" "\t" line ${line})
29 set(PROGMANPAGES "${PROGMANPAGES}\\& ${line}\n")
31 message(WARNING "Incorrectly formated line \"${line}\" in programs.txt")
35 configure_file(${CMAKE_SOURCE_DIR}/man/man7/gromacs.7.cmakein ${CMAKE_BINARY_DIR}/man/man7/gromacs.7)
36 install(FILES ${CMAKE_BINARY_DIR}/man/man7/gromacs.7 DESTINATION
37 ${MAN_INSTALL_DIR}/man7)
38 #man-pages are only avalaible if they are either build or this is a source archive
39 elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/admin/.isreposource")
40 install(FILES ${CMAKE_SOURCE_DIR}/man/man7/gromacs.7 DESTINATION
41 ${MAN_INSTALL_DIR}/man7)
44 function (gmx_add_man_page EXENAME)
45 if(GMX_BUILD_MANPAGES)
46 file(STRINGS ${CMAKE_SOURCE_DIR}/admin/programs.txt DESC
47 REGEX "^${EXENAME}\\|" LIMIT_COUNT 1)
48 #Regex breaks with a "|" in description. Cmake doesn't support
50 string(REGEX REPLACE "^.*\\|" "" DESC "${DESC}")
52 message(WARNING "Missing description for ${EXENAME}")
54 add_custom_command(TARGET ${EXENAME} POST_BUILD
55 #The redirect is a hack to avoid showing copyright.
56 #Ideally -quiet would also cause programs to not print copyright.
57 COMMAND ${CMAKE_COMMAND} -DINFILE=${EXENAME}${GMX_BINARY_SUFFIX}.nroff
58 -DOUTFILE=${MAN1_PATH}/${EXENAME}.1 -DDESC=" - ${DESC}"
59 -DEXENAME=${EXENAME}${GMX_BINARY_SUFFIX}
60 -P ${CMAKE_SOURCE_DIR}/cmake/CreateManPage.cmake)
61 install(FILES ${MAN1_PATH}/${EXENAME}.1 DESTINATION
62 ${MAN_INSTALL_DIR}/man1 OPTIONAL)
63 elseif(NOT EXISTS "${CMAKE_SOURCE_DIR}/admin/.isreposource")
64 install(FILES ${CMAKE_SOURCE_DIR}/man/man1/${EXENAME}.1 DESTINATION
65 ${MAN_INSTALL_DIR}/man1)