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 (5533B)


      1 # Copyright (C) 2022 |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.1)
     17 project(city_generator2 C)
     18 enable_testing()
     19 
     20 set(CG2_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../src)
     21 option(NO_TEST "Disable the test" OFF)
     22 option(STL_OUTPUT_DEFAULT_IS_BINARY
     23   "Default is to use binary format for output STL files" OFF)
     24 set(CG2_CLOSE_NEIGHBOR_DISTANCE "2" CACHE STRING
     25   "Distance up to which windows are not generated")
     26 set(CG2_MIN_DISTANCE_TO_MAP_LIMITS "2" CACHE STRING
     27   "Minimum distance from a building to the map limit")
     28 set(CG2_MIN_WINDOWS_WIDTH "0.1" CACHE STRING
     29   "Minimum width for a windows to be valid")
     30 
     31 if(CMAKE_HOST_UNIX)
     32   set(CG2_DOC "TROFF" CACHE STRING
     33     "Type of documentation to generate and install.")
     34 else()
     35   set(CG2_DOC "HTML" CACHE STRING
     36     "Type of documentation to generate and install.")
     37 endif()
     38 
     39 set_property(CACHE CG2_DOC PROPERTY STRINGS
     40   "HTML"
     41   "TROFF"
     42   "TROFF & HTML"
     43   "NONE")
     44 
     45 ###############################################################################
     46 # Generate files
     47 ###############################################################################
     48 if(STL_OUTPUT_DEFAULT_IS_BINARY)
     49   set(CG2_ARGS_BINARY_STL_DEFAULT "1")
     50   set(CG2_ARGS_STL_DEFAULT_STR "binary")
     51   set(CG2_ARGS_STL_NON_DEFAULT_STR "ascii")
     52   set(CG2_ARGS_CHANGE_BINARY_DEFAULT_OPTION "a")
     53 else()
     54   set(CG2_ARGS_BINARY_STL_DEFAULT "0")
     55   set(CG2_ARGS_STL_DEFAULT_STR "ascii")
     56   set(CG2_ARGS_STL_NON_DEFAULT_STR "binary")
     57   set(CG2_ARGS_CHANGE_BINARY_DEFAULT_OPTION "b")
     58 endif()
     59 set(CG2_ARGS_DEFAULT_VERBOSITY_LEVEL "1")
     60 
     61 configure_file(${CG2_SOURCE_DIR}/../doc/city_generator2.1.txt.in
     62   ${CMAKE_CURRENT_BINARY_DIR}/doc/city_generator2.1.txt @ONLY)
     63 
     64 configure_file(${CG2_SOURCE_DIR}/cg_default.h.in
     65   ${CMAKE_CURRENT_BINARY_DIR}/cg_default.h @ONLY)
     66 
     67 set(CG2_VERSION_MAJOR 0)
     68 set(CG2_VERSION_MINOR 2)
     69 set(CG2_VERSION_PATCH 0)
     70 
     71 set(CG2_VERSION ${CG2_VERSION_MAJOR}.${CG2_VERSION_MINOR}.${CG2_VERSION_PATCH})
     72 configure_file(${CG2_SOURCE_DIR}/cg_version.h.in
     73   ${CMAKE_CURRENT_BINARY_DIR}/cg_version.h @ONLY)
     74 
     75 ################################################################################
     76 # Check dependencies
     77 ################################################################################
     78 find_package(RCMake 0.4.1 REQUIRED)
     79 find_package(RSys 0.12.1 REQUIRED)
     80 find_package(StarCAD 0.4 REQUIRED)
     81 find_package(StarCPR 0.4.1 REQUIRED)
     82 find_package(libcyaml 1.4 REQUIRED)
     83 
     84 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RCMAKE_SOURCE_DIR})
     85 include(rcmake)
     86 include(rcmake_runtime)
     87 
     88 include_directories(
     89   ${StarCAD_INCLUDE_DIR}
     90   ${RSys_INCLUDE_DIR}
     91   ${StarCAD_INCLUDE_DIR}
     92   ${StarCPR_INCLUDE_DIR}
     93   ${LIBCYAML_INCLUDE_DIR}
     94   ${CMAKE_CURRENT_BINARY_DIR})
     95 
     96 if(CMAKE_COMPILER_IS_GNUCC)
     97   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
     98 endif()
     99 
    100 ###############################################################################
    101 # Build subprojects
    102 ###############################################################################
    103 if(NOT CG2_DOC STREQUAL "NONE")
    104   add_subdirectory(doc)
    105 endif()
    106 
    107 ################################################################################
    108 # Configure and define targets
    109 ################################################################################
    110 set(CG2_FILES_SRC
    111   cg_args.c
    112   cg_building.c
    113   cg_catalog.c
    114   cg_catalog_parsing.c
    115   cg_city.c
    116   cg_city_parsing.c
    117   cg_construction_mode.c
    118   cg_construction_mode_0.c
    119   cg_construction_mode_1.c
    120   cg_ground.c
    121   cg_main.c
    122   cg_types.c
    123   cg_vertex_denoiser.c)
    124 
    125 set(CG2_FILES_INC
    126   cg.h
    127   cg_args.h
    128   cg_building.h
    129   cg_catalog.h
    130   cg_catalog_parsing.h
    131   cg_city.h
    132   cg_city_parsing.h
    133   cg_city_parsing_schemas.h
    134   cg_construction_mode.h
    135   cg_construction_mode_0.h
    136   cg_construction_mode_0_parsing_schemas.h
    137   cg_construction_mode_1.h
    138   cg_construction_mode_1_parsing_schemas.h
    139   cg_default.h.in
    140   cg_ground.h
    141   cg_types.h
    142   cg_version.h.in
    143   cg_vertex_denoiser.h)
    144 
    145 set(CG2_FILES_DOC COPYING README.md)
    146 
    147 # Prepend each file in the `CG2_FILES_<SRC|INC>' list by `CG2_SOURCE_DIR'
    148 rcmake_prepend_path(CG2_FILES_SRC ${CG2_SOURCE_DIR})
    149 rcmake_prepend_path(CG2_FILES_INC ${CG2_SOURCE_DIR})
    150 rcmake_prepend_path(CG2_FILES_DOC ${PROJECT_SOURCE_DIR}/../)
    151 
    152 if(CMAKE_COMPILER_IS_GNUCC)
    153   set(MATH_LIB m)
    154 endif()
    155 
    156 add_executable(city_generator2
    157   ${CG2_FILES_SRC}
    158   ${CG2_FILES_INC})
    159 
    160 target_link_libraries(city_generator2
    161   RSys StarCAD StarCPR libcyaml ${MATH_LIB})
    162 
    163 set_target_properties(city_generator2 PROPERTIES
    164   VERSION ${CG2_VERSION})
    165 
    166 ################################################################################
    167 # Define output & install directories
    168 ################################################################################
    169 install(TARGETS city_generator2
    170   ARCHIVE DESTINATION bin
    171   LIBRARY DESTINATION lib
    172   RUNTIME DESTINATION bin)
    173 install(FILES ${CG2_FILES_DOC} DESTINATION share/doc/city_generator2)
    174 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cg_version.h
    175 	DESTINATION include/city_generator2)