|
| 1 | +# AUTHOR(S): Rashad Kanavath <rashad km gmail> |
| 2 | +# PURPOSE: Grass root that adds options to activate/deactivate 3rd party libraries |
| 3 | +# COPYRIGHT: (C) 2020 by the GRASS Development Team |
| 4 | +# This program is free software under the GPL (>=v2) |
| 5 | +# Read the file COPYING that comes with GRASS for details. |
| 6 | + |
| 7 | +cmake_minimum_required(VERSION 3.3) |
| 8 | +set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) |
| 9 | + |
| 10 | +#if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) |
| 11 | +# set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") |
| 12 | +#endif() |
| 13 | + |
| 14 | +project(GRASSGIS) |
| 15 | + |
| 16 | +set(BUILD_SHARED_LIBS ON) |
| 17 | +#message(FATAL_ERROR "VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}") |
| 18 | +if(MSVC) |
| 19 | + if(BUILD_SHARED_LIBS) |
| 20 | + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) |
| 21 | + endif() |
| 22 | + |
| 23 | + set_property(GLOBAL PROPERTY USE_FOLDERS ON) |
| 24 | +endif() |
| 25 | + |
| 26 | +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/find_scripts;${CMAKE_SOURCE_DIR}/cmake/modules;${CMAKE_MODULE_PATH}") |
| 27 | + |
| 28 | +set(default_option_enabled ON) |
| 29 | +if(WIN32) |
| 30 | + set(default_option_enabled OFF) |
| 31 | +endif() |
| 32 | + |
| 33 | +if(CMAKE_BUILD_TYPE) |
| 34 | +set( grass_build_type "${CMAKE_BUILD_TYPE}" ) |
| 35 | +string( TOLOWER "${grass_build_type}" grass_build_type_lc ) |
| 36 | +set(find_library_suffix "_RELEASE") |
| 37 | +if( grass_build_type_lc STREQUAL "debug" ) |
| 38 | +set(find_library_suffix "_DEBUG") |
| 39 | +endif() |
| 40 | +else() |
| 41 | +set(find_library_suffix "") |
| 42 | +endif() |
| 43 | + |
| 44 | +option(WITH_CAIRO "Build with cairo support ." ON) |
| 45 | +option(WITH_X11 "Build with X11 support ." ${default_option_enabled}) |
| 46 | +option(WITH_OPENGL "Build with opengl support ." ON) |
| 47 | +option(WITH_SQLITE "enable sqlite support" ON) |
| 48 | +option(WITH_POSTGRES "enable postgres support" ON) |
| 49 | +option(WITH_NLS "enable nls support" ${default_option_enabled}) |
| 50 | +option(WITH_BZLIB "enable bzlib support" ON) |
| 51 | +option(WITH_BLAS "enable blas support" ON) |
| 52 | +option(WITH_LAPACK "enable lapack support" ON) |
| 53 | +option(WITH_LIBLAS "enable libLAS support" ON) |
| 54 | +option(WITH_OPENDWG "enable v.in.dwg" OFF) |
| 55 | + |
| 56 | +option(WITH_PYTHON "Build python bindings" ON) |
| 57 | +option(WITH_LARGEFILES "enable largefile support" ${default_option_enabled}) |
| 58 | +option(WITH_DOCS "Build documentation" ON) |
| 59 | +if(APPLE) |
| 60 | + if(POLICY CMP0042) |
| 61 | + cmake_policy(SET CMP0042 NEW) |
| 62 | + endif() |
| 63 | + set(CMAKE_MACOSX_RPATH TRUE) |
| 64 | +endif() |
| 65 | + |
| 66 | +set(CMAKE_SKIP_BUILD_RPATH FALSE) |
| 67 | +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) |
| 68 | +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") |
| 69 | +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
| 70 | +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) |
| 71 | +if("${isSystemDir}" STREQUAL "-1") |
| 72 | + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") |
| 73 | +endif("${isSystemDir}" STREQUAL "-1") |
| 74 | + |
| 75 | +include(get_host_arch) |
| 76 | +get_host_arch(BUILD_ARCH) |
| 77 | + |
| 78 | +include(get_versions) |
| 79 | +get_versions("include/VERSION" |
| 80 | + GRASS_VERSION_MAJOR |
| 81 | + GRASS_VERSION_MINOR |
| 82 | + GRASS_VERSION_RELEASE |
| 83 | + GRASS_VERSION_DATE) |
| 84 | + |
| 85 | +set(GRASS_VERSION_NUMBER ${GRASS_VERSION_MAJOR}.${GRASS_VERSION_MINOR}.${GRASS_VERSION_RELEASE}) |
| 86 | +message(STATUS "GRASS_VERSION_NUMBER = '${GRASS_VERSION_NUMBER}'") |
| 87 | +set(GRASS_VERSION_UPDATE_PKG "0.2") |
| 88 | + |
| 89 | +include(set_compiler_flags) |
| 90 | +set_compiler_flags() |
| 91 | + |
| 92 | +include(repo_status) |
| 93 | +repo_status("${CMAKE_CURRENT_LIST_DIR}" GRASS_VERSION_GIT) |
| 94 | + |
| 95 | +enable_testing() |
| 96 | + |
| 97 | +# Setup build locations. |
| 98 | +if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) |
| 99 | + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| 100 | +endif() |
| 101 | +if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) |
| 102 | + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 103 | +endif() |
| 104 | +if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) |
| 105 | + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 106 | +endif() |
| 107 | + |
| 108 | +include(build_module) |
| 109 | +include(build_program) |
| 110 | +include(build_program_in_subdir) |
| 111 | +include(build_library_in_subdir) |
| 112 | +include(copy_python_files_in_subdir) |
| 113 | +include(build_script_in_subdir) |
| 114 | +include(build_gui_in_subdir) |
| 115 | +include(check_target) |
| 116 | + |
| 117 | +add_subdirectory(thirdparty) |
| 118 | +set(MKHTML_PY ${CMAKE_BINARY_DIR}/tools/mkhtml.py) |
| 119 | + |
| 120 | +set(GISBASE ${CMAKE_BINARY_DIR}/gisbase) |
| 121 | +file(TO_NATIVE_PATH "${GISBASE}" GISBASE_NATIVE) |
| 122 | +file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/bin" BINARY_DIR) |
| 123 | +file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/lib" LIB_DIR) |
| 124 | +file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}" MODULE_TOPDIR) |
| 125 | +file(TO_NATIVE_PATH "${GISBASE}/scripts" SCRIPTS_DIR) |
| 126 | +file(TO_NATIVE_PATH "${GISBASE}/etc/config/rc" GISRC) |
| 127 | +file(TO_NATIVE_PATH "${GISBASE}/etc/python" ETC_PYTHON_DIR) |
| 128 | +file(TO_NATIVE_PATH "${GISBASE}/gui/wxpython" GUI_WXPYTHON_DIR) |
| 129 | +if(WIN32) |
| 130 | +set(sep "\;") |
| 131 | +set(env_path "") |
| 132 | +else() |
| 133 | +set(sep ":") |
| 134 | +set(env_path ":$ENV{PATH}") |
| 135 | +endif() |
| 136 | + |
| 137 | + |
| 138 | +set(grass_env_command ${CMAKE_COMMAND} -E env |
| 139 | + "PATH=${BINARY_DIR}${sep}${SCRIPTS_DIR}${env_path}" |
| 140 | + "PYTHONPATH=${ETC_PYTHON_DIR}${sep}${GUI_WXPYTHON_DIR}${sep}$ENV{PYTHONPATH}" |
| 141 | + "LD_LIBRARY_PATH=${LIB_DIR}${sep}$ENV{LD_LIBRARY_PATH}" |
| 142 | + "GISBASE=${GISBASE_NATIVE}" |
| 143 | + "GISRC=${GISRC}" |
| 144 | + "LC_ALL=C" |
| 145 | + "LANG=C" |
| 146 | + "LANGUAGE=C" |
| 147 | + "MODULE_TOPDIR=${MODULE_TOPDIR}" |
| 148 | + "VERSION_NUMBER=\"${GRASS_VERSION_NUMBER}\"" |
| 149 | + "VERSION_DATE=\"${GRASS_VERSION_DATE}\"") |
| 150 | + |
| 151 | + |
| 152 | + |
| 153 | +set(NO_HTML_DESCR_TARGETS "g.parser;ximgview;test.raster3d.lib") |
| 154 | +add_subdirectory(include) |
| 155 | + |
| 156 | +include_directories("${CMAKE_BINARY_DIR}/include") |
| 157 | +if(MSVC) |
| 158 | + include_directories("${CMAKE_SOURCE_DIR}/msvc") |
| 159 | +endif() |
| 160 | + |
| 161 | +execute_process( |
| 162 | + COMMAND ${CMAKE_COMMAND} -E echo "Creating directories in ${GISBASE}" |
| 163 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/bin/ |
| 164 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/scripts/ |
| 165 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/demolocation/ |
| 166 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/config/ |
| 167 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/driver/db/ |
| 168 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/tools/ |
| 169 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/lib/ |
| 170 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/lister/ |
| 171 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/python/grass/lib |
| 172 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/wxpython/xml/ |
| 173 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/icons/ |
| 174 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/images/ |
| 175 | + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/docs/html/ |
| 176 | + ) |
| 177 | + |
| 178 | +add_subdirectory(lib) |
| 179 | +add_subdirectory(tools) |
| 180 | +set(modules_list) |
| 181 | + |
| 182 | + |
| 183 | +set(ALL_SUBDIRS |
| 184 | + general |
| 185 | + db |
| 186 | + display |
| 187 | + imagery |
| 188 | + misc |
| 189 | + raster |
| 190 | + raster3d |
| 191 | + scripts |
| 192 | + vector |
| 193 | + temporal |
| 194 | + # ps |
| 195 | +) |
| 196 | + |
| 197 | +foreach(d ${ALL_SUBDIRS}) |
| 198 | + add_subdirectory(${d}) |
| 199 | +endforeach() |
| 200 | +add_custom_target(ALL_MODULES |
| 201 | + COMMAND ${CMAKE_COMMAND} -E echo "Building all modules" |
| 202 | + DEPENDS ${modules_list}) |
| 203 | + |
| 204 | +###message(FATAL_ERROR "modules_list=${modules_list}") |
| 205 | + |
| 206 | +if(WITH_PYTHON) |
| 207 | + add_subdirectory(gui) |
| 208 | +endif() |
| 209 | + |
| 210 | +if(WITH_DOCS) |
| 211 | + add_subdirectory(doc) |
| 212 | + add_subdirectory(man) |
| 213 | +endif() # WITH_DOCS |
| 214 | + |
| 215 | + |
| 216 | +####add_subdirectory(locale) |
| 217 | + |
| 218 | +# TODO: To be discussed |
| 219 | +# add_subdirectory(testsuite) |
| 220 | +# add_subdirectory(macosx) |
| 221 | + |
| 222 | +if(WITH_X11) |
| 223 | + build_program_in_subdir(visualization/ximgview DEPENDS grass_gis X11) |
| 224 | +endif() |
0 commit comments