city_generator2

Generated conformal 3D meshes representing a city
git clone git://git.meso-star.fr/city_generator2.git
Log | Files | Refs | README | LICENSE

CMakeLists.txt (4798B)


      1 # Copyright (C) 2018-2021 |Meso|Star> (contact@meso-star.com)
      2 #
      3 # This program is free software: you can redistribute it and/or modify
      4 # it under the terms of the GNU General Public License as published by
      5 # the Free Software Foundation, either version 3 of the License, or
      6 # (at your option) any later version.
      7 #
      8 # This program is distributed in the hope that it will be useful,
      9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     11 # GNU General Public License for more details.
     12 #
     13 # You should have received a copy of the GNU General Public License
     14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
     15 
     16 cmake_minimum_required(VERSION 3.0)
     17 
     18 string(REGEX MATCH ".*HTML.*" _html ${CG2_DOC})
     19 string(REGEX MATCH ".*ROFF.*" _roff ${CG2_DOC})
     20 
     21 set(CG2_DOC_DIR ${PROJECT_SOURCE_DIR}/../doc)
     22 
     23 ################################################################################
     24 # Look for asciidoc and a2x programs
     25 ################################################################################
     26 if(_html)
     27   find_program(ASCIIDOC NAMES asciidoc asciidoc.py)
     28   if(NOT ASCIIDOC)
     29     unset(_html)
     30     message(WARNING
     31       "The `asciidoc' program is missing. "
     32       "The city_generator2 HTML documentation cannot be generated.")
     33   endif()
     34 endif()
     35 
     36 if(_roff)
     37   find_program(A2X NAMES a2x a2x.py)
     38   if(NOT A2X)
     39     unset(_roff)
     40     message(WARNING
     41       "The `a2x' program is missing. "
     42       "The city_generator2 man pages cannot be generated.")
     43   endif()
     44 endif()
     45 
     46 ################################################################################
     47 # Copy doc files
     48 ################################################################################
     49 set(MAN_NAMES
     50   city_generator2-input.5
     51   city_generator2-output.5)
     52 
     53 if(_roff OR _html)
     54   set(MAN_FILES)
     55   foreach(_name IN LISTS MAN_NAMES)
     56     set(_src ${CG2_DOC_DIR}/${_name}.txt)
     57     set(_dst ${CMAKE_CURRENT_BINARY_DIR}/${_name}.txt)
     58     add_custom_command(
     59       OUTPUT ${_dst}
     60       COMMAND ${CMAKE_COMMAND} -E copy ${_src} ${_dst}
     61       DEPENDS ${_src}
     62       COMMENT "Copy the asciidoc ${_src}"
     63       VERBATIM)
     64     list(APPEND MAN_FILES ${_dst})
     65   endforeach()
     66   add_custom_target(man-copy ALL DEPENDS ${MAN_FILES})
     67 endif()
     68 
     69 list(APPEND MAN_NAMES city_generator2.1)
     70 
     71 ################################################################################
     72 # ROFF man pages
     73 ################################################################################
     74 if(_roff)
     75   set(A2X_OPTS -dmanpage -fmanpage)
     76   set(MAN_FILES)
     77   set(MAN5_FILES)
     78   set(MAN1_FILES)
     79   foreach(_name IN LISTS MAN_NAMES)
     80     set(_man ${CMAKE_CURRENT_BINARY_DIR}/${_name})
     81     set(_txt ${CMAKE_CURRENT_BINARY_DIR}/${_name}.txt)
     82 
     83     add_custom_command(
     84       OUTPUT ${_man}
     85       COMMAND ${A2X} ${A2X_OPTS} ${_txt}
     86       DEPENDS man-copy ${_txt}
     87       WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     88       COMMENT "Build ROFF man page ${_man}"
     89       VERBATIM)
     90     list(APPEND MAN_FILES ${_man})
     91 
     92     string(REGEX MATCH "^.*.5$" _man5 ${_man})
     93     string(REGEX MATCH "^.*.1$" _man1 ${_man})
     94     if(_man1)
     95       list(APPEND MAN1_FILES ${_man1})
     96     elseif(_man5)
     97       list(APPEND MAN5_FILES ${_man5})
     98     else()
     99       message(FATAL_ERROR "Unexpected man type")
    100     endif()
    101   endforeach()
    102   add_custom_target(man-roff ALL DEPENDS ${MAN_FILES})
    103 
    104   install(FILES ${MAN1_FILES} DESTINATION share/man/man1)
    105   install(FILES ${MAN5_FILES} DESTINATION share/man/man5)
    106 endif()
    107 
    108 ################################################################################
    109 # HTML documentation
    110 ################################################################################
    111 if(_html)
    112   set(ASCIIDOC_OPTS
    113     -bxhtml11
    114     -dmanpage
    115     --attribute themedir=${CG2_DOC_DIR}
    116     --theme=city_generator2-man)
    117 
    118   set(MAN_FILES)
    119   set(MAN5_FILES)
    120   set(MAN1_FILES)
    121   foreach(_name IN LISTS MAN_NAMES)
    122     set(_man ${CMAKE_CURRENT_BINARY_DIR}/${_name}.html)
    123     set(_txt ${CMAKE_CURRENT_BINARY_DIR}/${_name}.txt)
    124 
    125     add_custom_command(
    126       OUTPUT ${_man}
    127       COMMAND ${ASCIIDOC} ${ASCIIDOC_OPTS} ${_txt}
    128       DEPENDS man-copy ${_txt} ${CG2_DOC_DIR}/city_generator2-man.css
    129       WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    130       COMMENT "Build HTML man page ${_man}"
    131       VERBATIM)
    132     list(APPEND MAN_FILES ${_man})
    133 
    134     string(REGEX MATCH "^.*.5.html$" _man5 ${_man})
    135     string(REGEX MATCH "^.*.1.html$" _man1 ${_man})
    136     if(_man1)
    137       list(APPEND MAN1_FILES ${_man1})
    138     elseif(_man5)
    139       list(APPEND MAN5_FILES ${_man5})
    140     else()
    141       message(FATAL_ERROR "Unexpected man type")
    142     endif()
    143   endforeach()
    144   add_custom_target(man-html ALL DEPENDS ${MAN_FILES})
    145 
    146   install(FILES ${MAN1_FILES} DESTINATION share/doc/city_generator2/html)
    147   install(FILES ${MAN5_FILES} DESTINATION share/doc/city_generator2/html)
    148 endif()
    149