|
| 1 | +cmake_minimum_required(VERSION 3.0) |
| 2 | + |
| 3 | +project(tin-terrain) |
| 4 | + |
| 5 | +option(TNTN_TEST "include test targets in the buildsystem" OFF) |
| 6 | +option(TNTN_DOWNLOAD_DEPS "download dependencies during cmake configure" ON) |
| 7 | +#option(TNTN_USE_ADDONS "" OFF) |
| 8 | + |
| 9 | +set(CMAKE_CXX_STANDARD 14) |
| 10 | + |
| 11 | + |
| 12 | +# get the current working branch |
| 13 | +execute_process( |
| 14 | + COMMAND git describe --all --dirty |
| 15 | + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" |
| 16 | + OUTPUT_VARIABLE TNTN_GIT_DESCRIPTION |
| 17 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 18 | +) |
| 19 | + |
| 20 | +# last commit hash |
| 21 | +execute_process( |
| 22 | + COMMAND git log -1 --format=%H |
| 23 | + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" |
| 24 | + OUTPUT_VARIABLE TNTN_GIT_COMMIT_HASH |
| 25 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 26 | +) |
| 27 | +string(TIMESTAMP TNTN_TIMESTAMP "%Y%m%dT%H%MZ" UTC) |
| 28 | + |
| 29 | + |
| 30 | +find_package(GDAL REQUIRED) |
| 31 | +if(NOT GDAL_FOUND) |
| 32 | + message(FATAL_ERROR "GDAL not found, cannot proceed") |
| 33 | +endif() |
| 34 | +if(NOT GDAL_CONFIG) |
| 35 | + message(FATAL_ERROR "gdal-config command not found (not in PATH?), cannot proceed") |
| 36 | +endif() |
| 37 | + |
| 38 | +execute_process( |
| 39 | + COMMAND ${GDAL_CONFIG} --version |
| 40 | + OUTPUT_VARIABLE SYSTEM_GDAL_VERSION |
| 41 | +) |
| 42 | + |
| 43 | +if(SYSTEM_GDAL_VERSION VERSION_LESS "2.3") |
| 44 | + message(FATAL_ERROR "GDAL version \"${SYSTEM_GDAL_VERSION}\" is too old, at least 2.3 is required") |
| 45 | +endif() |
| 46 | + |
| 47 | +# Boost |
| 48 | +set(Boost_USE_STATIC_LIBS ON CACHE BOOL "" FORCE) |
| 49 | +set(Boost_USE_STATIC_LIBS ON) |
| 50 | +find_package(Boost REQUIRED COMPONENTS |
| 51 | + program_options |
| 52 | + filesystem |
| 53 | + system |
| 54 | +) |
| 55 | + |
| 56 | +include("download-deps.cmake") |
| 57 | +find_path(TNTN_LIBGLM_SOURCE_DIR NAMES "glm/glm.hpp" HINTS "${CMAKE_SOURCE_DIR}/3rdparty/glm-0.9.9.0/") |
| 58 | +find_path(TNTN_LIBFMT_SOURCE_DIR NAMES "include/fmt/format.h" HINTS "${CMAKE_SOURCE_DIR}/3rdparty/fmt-5.1.0/") |
| 59 | +find_path(TNTN_CATCH2_SOURCE_DIR NAMES "catch.hpp" HINTS "${CMAKE_SOURCE_DIR}/3rdparty/Catch2-2.3.0/") |
| 60 | + |
| 61 | +if(NOT TNTN_LIBGLM_SOURCE_DIR) |
| 62 | + message(SEND_ERROR "GLM math library source dir not found, please download and set TNTN_LIBGLM_SOURCE_DIR") |
| 63 | +endif() |
| 64 | +if(NOT TNTN_LIBFMT_SOURCE_DIR) |
| 65 | + message(SEND_ERROR "libfmt string formatting library source dir not found, please download and set TNTN_LIBFMT_SOURCE_DIR") |
| 66 | +endif() |
| 67 | + |
| 68 | +add_subdirectory("${TNTN_LIBFMT_SOURCE_DIR}") |
| 69 | + |
| 70 | + |
| 71 | +set(TNTN_SOURCE_FILES |
| 72 | + |
| 73 | + src/dem2tintiles_workflow.cpp |
| 74 | + include/tntn/dem2tintiles_workflow.h |
| 75 | + |
| 76 | + src/TileMaker.cpp |
| 77 | + include/tntn/TileMaker.h |
| 78 | + |
| 79 | + src/MercatorProjection.cpp |
| 80 | + include/tntn/MercatorProjection.h |
| 81 | + |
| 82 | + include/tntn/MeshMode.h |
| 83 | + include/tntn/Mesh.h |
| 84 | + src/Mesh.cpp |
| 85 | + |
| 86 | + include/tntn/QuadEdge.h |
| 87 | + src/QuadEdge.cpp |
| 88 | + |
| 89 | + include/tntn/DelaunayMesh.h |
| 90 | + src/DelaunayMesh.cpp |
| 91 | + |
| 92 | + include/tntn/DelaunayTriangle.h |
| 93 | + src/DelaunayTriangle.cpp |
| 94 | + |
| 95 | + include/tntn/TerraMesh.h |
| 96 | + src/TerraMesh.cpp |
| 97 | + |
| 98 | + include/tntn/TerraUtils.h |
| 99 | + src/TerraUtils.cpp |
| 100 | + |
| 101 | + include/tntn/terra_meshing.h |
| 102 | + src/terra_meshing.cpp |
| 103 | + |
| 104 | + include/tntn/zemlya_meshing.h |
| 105 | + src/zemlya_meshing.cpp |
| 106 | + |
| 107 | + include/tntn/MeshIO.h |
| 108 | + src/MeshIO.cpp |
| 109 | + |
| 110 | + include/tntn/geometrix.h |
| 111 | + src/geometrix.cpp |
| 112 | + |
| 113 | + include/tntn/SurfacePoints.h |
| 114 | + src/SurfacePoints.cpp |
| 115 | + |
| 116 | + include/tntn/ZoomRange.h |
| 117 | + |
| 118 | + include/tntn/util.h |
| 119 | + src/util.cpp |
| 120 | + |
| 121 | + include/tntn/logging.h |
| 122 | + src/logging.cpp |
| 123 | + |
| 124 | + include/tntn/OFFReader.h |
| 125 | + src/OFFReader.cpp |
| 126 | + |
| 127 | + include/tntn/Raster.h |
| 128 | + |
| 129 | + include/tntn/RasterIO.h |
| 130 | + src/RasterIO.cpp |
| 131 | + |
| 132 | + include/tntn/Mesh2Raster.h |
| 133 | + src/Mesh2Raster.cpp |
| 134 | + |
| 135 | + include/tntn/SuperTriangle.h |
| 136 | + src/SuperTriangle.cpp |
| 137 | + |
| 138 | + include/tntn/raster_tools.h |
| 139 | + src/raster_tools.cpp |
| 140 | + |
| 141 | + include/tntn/FileFormat.h |
| 142 | + |
| 143 | + include/tntn/tntn_assert.h |
| 144 | + |
| 145 | + include/tntn/File.h |
| 146 | + src/File.cpp |
| 147 | + |
| 148 | + include/tntn/QuantizedMeshIO.h |
| 149 | + src/QuantizedMeshIO.cpp |
| 150 | + |
| 151 | + include/tntn/MeshWriter.h |
| 152 | + src/MeshWriter.cpp |
| 153 | + |
| 154 | + include/tntn/ObjPool.h |
| 155 | + |
| 156 | + include/tntn/benchmark_workflow.h |
| 157 | + src/benchmark_workflow.cpp |
| 158 | + |
| 159 | + include/tntn/simple_meshing.h |
| 160 | + src/simple_meshing.cpp |
| 161 | + |
| 162 | + include/tntn/Points2Mesh.h |
| 163 | + src/Points2Mesh.cpp |
| 164 | + |
| 165 | + include/tntn/endianness.h |
| 166 | + include/tntn/BinaryIO.h |
| 167 | + src/BinaryIO.cpp |
| 168 | + |
| 169 | + include/tntn/version_info.h |
| 170 | + src/version_info.cpp.in |
| 171 | + "${CMAKE_CURRENT_BINARY_DIR}/version_info.cpp" |
| 172 | + |
| 173 | + include/tntn/RasterOverviews.h |
| 174 | + src/RasterOverviews.cpp |
| 175 | + |
| 176 | + include/tntn/gdal_init.h |
| 177 | + src/gdal_init.cpp |
| 178 | + |
| 179 | + include/delaunator_cpp/Delaunator.h |
| 180 | + src/Delaunator.cpp |
| 181 | + |
| 182 | + include/tntn/println.h |
| 183 | + src/println.cpp |
| 184 | +) |
| 185 | + |
| 186 | +if(TNTN_USE_ADDONS) |
| 187 | + list(APPEND TNTN_SOURCE_FILES |
| 188 | + include/tntn/Raster2Mesh.h |
| 189 | + src/Raster2Mesh.cpp |
| 190 | + include/tntn/ZemlyaMesh.h |
| 191 | + src/ZemlyaMesh.cpp |
| 192 | + ) |
| 193 | +endif() |
| 194 | + |
| 195 | +configure_file(src/version_info.cpp.in version_info.cpp) |
| 196 | + |
| 197 | + |
| 198 | +add_library(tntn STATIC |
| 199 | + ${TNTN_SOURCE_FILES} |
| 200 | +) |
| 201 | + |
| 202 | +target_compile_definitions(tntn PUBLIC $<$<CONFIG:Debug>:TNTN_DEBUG>) |
| 203 | + |
| 204 | +target_compile_definitions(tntn PUBLIC GLM_FORCE_SWIZZLE GLM_ENABLE_EXPERIMENTAL) |
| 205 | + |
| 206 | +if(TNTN_DOWNLOAD_ADDONS) |
| 207 | + target_compile_definitions(tntn PUBLIC TNTN_USE_ADDONS=1) |
| 208 | +endif() |
| 209 | + |
| 210 | +target_include_directories(tntn |
| 211 | + PUBLIC |
| 212 | + ${TNTN_LIBGLM_SOURCE_DIR} |
| 213 | + ${CMAKE_CURRENT_SOURCE_DIR}/include/ |
| 214 | + ${Boost_INCLUDE_DIRS} |
| 215 | + |
| 216 | + PRIVATE |
| 217 | + ${GDAL_INCLUDE_DIR} |
| 218 | +) |
| 219 | +if(TNTN_USE_ADDONS) |
| 220 | + target_include_directories(tntn |
| 221 | + PUBLIC |
| 222 | + 3rdparty/addons/include/ |
| 223 | + ) |
| 224 | +endif() |
| 225 | + |
| 226 | +target_link_libraries(tntn |
| 227 | + PUBLIC |
| 228 | + ${Boost_LIBRARIES} |
| 229 | + fmt |
| 230 | + |
| 231 | + PRIVATE |
| 232 | + ${GDAL_LIBRARY} |
| 233 | +) |
| 234 | + |
| 235 | +add_executable(tin-terrain |
| 236 | + src/cmd.cpp |
| 237 | +) |
| 238 | +target_include_directories(tin-terrain |
| 239 | + PRIVATE |
| 240 | + ${Boost_INCLUDE_DIRS} |
| 241 | +) |
| 242 | +target_link_libraries(tin-terrain |
| 243 | + PRIVATE |
| 244 | + ${Boost_LIBRARIES} |
| 245 | + tntn |
| 246 | +) |
| 247 | + |
| 248 | +if(TNTN_TEST) |
| 249 | + add_subdirectory(test) |
| 250 | +endif() |
0 commit comments