From 98bda809fa2df2368608c6f06464958d12961a6a Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 14 Jan 2020 12:00:00 +0100 Subject: [PATCH 01/37] Add CMake support --- CMakeLists.txt | 224 ++++++++ cmake/copy_g_gui_module.cmake | 35 ++ cmake/ctypesgen.cmake | 61 +++ cmake/find_scripts/FindCairo.cmake | 122 +++++ cmake/find_scripts/FindFFTW.cmake | 66 +++ cmake/find_scripts/FindFontConfig.cmake | 35 ++ cmake/find_scripts/FindGDAL.cmake | 23 + cmake/find_scripts/FindGEOS.cmake | 57 ++ cmake/find_scripts/FindIconv.cmake | 58 ++ cmake/find_scripts/FindLibLAS.cmake | 35 ++ cmake/find_scripts/FindNetCDF.cmake | 14 + cmake/find_scripts/FindPCRE.cmake | 32 ++ cmake/find_scripts/FindPROJ.cmake | 58 ++ cmake/find_scripts/FindPostgreSQL.cmake | 126 +++++ cmake/find_scripts/FindSQLite.cmake | 8 + cmake/locale_strings.cmake | 82 +++ cmake/modules/build_gui_in_subdir.cmake | 107 ++++ cmake/modules/build_library_in_subdir.cmake | 16 + cmake/modules/build_module.cmake | 271 +++++++++ cmake/modules/build_program.cmake | 8 + cmake/modules/build_program_in_subdir.cmake | 17 + cmake/modules/build_script_in_subdir.cmake | 97 ++++ cmake/modules/check_target.cmake | 7 + .../modules/copy_python_files_in_subdir.cmake | 15 + cmake/modules/get_host_arch.cmake | 39 ++ cmake/modules/get_versions.cmake | 34 ++ cmake/modules/repo_status.cmake | 36 ++ cmake/modules/set_compiler_flags.cmake | 13 + cmake/tests/have_pbuffer.c | 18 + cmake/tests/have_pixmaps.c | 20 + cmake/tests/have_pqcmdtuples.c | 8 + cmake/windows_launch.bat.in | 2 + db/CMakeLists.txt | 41 ++ db/drivers/CMakeLists.txt | 67 +++ demolocation/grassrc.cmake.in | 4 + display/CMakeLists.txt | 27 + doc/CMakeLists.txt | 0 general/CMakeLists.txt | 44 ++ general/manage/lister/CMakeLists.txt | 9 + gui/CMakeLists.txt | 12 + gui/icons/CMakeLists.txt | 52 ++ gui/images/CMakeLists.txt | 26 + gui/wxpython/CMakeLists.txt | 77 +++ gui/wxpython/docs/CMakeLists.txt | 13 + imagery/CMakeLists.txt | 103 ++++ imagery/i.ortho.photo/CMakeLists.txt | 17 + include/CMakeLists.txt | 285 ++++++++++ include/config.h.cmake.in | 317 +++++++++++ lib/CMakeLists.txt | 163 ++++++ lib/db/CMakeLists.txt | 28 + lib/db/sqlp/CMakeLists.txt | 17 + lib/fonts/CMakeLists.txt | 1 + lib/gis/CMakeLists.txt | 68 +++ lib/init/CMakeLists.txt | 171 ++++++ lib/proj/CMakeLists.txt | 14 + lib/python/CMakeLists.txt | 42 ++ lib/python/ctypes/CMakeLists.txt | 85 +++ lib/python/script/core.py | 2 + lib/rst/CMakeLists.txt | 21 + lib/temporal/CMakeLists.txt | 5 + lib/vector/CMakeLists.txt | 23 + lib/vector/dglib/CMakeLists.txt | 56 ++ lib/vector/diglib/CMakeLists.txt | 8 + lib/vector/neta/CMakeLists.txt | 24 + lib/vector/vedit/CMakeLists.txt | 21 + man/CMakeLists.txt | 5 + misc/CMakeLists.txt | 23 + raster/CMakeLists.txt | 514 ++++++++++++++++++ raster/r.colors.out/CMakeLists.txt | 16 + raster/r.colors/CMakeLists.txt | 12 + raster/r.li/CMakeLists.txt | 27 + raster/r.mapcalc/CMakeLists.txt | 22 + raster/r.sim/CMakeLists.txt | 15 + raster/r.spread/CMakeLists.txt | 8 + raster/r.univar/CMakeLists.txt | 15 + raster/r.watershed/CMakeLists.txt | 11 + raster3d/CMakeLists.txt | 97 ++++ raster3d/r3.flow/CMakeLists.txt | 14 + scripts/CMakeLists.txt | 102 ++++ temporal/CMakeLists.txt | 56 ++ thirdparty/CMakeLists.txt | 180 ++++++ tools/CMakeLists.txt | 24 + vector/CMakeLists.txt | 212 ++++++++ vector/v.lrs/CMakeLists.txt | 19 + 84 files changed, 4959 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/copy_g_gui_module.cmake create mode 100644 cmake/ctypesgen.cmake create mode 100644 cmake/find_scripts/FindCairo.cmake create mode 100644 cmake/find_scripts/FindFFTW.cmake create mode 100644 cmake/find_scripts/FindFontConfig.cmake create mode 100644 cmake/find_scripts/FindGDAL.cmake create mode 100644 cmake/find_scripts/FindGEOS.cmake create mode 100644 cmake/find_scripts/FindIconv.cmake create mode 100644 cmake/find_scripts/FindLibLAS.cmake create mode 100644 cmake/find_scripts/FindNetCDF.cmake create mode 100644 cmake/find_scripts/FindPCRE.cmake create mode 100644 cmake/find_scripts/FindPROJ.cmake create mode 100644 cmake/find_scripts/FindPostgreSQL.cmake create mode 100644 cmake/find_scripts/FindSQLite.cmake create mode 100644 cmake/locale_strings.cmake create mode 100644 cmake/modules/build_gui_in_subdir.cmake create mode 100644 cmake/modules/build_library_in_subdir.cmake create mode 100644 cmake/modules/build_module.cmake create mode 100644 cmake/modules/build_program.cmake create mode 100644 cmake/modules/build_program_in_subdir.cmake create mode 100644 cmake/modules/build_script_in_subdir.cmake create mode 100644 cmake/modules/check_target.cmake create mode 100644 cmake/modules/copy_python_files_in_subdir.cmake create mode 100644 cmake/modules/get_host_arch.cmake create mode 100644 cmake/modules/get_versions.cmake create mode 100644 cmake/modules/repo_status.cmake create mode 100644 cmake/modules/set_compiler_flags.cmake create mode 100644 cmake/tests/have_pbuffer.c create mode 100644 cmake/tests/have_pixmaps.c create mode 100644 cmake/tests/have_pqcmdtuples.c create mode 100644 cmake/windows_launch.bat.in create mode 100644 db/CMakeLists.txt create mode 100644 db/drivers/CMakeLists.txt create mode 100644 demolocation/grassrc.cmake.in create mode 100644 display/CMakeLists.txt create mode 100644 doc/CMakeLists.txt create mode 100644 general/CMakeLists.txt create mode 100644 general/manage/lister/CMakeLists.txt create mode 100644 gui/CMakeLists.txt create mode 100644 gui/icons/CMakeLists.txt create mode 100644 gui/images/CMakeLists.txt create mode 100644 gui/wxpython/CMakeLists.txt create mode 100644 gui/wxpython/docs/CMakeLists.txt create mode 100644 imagery/CMakeLists.txt create mode 100644 imagery/i.ortho.photo/CMakeLists.txt create mode 100644 include/CMakeLists.txt create mode 100644 include/config.h.cmake.in create mode 100644 lib/CMakeLists.txt create mode 100644 lib/db/CMakeLists.txt create mode 100644 lib/db/sqlp/CMakeLists.txt create mode 100644 lib/fonts/CMakeLists.txt create mode 100644 lib/gis/CMakeLists.txt create mode 100644 lib/init/CMakeLists.txt create mode 100644 lib/proj/CMakeLists.txt create mode 100644 lib/python/CMakeLists.txt create mode 100644 lib/python/ctypes/CMakeLists.txt create mode 100644 lib/rst/CMakeLists.txt create mode 100644 lib/temporal/CMakeLists.txt create mode 100644 lib/vector/CMakeLists.txt create mode 100644 lib/vector/dglib/CMakeLists.txt create mode 100644 lib/vector/diglib/CMakeLists.txt create mode 100644 lib/vector/neta/CMakeLists.txt create mode 100644 lib/vector/vedit/CMakeLists.txt create mode 100644 man/CMakeLists.txt create mode 100644 misc/CMakeLists.txt create mode 100644 raster/CMakeLists.txt create mode 100644 raster/r.colors.out/CMakeLists.txt create mode 100644 raster/r.colors/CMakeLists.txt create mode 100644 raster/r.li/CMakeLists.txt create mode 100644 raster/r.mapcalc/CMakeLists.txt create mode 100644 raster/r.sim/CMakeLists.txt create mode 100644 raster/r.spread/CMakeLists.txt create mode 100644 raster/r.univar/CMakeLists.txt create mode 100644 raster/r.watershed/CMakeLists.txt create mode 100644 raster3d/CMakeLists.txt create mode 100644 raster3d/r3.flow/CMakeLists.txt create mode 100644 scripts/CMakeLists.txt create mode 100644 temporal/CMakeLists.txt create mode 100644 thirdparty/CMakeLists.txt create mode 100644 tools/CMakeLists.txt create mode 100644 vector/CMakeLists.txt create mode 100644 vector/v.lrs/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000000..bb10172df55 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,224 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: Grass root that adds options to activate/deactivate 3rd party libraries +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. + +cmake_minimum_required(VERSION 3.3) +set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) + +#if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) +# set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") +#endif() + +project(GRASSGIS) + +set(BUILD_SHARED_LIBS ON) +#message(FATAL_ERROR "VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}") +if(MSVC) + if(BUILD_SHARED_LIBS) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + endif() + + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +endif() + +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/find_scripts;${CMAKE_SOURCE_DIR}/cmake/modules;${CMAKE_MODULE_PATH}") + +set(default_option_enabled ON) +if(WIN32) + set(default_option_enabled OFF) +endif() + +if(CMAKE_BUILD_TYPE) +set( grass_build_type "${CMAKE_BUILD_TYPE}" ) +string( TOLOWER "${grass_build_type}" grass_build_type_lc ) +set(find_library_suffix "_RELEASE") +if( grass_build_type_lc STREQUAL "debug" ) +set(find_library_suffix "_DEBUG") +endif() +else() +set(find_library_suffix "") +endif() + +option(WITH_CAIRO "Build with cairo support ." ON) +option(WITH_X11 "Build with X11 support ." ${default_option_enabled}) +option(WITH_OPENGL "Build with opengl support ." ON) +option(WITH_SQLITE "enable sqlite support" ON) +option(WITH_POSTGRES "enable postgres support" ON) +option(WITH_NLS "enable nls support" ${default_option_enabled}) +option(WITH_BZLIB "enable bzlib support" ON) +option(WITH_BLAS "enable blas support" ON) +option(WITH_LAPACK "enable lapack support" ON) +option(WITH_LIBLAS "enable libLAS support" ON) +option(WITH_OPENDWG "enable v.in.dwg" OFF) + +option(WITH_PYTHON "Build python bindings" ON) +option(WITH_LARGEFILES "enable largefile support" ${default_option_enabled}) +option(WITH_DOCS "Build documentation" ON) +if(APPLE) + if(POLICY CMP0042) + cmake_policy(SET CMP0042 NEW) + endif() + set(CMAKE_MACOSX_RPATH TRUE) +endif() + +set(CMAKE_SKIP_BUILD_RPATH FALSE) +set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) +if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +endif("${isSystemDir}" STREQUAL "-1") + +include(get_host_arch) +get_host_arch(BUILD_ARCH) + +include(get_versions) +get_versions("include/VERSION" + GRASS_VERSION_MAJOR + GRASS_VERSION_MINOR + GRASS_VERSION_RELEASE + GRASS_VERSION_DATE) + +set(GRASS_VERSION_NUMBER ${GRASS_VERSION_MAJOR}.${GRASS_VERSION_MINOR}.${GRASS_VERSION_RELEASE}) +message(STATUS "GRASS_VERSION_NUMBER = '${GRASS_VERSION_NUMBER}'") +set(GRASS_VERSION_UPDATE_PKG "0.2") + +include(set_compiler_flags) +set_compiler_flags() + +include(repo_status) +repo_status("${CMAKE_CURRENT_LIST_DIR}" GRASS_VERSION_GIT) + +enable_testing() + +# Setup build locations. +if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +endif() +if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +endif() +if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +endif() + +include(build_module) +include(build_program) +include(build_program_in_subdir) +include(build_library_in_subdir) +include(copy_python_files_in_subdir) +include(build_script_in_subdir) +include(build_gui_in_subdir) +include(check_target) + +add_subdirectory(thirdparty) +set(MKHTML_PY ${CMAKE_BINARY_DIR}/tools/mkhtml.py) + +set(GISBASE ${CMAKE_BINARY_DIR}/gisbase) +file(TO_NATIVE_PATH "${GISBASE}" GISBASE_NATIVE) +file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/bin" BINARY_DIR) +file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/lib" LIB_DIR) +file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}" MODULE_TOPDIR) +file(TO_NATIVE_PATH "${GISBASE}/scripts" SCRIPTS_DIR) +file(TO_NATIVE_PATH "${GISBASE}/etc/config/rc" GISRC) +file(TO_NATIVE_PATH "${GISBASE}/etc/python" ETC_PYTHON_DIR) +file(TO_NATIVE_PATH "${GISBASE}/gui/wxpython" GUI_WXPYTHON_DIR) +if(WIN32) +set(sep "\;") +set(env_path "") +else() +set(sep ":") +set(env_path ":$ENV{PATH}") +endif() + + +set(grass_env_command ${CMAKE_COMMAND} -E env + "PATH=${BINARY_DIR}${sep}${SCRIPTS_DIR}${env_path}" + "PYTHONPATH=${ETC_PYTHON_DIR}${sep}${GUI_WXPYTHON_DIR}${sep}$ENV{PYTHONPATH}" + "LD_LIBRARY_PATH=${LIB_DIR}${sep}$ENV{LD_LIBRARY_PATH}" + "GISBASE=${GISBASE_NATIVE}" + "GISRC=${GISRC}" + "LC_ALL=C" + "LANG=C" + "LANGUAGE=C" + "MODULE_TOPDIR=${MODULE_TOPDIR}" + "VERSION_NUMBER=\"${GRASS_VERSION_NUMBER}\"" + "VERSION_DATE=\"${GRASS_VERSION_DATE}\"") + + + +set(NO_HTML_DESCR_TARGETS "g.parser;ximgview;test.raster3d.lib") +add_subdirectory(include) + +include_directories("${CMAKE_BINARY_DIR}/include") +if(MSVC) + include_directories("${CMAKE_SOURCE_DIR}/msvc") +endif() + +execute_process( + COMMAND ${CMAKE_COMMAND} -E echo "Creating directories in ${GISBASE}" + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/bin/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/scripts/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/demolocation/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/config/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/driver/db/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/tools/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/lib/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/lister/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/python/grass/lib + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/wxpython/xml/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/icons/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/images/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/docs/html/ + ) + +add_subdirectory(lib) +add_subdirectory(tools) +set(modules_list) + + +set(ALL_SUBDIRS + general + db + display + imagery + misc + raster + raster3d + scripts + vector + temporal + # ps +) + +foreach(d ${ALL_SUBDIRS}) + add_subdirectory(${d}) +endforeach() +add_custom_target(ALL_MODULES + COMMAND ${CMAKE_COMMAND} -E echo "Building all modules" + DEPENDS ${modules_list}) + +###message(FATAL_ERROR "modules_list=${modules_list}") + +if(WITH_PYTHON) + add_subdirectory(gui) +endif() + +if(WITH_DOCS) + add_subdirectory(doc) + add_subdirectory(man) +endif() # WITH_DOCS + + +####add_subdirectory(locale) + +# TODO: To be discussed +# add_subdirectory(testsuite) +# add_subdirectory(macosx) + +if(WITH_X11) + build_program_in_subdir(visualization/ximgview DEPENDS grass_gis X11) +endif() diff --git a/cmake/copy_g_gui_module.cmake b/cmake/copy_g_gui_module.cmake new file mode 100644 index 00000000000..46246dc4ca0 --- /dev/null +++ b/cmake/copy_g_gui_module.cmake @@ -0,0 +1,35 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: Copy g.gui script plus .bat file if on windows +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. +# -DSOURCE_DIR +# -DGISBASE +# -DG_NAME +# -DSRC_SCRIPT_FILE +# -DBINARY_DIR + +set(SCRIPT_EXT "") +if(WIN32) + set(SCRIPT_EXT ".py") +endif() + +if(WIN32) + set(PGM_NAME ${G_NAME}) + configure_file( + ${SOURCE_DIR}/cmake/windows_launch.bat.in + ${GISBASE}/scripts/${G_NAME}.bat @ONLY) +endif(WIN32) + +set(TMP_SCRIPT_FILE ${BINARY_DIR}/CMakeFiles/${G_NAME}${SCRIPT_EXT}) +configure_file(${SRC_SCRIPT_FILE} ${TMP_SCRIPT_FILE} COPYONLY) +file( + COPY ${TMP_SCRIPT_FILE} + DESTINATION ${GISBASE}/scripts/ + FILE_PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) + + +file(REMOVE ${TMP_SCRIPT_FILE}) diff --git a/cmake/ctypesgen.cmake b/cmake/ctypesgen.cmake new file mode 100644 index 00000000000..7fc3edd46d3 --- /dev/null +++ b/cmake/ctypesgen.cmake @@ -0,0 +1,61 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: Cmake building of lib/python/ctypes (TODO) +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. + +set(ENV{GISRC} "${BIN_DIR}/demolocation/.grassrc${GRASS_VERSION_MAJOR}${GRASS_VERSION_MINOR}") +set(ENV{GISBASE} "${BIN_DIR}") +set(ENV{PATH} "${BIN_DIR}/bin:${BIN_DIR}/scripts:$ENV{PATH}") +set(ENV{PYTHONPATH} "${BIN_DIR}/gui/wxpython:${BIN_DIR}/etc/python:$ENV{PYTHONPATH}") +if(NOT MSVC) + set(ENV{LD_LIBRARY_PATH} "${BIN_DIR}/lib:$ENV{LD_LIBRARY_PATH}") +endif() +set(ENV{LC_ALL} C) + +set(LIBRARIES) +foreach(LIB ${LIBS}) + if(WIN32) + list(APPEND LIBRARIES "--library=${BIN_DIR}/bin/${LIB}.dll") + elseif(APPLE) + list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.so") + else() + #This can be linux or unix + list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.so") + endif() +endforeach() + +set(HEADERS) +foreach(HDR ${HDRS}) + list(APPEND HEADERS "${BIN_DIR}/include/grass/${HDR}") +endforeach() + +foreach(req OUT_FILE HDRS LIBS CTYPESGEN_PY COMPILER ) + if(NOT DEFINED ${req} OR "${${req}}" STREQUAL "") + message(FATAL_ERROR "you must set ${req}") + endif() +endforeach() + +if(MSVC) + set(CTYPESFLAGS "${COMPILER} -E -DPACKAGE=\"grasslibs\"") +else() + set(CTYPESFLAGS "${COMPILER} -E -DPACKAGE=\"grasslibs\" -D__GLIBC_HAVE_LONG_LONG") +endif() + +message(STATUS "Running ${PYTHON_EXECUTABLE} ${CTYPESGEN_PY} --cpp=${CTYPESFLAGS} --includedir=\"${BIN_DIR}/include\" --runtime-libdir=\"${BIN_DIR}/lib\" ${HEADERS} ${LIBRARIES} --output=${OUT_FILE}") +execute_process( + COMMAND ${PYTHON_EXECUTABLE} ${CTYPESGEN_PY} + --cpp=${CTYPESFLAGS} + --includedir="${BIN_DIR}/include" + --runtime-libdir="${BIN_DIR}/lib" + ${HEADERS} + ${LIBRARIES} + --output=${OUT_FILE} + OUTPUT_VARIABLE ctypesgen_OV + ERROR_VARIABLE ctypesgen_EV + RESULT_VARIABLE ctypesgen_RV + ) + +if( ctypesgen_RV ) + message(FATAL_ERROR "ctypesgen.py: ${ctypesgen_EV} \n ${ctypesgen_OV}") +endif() diff --git a/cmake/find_scripts/FindCairo.cmake b/cmake/find_scripts/FindCairo.cmake new file mode 100644 index 00000000000..92a22db9a25 --- /dev/null +++ b/cmake/find_scripts/FindCairo.cmake @@ -0,0 +1,122 @@ +# - Try to find Cairo +# Once done, this will define +# +# CAIRO_FOUND - system has Cairo +# CAIRO_INCLUDE_DIRS - the Cairo include directories +# CAIRO_LIBRARIES - link these to use Cairo +# +# Copyright (C) 2012 Raphael Kubo da Costa +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS +# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +FIND_PACKAGE(PkgConfig QUIET) +PKG_CHECK_MODULES(PC_CAIRO cairo QUIET) # FIXME: After we require CMake 2.8.2 we can pass QUIET to this call. + + +FIND_PATH(CAIRO_INCLUDE_DIRS + NAMES cairo.h + HINTS ${PC_CAIRO_INCLUDEDIR} + ${PC_CAIRO_INCLUDE_DIRS} + PATH_SUFFIXES cairo +) + +FIND_LIBRARY(CAIRO_LIBRARY_RELEASE + NAMES cairo + HINTS ${PC_CAIRO_LIBDIR} + ${PC_CAIRO_LIBRARY_DIRS} +) + +FIND_LIBRARY(CAIRO_LIBRARY_DEBUG + NAMES cairod + HINTS ${PC_CAIRO_LIBDIR} + ${PC_CAIRO_LIBRARY_DIRS} +) + +set(CAIRO_LIBRARY) +if(CAIRO_LIBRARY_DEBUG) + set( CAIRO_LIBRARY ${CAIRO_LIBRARY_DEBUG}) +elseif(CAIRO_LIBRARY_RELEASE) + set( CAIRO_LIBRARY ${CAIRO_LIBRARY_RELEASE}) +endif() + + +IF (CAIRO_INCLUDE_DIRS) + IF (EXISTS "${CAIRO_INCLUDE_DIRS}/cairo-version.h") + FILE(READ "${CAIRO_INCLUDE_DIRS}/cairo-version.h" CAIRO_VERSION_CONTENT) + + STRING(REGEX MATCH "#define +CAIRO_VERSION_MAJOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}") + SET(CAIRO_VERSION_MAJOR "${CMAKE_MATCH_1}") + + STRING(REGEX MATCH "#define +CAIRO_VERSION_MINOR +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}") + SET(CAIRO_VERSION_MINOR "${CMAKE_MATCH_1}") + + STRING(REGEX MATCH "#define +CAIRO_VERSION_MICRO +([0-9]+)" _dummy "${CAIRO_VERSION_CONTENT}") + SET(CAIRO_VERSION_MICRO "${CMAKE_MATCH_1}") + + SET(CAIRO_VERSION "${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_MICRO}") + ENDIF () +ENDIF () + +# FIXME: Should not be needed anymore once we start depending on CMake 2.8.3 +SET(VERSION_OK TRUE) +IF (Cairo_FIND_VERSION) + IF (Cairo_FIND_VERSION_EXACT) + IF ("${Cairo_FIND_VERSION}" VERSION_EQUAL "${CAIRO_VERSION}") + # FIXME: Use IF (NOT ...) with CMake 2.8.2+ to get rid of the ELSE block + ELSE () + SET(VERSION_OK FALSE) + ENDIF () + ELSE () + IF ("${Cairo_FIND_VERSION}" VERSION_GREATER "${CAIRO_VERSION}") + SET(VERSION_OK FALSE) + ENDIF () + ENDIF () +ENDIF () + +find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h) + +if(FONTCONFIG_INCLUDE_DIR) + set(CAIRO_INCLUDE_DIRS ${CAIRO_INCLUDE_DIRS} ${FONTCONFIG_INCLUDE_DIR} ) +else() + message(STATUS "fontconfig/fontconfig.h was not found. \n I had to unset(CAIRO_INCLUDE_DIRS) to make find_package() fail \n ") + unset(CAIRO_INCLUDE_DIRS CACHE) +endif() + +find_library(FONTCONFIG_LIBRARY NAMES fontconfig) +if(FONTCONFIG_LIBRARY) + set(CAIRO_LIBRARIES ${CAIRO_LIBRARY} ${FONTCONFIG_LIBRARY} ) +else() + message(STATUS "fontconfig library file was not found. \n I had to unset(CAIRO_LIBRARIES) to make find_package() fail \n ") + unset(CAIRO_LIBRARIES CACHE) +endif() + +MARK_AS_ADVANCED( + CAIRO_INCLUDE_DIRS + CAIRO_LIBRARY + CAIRO_LIBRARY_RELEASE + CAIRO_LIBRARY_DEBUG + FONTCONFIG_LIBRARY + FONTCONFIG_INCLUDE_DIR + ) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cairo DEFAULT_MSG CAIRO_INCLUDE_DIRS CAIRO_LIBRARIES VERSION_OK) diff --git a/cmake/find_scripts/FindFFTW.cmake b/cmake/find_scripts/FindFFTW.cmake new file mode 100644 index 00000000000..3e0cb54928b --- /dev/null +++ b/cmake/find_scripts/FindFFTW.cmake @@ -0,0 +1,66 @@ +find_path(FFTW_INCLUDE_DIR fftw3.h) + +if(FFTW_INCLUDE_DIR) + set(HAVE_FFTW3_H 1) + message(STATUS "Found fftw3.h in ${FFTW_INCLUDE_DIR}") +else() + find_path(FFTW_INCLUDE_DIR fftw.h) + if(FFTW_INCLUDE_DIR) + set(HAVE_FFTW_H 1) + message(STATUS "Found fftw.h in ${FFTW_INCLUDE_DIR}") + endif() +endif() + +find_path(DFFTW_INCLUDE_DIR dfftw.h) +if(DFFTW_INCLUDE_DIR) + set(HAVE_DFFTW_H 1) + message(STATUS "Found dfftw.h in ${FFTW_INCLUDE_DIR}") +endif() + +#fftw double lib +find_library(FFTWD_LIB fftw3 ) +find_library(FFTWD_THREADS_LIB fftw3_threads) # threads support + +set(FFTW_LIBRARIES) +if(FFTWD_LIB) + set(FFTWD_FOUND 1) + set(FFTW_LIBRARIES ${FFTWD_LIB}) + if(FFTWD_THREADS_LIB) + set(FFTW_LIBRARIES "${FFTW_LIBRARIES};${FFTWD_THREADS_LIB}") + endif() +endif() + +#Single Precision +find_library(FFTWF_LIB fftw3f) +find_library(FFTWF_THREADS_LIB fftw3f_threads) #threads support + +if(FFTWF_LIB) + set(FFTWF_FOUND 1) + set(FFTW_LIBRARIES "${FFTW_LIBRARIES};${FFTWF_LIB}") + if(FFTWF_THREADS_LIB) + set(FFTW_LIBRARIES "${FFTW_LIBRARIES};${FFTWF_THREADS_LIB}") + endif() +endif() + +if(NOT FFTWD_FOUND AND NOT FFTWF_FOUND ) + set(FFTW_FOUND FALSE) +endif() + +MARK_AS_ADVANCED( + FFTW_LIBRARIES + FFTW_INCLUDE_DIR + DFFTW_INCLUDE_DIR + FFTWF_LIB + FFTWF_THREADS_LIB + FFTWD_LIB + FFTWD_THREADS_LIB +) + + +#copy HAVE_ to parent scope so that we can use in include/CMakeLists.txt and rest +set(HAVE_FFTW3_H ${HAVE_FFTW3_H} PARENT_SCOPE) +set(HAVE_FFTW_H ${HAVE_FFTW_H} PARENT_SCOPE) +set(HAVE_DFFTW_H ${HAVE_DFFTW_H} PARENT_SCOPE) +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(FFTW + REQUIRED_VARS FFTW_LIBRARIES FFTW_INCLUDE_DIR) diff --git a/cmake/find_scripts/FindFontConfig.cmake b/cmake/find_scripts/FindFontConfig.cmake new file mode 100644 index 00000000000..540aef0d2af --- /dev/null +++ b/cmake/find_scripts/FindFontConfig.cmake @@ -0,0 +1,35 @@ +# - Find FontConfig library +# Find the FontConfig includes and library +# This module defines +# FONTCONFIG_INCLUDE_DIR, where to find fontconfig.h +# FONTCONFIG_LIBRARIES, libraries to link against to use the FontConfig API. +# FONTCONFIG_FOUND, If false, do not try to use FontConfig. + +#============================================================================= +# Copyright 2012 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of VTK, substitute the full +# License text for the above reference.) + +find_path(FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h) + +find_library(FONTCONFIG_LIBRARY NAMES fontconfig) + +# handle the QUIETLY and REQUIRED arguments and set FONTCONFIG_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FontConfig DEFAULT_MSG + FONTCONFIG_LIBRARY FONTCONFIG_INCLUDE_DIR) + +if(FONTCONFIG_FOUND) + set( FONTCONFIG_LIBRARIES ${FONTCONFIG_LIBRARY} ) +endif() + +mark_as_advanced(FONTCONFIG_INCLUDE_DIR FONTCONFIG_LIBRARY FONTCONFIG_LIBRARIES) diff --git a/cmake/find_scripts/FindGDAL.cmake b/cmake/find_scripts/FindGDAL.cmake new file mode 100644 index 00000000000..77af178bc3d --- /dev/null +++ b/cmake/find_scripts/FindGDAL.cmake @@ -0,0 +1,23 @@ +find_path(GDAL_INCLUDE_DIR gdal.h PATH_SUFFIXES gdal) + +find_library(GDAL_LIBRARY_RELEASE NAMES gdal_i gdal) +find_library(GDAL_LIBRARY_DEBUG NAMES gdald) +set(GDAL_FOUND FALSE) + +set(GDAL_LIBRARY) +if(GDAL_LIBRARY_DEBUG) + set( GDAL_LIBRARY ${GDAL_LIBRARY_DEBUG} CACHE FILEPATH "doc" ) +elseif(GDAL_LIBRARY_RELEASE) + set( GDAL_LIBRARY ${GDAL_LIBRARY_RELEASE} CACHE FILEPATH "doc" ) +endif() + +mark_as_advanced(GDAL_LIBRARY_RELEASE) +mark_as_advanced(GDAL_LIBRARY_DEBUG) +mark_as_advanced(GDAL_LIBRARY) +mark_as_advanced(GDAL_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( GDAL DEFAULT_MSG + GDAL_LIBRARY + GDAL_INCLUDE_DIR ) + diff --git a/cmake/find_scripts/FindGEOS.cmake b/cmake/find_scripts/FindGEOS.cmake new file mode 100644 index 00000000000..b1b03377f9e --- /dev/null +++ b/cmake/find_scripts/FindGEOS.cmake @@ -0,0 +1,57 @@ +#--- +# File: FindGEOS.cmake +# +# Find the native GEOS(Geometry Engine - Open Source) includes and libraries. +# +# This module defines: +# +# GEOS_INCLUDE_DIR, where to find geos.h, etc. +# GEOS_LIBRARY, libraries to link against to use GEOS. Currently there are +# two looked for, geos and geos_c libraries. +# GEOS_FOUND, True if found, false if one of the above are not found. +# +# For ossim, typically geos will be system installed which should be found; +# or found in the ossim 3rd party dependencies directory from a geos build +# and install. If the latter it will rely on CMAKE_INCLUDE_PATH and +# CMAKE_LIBRARY_PATH having the path to the party dependencies directory. +# +# NOTE: +# This script is specialized for ossim, e.g. looking in /usr/local/ossim. +# +# $Id$ +#--- + +#--- +# Find include path: +# Note: Ubuntu 14.04+ did not have geos.h (not included in any ossim src). +# Instead looking for Geometry.h +#--- + +find_path( GEOS_INCLUDE_DIR geos_c.h) + +# Find GEOS C library: +find_library( GEOS_C_LIBRARY_RELEASE NAMES geos_c ) +find_library( GEOS_C_LIBRARY_DEBUG NAMES geos_cd ) +set(GEOS_FOUND FALSE) + +set(GEOS_C_LIBRARY) +if(GEOS_C_LIBRARY_DEBUG) + set(GEOS_C_LIBRARY ${GEOS_C_LIBRARY_DEBUG}) +elseif(GEOS_C_LIBRARY_RELEASE) + set(GEOS_C_LIBRARY ${GEOS_C_LIBRARY_RELEASE}) +endif() + +MARK_AS_ADVANCED( + GEOS_INCLUDE_DIR + GEOS_C_LIBRARY + GEOS_C_LIBRARY_RELEASE + GEOS_C_LIBRARY_DEBUG) + +#--- +# This function sets GEOS_FOUND if variables are valid. +#--- +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( GEOS DEFAULT_MSG + GEOS_C_LIBRARY + GEOS_INCLUDE_DIR ) + diff --git a/cmake/find_scripts/FindIconv.cmake b/cmake/find_scripts/FindIconv.cmake new file mode 100644 index 00000000000..028df5c1ae5 --- /dev/null +++ b/cmake/find_scripts/FindIconv.cmake @@ -0,0 +1,58 @@ +# - Try to find Iconv +# Once done this will define +# +# ICONV_FOUND - system has Iconv +# ICONV_INCLUDE_DIR - the Iconv include directory +# ICONV_LIBRARIES - Link these to use Iconv +# ICONV_SECOND_ARGUMENT_IS_CONST - the second argument for iconv() is const +# +include(CheckCXXSourceCompiles) + +IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + # Already in cache, be silent + SET(ICONV_FIND_QUIETLY TRUE) +ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + +FIND_PATH(ICONV_INCLUDE_DIR iconv.h) + +FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv-2 c) + +IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + SET(ICONV_FOUND TRUE) +ENDIF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) + +set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) +set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) +IF(ICONV_FOUND) + check_cxx_source_compiles(" + #include + int main(){ + iconv_t conv = 0; + const char* in = 0; + size_t ilen = 0; + char* out = 0; + size_t olen = 0; + iconv(conv, &in, &ilen, &out, &olen); + return 0; + } +" ICONV_SECOND_ARGUMENT_IS_CONST ) +ENDIF(ICONV_FOUND) +set(CMAKE_REQUIRED_INCLUDES) +set(CMAKE_REQUIRED_LIBRARIES) + +IF(ICONV_FOUND) + IF(NOT ICONV_FIND_QUIETLY) + MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}") + ENDIF(NOT ICONV_FIND_QUIETLY) +ELSE(ICONV_FOUND) + IF(Iconv_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find Iconv") + ENDIF(Iconv_FIND_REQUIRED) +ENDIF(ICONV_FOUND) + +MARK_AS_ADVANCED( + ICONV_INCLUDE_DIR + ICONV_LIBRARIES + ICONV_SECOND_ARGUMENT_IS_CONST +) + diff --git a/cmake/find_scripts/FindLibLAS.cmake b/cmake/find_scripts/FindLibLAS.cmake new file mode 100644 index 00000000000..75383dc818c --- /dev/null +++ b/cmake/find_scripts/FindLibLAS.cmake @@ -0,0 +1,35 @@ +find_path(LibLAS_INCLUDE_DIR + NAMES liblas.h + PATH_SUFFIXES capi + PATH_SUFFIXES liblas/capi + DOC "path to liblas.h") + +find_library(LibLAS_C_LIBRARY + NAMES liblas_c las_c las + # Help the user find it if we cannot. + DOC "path liblas_c library") + +if (LibLAS_INCLUDE_DIR) + unset(las_version_CONTENTS) + file(READ "${LibLAS_INCLUDE_DIR}/las_version.h" las_version_CONTENTS) + + STRING(REGEX MATCH "#define +LIBLAS_VERSION_MAJOR +([0-9]+)" _dummy "${las_version_CONTENTS}") + SET(LibLAS_VERSION_MAJOR "${CMAKE_MATCH_1}") + string(REGEX MATCH "#define +LIBLAS_VERSION_MINOR +([0-9])" _dummy "${las_version_CONTENTS}") + set(LibLAS_VERSION_MINOR "${CMAKE_MATCH_1}") + string(REGEX MATCH "#define +LIBLAS_VERSION_REV +([0-9])" _dummy "${las_version_CONTENTS}") + set(LIBLAS_VERSION_REV "${CMAKE_MATCH_1}") + + set(LibLAS_VERSION_STRING + "${LibLAS_VERSION_MAJOR}.${LibLAS_VERSION_MINOR}.${LIBLAS_VERSION_REV}") +endif() + #message(FATAL_ERROR "LibLAS_LIBRARY=${LibLAS_LIBRARY}") +if(LibLAS_INCLUDE_DIR AND LibLAS_C_LIBRARY) + set(LibLAS_FOUND TRUE) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + LibLAS + REQUIRED_VARS LibLAS_C_LIBRARY LibLAS_INCLUDE_DIR + VERSION_VAR LibLAS_VERSION_STRING) diff --git a/cmake/find_scripts/FindNetCDF.cmake b/cmake/find_scripts/FindNetCDF.cmake new file mode 100644 index 00000000000..d25e9ffab8a --- /dev/null +++ b/cmake/find_scripts/FindNetCDF.cmake @@ -0,0 +1,14 @@ +find_path(NetCDF_INCLUDE_DIR + NAMES netcdf.h + DOC "path to netcdf.h") + +find_library(NetCDF_LIBRARY + NAMES netcdf + DOC "path netcdf library") + +if(NetCDF_INCLUDE_DIR AND NetCDF_LIBRARY) + set(NetCDF_FOUND TRUE) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NetCDF REQUIRED_VARS NetCDF_LIBRARY NetCDF_INCLUDE_DIR) diff --git a/cmake/find_scripts/FindPCRE.cmake b/cmake/find_scripts/FindPCRE.cmake new file mode 100644 index 00000000000..fb329d930d0 --- /dev/null +++ b/cmake/find_scripts/FindPCRE.cmake @@ -0,0 +1,32 @@ + +find_path(PCRE_INCLUDE_DIR NAMES pcre.h) + +find_library(PCRE_LIBRARY_RELEASE NAMES pcre) +find_library(PCRE_LIBRARY_DEBUG NAMES pcred) +if(PCRE_LIBRARY_DEBUG) +set(PCRE_LIBRARY ${PCRE_LIBRARY_DEBUG}) +elseif(PCRE_LIBRARY_RELEASE) +set(PCRE_LIBRARY ${PCRE_LIBRARY_RELEASE}) +endif() + +set(PCRE_FOUND FALSE) +if(PCRE_INCLUDE_DIR AND PCRE_LIBRARY) + set(PCRE_FOUND TRUE) +endif() + +if(PCRE_FOUND) + set(PCRE_LIBRARIES ${PCRE_LIBRARY}) + set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) +endif() + +mark_as_advanced(PCRE_LIBRARY) +mark_as_advanced(PCRE_LIBRARY_DEBUG) +mark_as_advanced(PCRE_LIBRARY_RELEASE) +mark_as_advanced(PCRE_INCLUDE_DIR) +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE + DEFAULT_MSG + PCRE_LIBRARY + PCRE_INCLUDE_DIR) + + diff --git a/cmake/find_scripts/FindPROJ.cmake b/cmake/find_scripts/FindPROJ.cmake new file mode 100644 index 00000000000..cc579ed5116 --- /dev/null +++ b/cmake/find_scripts/FindPROJ.cmake @@ -0,0 +1,58 @@ +############################################################################### +# CMake module to search for PROJ.4 library +# +# On success, the macro sets the following variables: +# PROJ_FOUND = if the library found +# PROJ_LIBRARY = full path to the library +# PROJ_INCLUDE_DIR = where to find the library headers +# also defined, but not for general use are +# PROJ_LIBRARY, where to find the PROJ.4 library. +# +# Copyright (c) 2009 Mateusz Loskot +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# +############################################################################### + +FIND_PATH(PROJ_INCLUDE_DIR proj_api.h DOC "Path to PROJ.4 include directory") + +if(EXISTS "${PROJ_INCLUDE_DIR}/proj_api.h") + file(READ "${PROJ_INCLUDE_DIR}/proj_api.h" proj_h_header) + string(REGEX MATCH "#define +PJ_VERSION +([0-9]+)" _dummy "${proj_h_header}") + set(PROJ_VERSION_STRING "${CMAKE_MATCH_1}" CACHE INTERNAL "PROJ.4 version string") +endif() +FIND_LIBRARY(PROJ_LIBRARY_RELEASE + NAMES proj proj_i + DOC "Path to PROJ library file") + +FIND_LIBRARY(PROJ_LIBRARY_DEBUG + NAMES projd + DOC "Path to PROJ debug library file") + +set(PROJ_LIBRARY) +if(PROJ_LIBRARY_DEBUG) + set( PROJ_LIBRARY ${PROJ_LIBRARY_DEBUG}) +elseif(PROJ_LIBRARY_RELEASE) + set( PROJ_LIBRARY ${PROJ_LIBRARY_RELEASE}) +endif() + +if(PROJ_INCLUDE_DIR AND PROJ_LIBRARY) +set(PROJ_FOUND TRUE) +endif() + +MARK_AS_ADVANCED( + PROJ_INCLUDE_DIR + PROJ_LIBRARY + PROJ_LIBRARY_DEBUG + PROJ_LIBRARY_RELEASE +) + +# Handle the QUIETLY and REQUIRED arguments and set SPATIALINDEX_FOUND to TRUE +# if all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ + FOUND_VAR PROJ_FOUND + REQUIRED_VARS PROJ_LIBRARY PROJ_INCLUDE_DIR PROJ_VERSION_STRING + VERSION_VAR PROJ_VERSION_STRING) + diff --git a/cmake/find_scripts/FindPostgreSQL.cmake b/cmake/find_scripts/FindPostgreSQL.cmake new file mode 100644 index 00000000000..74fc4901d8d --- /dev/null +++ b/cmake/find_scripts/FindPostgreSQL.cmake @@ -0,0 +1,126 @@ +#]=======================================================================] + +# ---------------------------------------------------------------------------- +# History: +# This module is derived from the module originally found in the VTK source tree. +# +# ---------------------------------------------------------------------------- +# Note: +# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the +# version number of the implementation of PostgreSQL. +# In Windows the default installation of PostgreSQL uses that as part of the path. +# E.g C:\Program Files\PostgreSQL\8.4. +# Currently, the following version numbers are known to this module: +# "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# +# To use this variable just do something like this: +# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") +# before calling find_package(PostgreSQL) in your CMakeLists.txt file. +# This will mean that the versions you set here will be found first in the order +# specified before the default ones are searched. +# +# ---------------------------------------------------------------------------- +# You may need to manually set: +# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are. +# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are. +# If FindPostgreSQL.cmake cannot find the include files or the library files. +# +# ---------------------------------------------------------------------------- +# The following variables are set if PostgreSQL is found: +# PostgreSQL_FOUND - Set to true when PostgreSQL is found. +# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL +# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries +# PostgreSQL_LIBRARIES - The PostgreSQL libraries. +# +# The ``PostgreSQL::PostgreSQL`` imported target is also created. +# +# ---------------------------------------------------------------------------- +# If you have installed PostgreSQL in a non-standard location. +# (Please note that in the following comments, it is assumed that +# points to the root directory of the include directory of PostgreSQL.) +# Then you have three options. +# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to /include and +# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is +# 2) Use CMAKE_INCLUDE_PATH to set a path to /PostgreSQL<-version>. This will allow find_path() +# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file +# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "/include") +# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have +# installed PostgreSQL, e.g. . +# +# ---------------------------------------------------------------------------- +find_path(PostgreSQL_INCLUDE_DIR + NAMES libpq-fe.h + PATH_SUFFIXES + pgsql + postgresql + include + + # Help the user find it if we cannot. + DOC "path to libpq-fe.h" +) + +find_path(PostgreSQL_TYPE_INCLUDE_DIR + NAMES catalog/pg_type.h + PATH_SUFFIXES + postgresql + pgsql/server + postgresql/server + postgresql/9.5/server + include/server + + # Help the user find it if we cannot. + DOC "path to postgresql header catalog/pg_type.h" +) + +find_library(PostgreSQL_LIBRARY + NAMES libpqd pqd libpq pq + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}") + +get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH) + +if (PostgreSQL_INCLUDE_DIR) + # Some platforms include multiple pg_config.hs for multi-lib configurations + # This is a temporary workaround. A better solution would be to compile + # a dummy c file and extract the value of the symbol. + file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h") + foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS}) + if(EXISTS "${_PG_CONFIG_HEADER}") + file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str + REGEX "^#define[\t ]+PG_VERSION_NUM[\t ]+.*") + if(pgsql_version_str) + string(REGEX REPLACE "^#define[\t ]+PG_VERSION_NUM[\t ]+([0-9]*).*" + "\\1" _PostgreSQL_VERSION_NUM "${pgsql_version_str}") + break() + endif() + endif() + endforeach() + if (_PostgreSQL_VERSION_NUM) + math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000") + math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000") + set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}") + unset(_PostgreSQL_major_version) + unset(_PostgreSQL_minor_version) + else () + foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS}) + if(EXISTS "${_PG_CONFIG_HEADER}") + file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str + REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"") + if(pgsql_version_str) + string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*" + "\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}") + break() + endif() + endif() + endforeach() + endif () + unset(_PostgreSQL_VERSION_NUM) + unset(pgsql_version_str) +endif() + +# Did we find anything? +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PostgreSQL + REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR + VERSION_VAR PostgreSQL_VERSION_STRING) +set(PostgreSQL_FOUND ${POSTGRESQL_FOUND}) diff --git a/cmake/find_scripts/FindSQLite.cmake b/cmake/find_scripts/FindSQLite.cmake new file mode 100644 index 00000000000..c49858c4ef7 --- /dev/null +++ b/cmake/find_scripts/FindSQLite.cmake @@ -0,0 +1,8 @@ +find_path(SQLITE_INCLUDE_DIR sqlite3.h) +find_library(SQLITE_LIBRARY NAMES sqlite3 ) + +mark_as_advanced(SQLITE_LIBRARY) +mark_as_advanced(SQLITE_INCLUDE_DIR) + +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE REQUIRED_VARS SQLITE_LIBRARY SQLITE_INCLUDE_DIR) diff --git a/cmake/locale_strings.cmake b/cmake/locale_strings.cmake new file mode 100644 index 00000000000..79a42843ee9 --- /dev/null +++ b/cmake/locale_strings.cmake @@ -0,0 +1,82 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: create translation strings for grass scripts +# environment. TODO use custom_command POST_BUILD directly +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. +#-DBINARY_DIR= +#-DG_NAME= +#-DSRC_SCRIPT_FILE= +#-DOUTPUT_FILE= +#-DSOURCE_DIR= + +set(GISBASE ${BINARY_DIR}/gisbase) +file(TO_NATIVE_PATH "${GISBASE}" GISBASE_NATIVE) +file(TO_NATIVE_PATH "${GISBASE}/etc/config/rc" GISRC) +file(TO_NATIVE_PATH "${BINARY_DIR}/bin" BINARY_DIR) +file(TO_NATIVE_PATH "${BINARY_DIR}/lib" LIB_DIR) +file(TO_NATIVE_PATH "${SOURCE_DIR}" MODULE_TOPDIR) +file(TO_NATIVE_PATH "${GISBASE}/scripts" SCRIPTS_DIR) +file(TO_NATIVE_PATH "${GISBASE}/etc/python" ETC_PYTHON_DIR) +file(TO_NATIVE_PATH "${GISBASE}/gui/wxpython" GUI_WXPYTHON_DIR) + +if(WIN32) + set(sep "\;") + set(env_path "") +else() + set(sep ":") + set(env_path ":$ENV{PATH}") +endif() + +set(ENV{GISBASE} "${GISBASE_NATIVE}") +set(ENV{GISRC} ${GISRC}) +set(ENV{PATH} "${BINARY_DIR}${sep}${SCRIPTS_DIR}${env_path}") +set(ENV{PYTHONPATH} "${ETC_PYTHON_DIR}${sep}${GUI_WXPYTHON_DIR}${sep}$ENV{PYTHONPATH}") +if(NOT MSVC) + set(ENV{LD_LIBRARY_PATH} "${LIB_DIR}${sep}$ENV{LD_LIBRARY_PATH}") +endif() +set(ENV{LC_ALL} C) +set(ENV{LANG} C) +set(ENV{LANGUAGE} C) +set(ENV{MODULE_TOPDIR} ${MODULE_TOPDIR}) + +set(SCRIPT_EXT "") +if(WIN32) + set(SCRIPT_EXT ".py") +endif() + +if(WIN32) + set(PGM_NAME ${G_NAME}) + configure_file( + ${SOURCE_DIR}/cmake/windows_launch.bat.in + ${GISBASE}/scripts/${G_NAME}.bat @ONLY) +endif(WIN32) + +set(TMP_SCRIPT_FILE ${BINARY_DIR}/CMakeFiles/${G_NAME}${SCRIPT_EXT}) +configure_file(${SRC_SCRIPT_FILE} ${TMP_SCRIPT_FILE} COPYONLY) +file( + COPY ${TMP_SCRIPT_FILE} + DESTINATION ${GISBASE}/scripts/ + FILE_PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) + + +execute_process(COMMAND + ${BINARY_DIR}/bin/g.parser -t ${GISBASE}/scripts/${G_NAME}${SCRIPT_EXT} + OUTPUT_VARIABLE run_g_parser_OV + ERROR_VARIABLE run_g_parser_EV + RESULT_VARIABLE run_g_parser_RV) + +string(REGEX REPLACE "\n" ";" varname "${run_g_parser_OV}") +set(output_to_write) +foreach(line ${varname}) + string(REPLACE "\"" "\\\"" line "${line}") + set(line "_(\"${line}\")") + list(APPEND output_to_write "${line}") +endforeach() + +string(REGEX REPLACE ";" "\n" output_to_write "${output_to_write}") +file(WRITE "${OUTPUT_FILE}" "${output_to_write}\n") +file(REMOVE ${TMP_SCRIPT_FILE}) diff --git a/cmake/modules/build_gui_in_subdir.cmake b/cmake/modules/build_gui_in_subdir.cmake new file mode 100644 index 00000000000..12d51e64d9a --- /dev/null +++ b/cmake/modules/build_gui_in_subdir.cmake @@ -0,0 +1,107 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: build_gui_in_subdir is the cmake function that builds g.gui.* modules +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. + +function(build_gui_in_subdir dir_name) + set(G_NAME ${dir_name}) + set(G_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${G_NAME}) + set(G_TARGET_NAME g.gui.${G_NAME}) + + set(HTML_FILE_NAME ${G_TARGET_NAME}) + + file(GLOB PYTHON_FILES "${G_SRC_DIR}/*.py") + if(NOT PYTHON_FILES) + message(FATAL_ERROR "[${G_TARGET_NAME}]: No PYTHON_FILES found.") + endif() + + set(SRC_SCRIPT_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${G_NAME}/${G_TARGET_NAME}.py) + + if (NOT EXISTS ${SRC_SCRIPT_FILE}) + message(FATAL_ERROR "${SRC_SCRIPT_FILE} does not exists") + endif() + + + set(SCRIPT_EXT "") + if(WIN32) + set(SCRIPT_EXT ".py") + endif() + set(GUI_STAMP_FILE ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${G_NAME}.stamp) + + ADD_CUSTOM_COMMAND(OUTPUT ${GUI_STAMP_FILE} + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/wxpython/${G_NAME}/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PYTHON_FILES} ${GISBASE}/gui/wxpython/${G_NAME}/ + COMMAND ${CMAKE_COMMAND} -E touch ${GUI_STAMP_FILE}) + + set(OUT_SCRIPT_FILE ${GISBASE}/scripts/${G_TARGET_NAME}${SCRIPT_EXT}) + ADD_CUSTOM_COMMAND(OUTPUT ${OUT_SCRIPT_FILE} + COMMAND ${CMAKE_COMMAND} + -DSOURCE_DIR=${CMAKE_SOURCE_DIR} + -DBINARY_DIR=${CMAKE_BINARY_DIR} + -DSRC_SCRIPT_FILE=${SRC_SCRIPT_FILE} + -DG_NAME=${G_TARGET_NAME} + -DGISBASE=${GISBASE} + -P ${CMAKE_SOURCE_DIR}/cmake/copy_g_gui_module.cmake + DEPENDS g.parser ${SRC_SCRIPT_FILE}) + + + if(WITH_DOCS) + + file(GLOB IMG_FILES ${G_SRC_DIR}/*.png ${G_SRC_DIR}/*.jpg) + set(copy_images_command ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${G_TARGET_NAME}) + if(IMG_FILES) + set(copy_images_command ${CMAKE_COMMAND} -E copy ${IMG_FILES} ${GISBASE}/docs/html/) + endif() + + set(HTML_FILE ${G_SRC_DIR}/${G_TARGET_NAME}.html) + if(EXISTS ${HTML_FILE}) + install(FILES ${GISBASE}/docs/html/${G_TARGET_NAME}.html DESTINATION docs/html) + else() + set(HTML_FILE) + file(GLOB html_files ${G_SRC_DIR}/*.html) + if(html_files) + message(FATAL_ERROR "${html_file} does not exists. ${G_SRC_DIR} \n ${GISBASE}/scripts| ${G_TARGET_NAME}") + endif() + endif() + + set(TMP_HTML_FILE ${G_SRC_DIR}/${G_TARGET_NAME}.tmp.html) + set(OUT_HTML_FILE ${GISBASE}/docs/html/${G_TARGET_NAME}.html) + set(GUI_HTML_FILE ${GISBASE}/docs/html/wxGUI.${G_NAME}.html) + + ADD_CUSTOM_COMMAND(OUTPUT ${OUT_HTML_FILE} + COMMAND ${grass_env_command} ${CMAKE_COMMAND} -E chdir ${G_SRC_DIR} + ${PYTHON_EXECUTABLE} ${G_TARGET_NAME}.py "--html-description" > ${TMP_HTML_FILE} + COMMAND ${grass_env_command} ${CMAKE_COMMAND} -E chdir ${G_SRC_DIR} + ${PYTHON_EXECUTABLE} ${MKHTML_PY} ${G_TARGET_NAME} ${GRASS_VERSION_DATE} > ${OUT_HTML_FILE} + COMMENT "Creating ${OUT_HTML_FILE}" + COMMAND ${copy_images_command} + COMMAND ${CMAKE_COMMAND} -E remove ${TMP_HTML_FILE} + COMMAND ${grass_env_command} ${CMAKE_COMMAND} -E chdir ${G_SRC_DIR} + ${PYTHON_EXECUTABLE} ${MKHTML_PY} ${G_TARGET_NAME} ${GRASS_VERSION_DATE} > ${GUI_HTML_FILE} + COMMENT "Creating ${GUI_HTML_FILE}" + DEPENDS ${OUT_SCRIPT_FILE} GUI_WXPYTHON LIB_PYTHON + ) + + install(FILES ${OUT_HTML_FILE} DESTINATION docs/html/) + + endif() #WITH_DOCS + + + ADD_CUSTOM_TARGET(${G_TARGET_NAME} + DEPENDS ${GUI_STAMP_FILE} ${OUT_SCRIPT_FILE} ${OUT_HTML_FILE}) + + + set(modules_list "${G_TARGET_NAME};${modules_list}" CACHE INTERNAL "list of modules") + + set_target_properties (${G_TARGET_NAME} PROPERTIES FOLDER gui) + + + if(WIN32) + install(PROGRAMS ${GISBASE}/scripts/${G_TARGET_NAME}.bat DESTINATION scripts) + endif() + + install(PROGRAMS ${GISBASE}/scripts/${G_TARGET_NAME}${SCRIPT_EXT} DESTINATION scripts) + + +endfunction() diff --git a/cmake/modules/build_library_in_subdir.cmake b/cmake/modules/build_library_in_subdir.cmake new file mode 100644 index 00000000000..44415bea900 --- /dev/null +++ b/cmake/modules/build_library_in_subdir.cmake @@ -0,0 +1,16 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: This is the macro to make grass libraries through build_module function. +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. + +macro(build_library_in_subdir dir_name) + set (extra_args ${ARGN}) + if ("NAME" IN_LIST extra_args) + build_module(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${dir_name} ${ARGN} ) + else() + get_filename_component(g_name ${dir_name} NAME) + #message("dir_name=${dir_name} |g_name= ${g_name}") + build_module(NAME grass_${g_name} SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${dir_name} ${ARGN}) + endif() +endmacro() \ No newline at end of file diff --git a/cmake/modules/build_module.cmake b/cmake/modules/build_module.cmake new file mode 100644 index 00000000000..9a87e5d03e6 --- /dev/null +++ b/cmake/modules/build_module.cmake @@ -0,0 +1,271 @@ + +# AUTHOR(S): Rashad Kanavath +# PURPOSE: This is the main function that builds all grass libraries (prefixed with grass_) +# and grass exeuctables. This cmake function is tailored to meet requirement of grass gnu make rules +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. + +include(GenerateExportHeader) +function(build_module) + cmake_parse_arguments(G + "EXE" + "NAME;SRCDIR;SRC_REGEX;RUNTIME_OUTPUT_DIR;PACKAGE;HTML_FILE_NAME" + "SOURCES;INCLUDES;DEPENDS;OPTIONAL_DEPENDS;PRIMARY_DEPENDS;DEFS;HEADERS;TEST_SOURCES" + ${ARGN} ) + + if(NOT G_NAME) + message(FATAL_ERROR "G_NAME empty") + endif() + + foreach(PRIMARY_DEPEND ${G_PRIMARY_DEPENDS}) + if (NOT TARGET ${PRIMARY_DEPEND}) + message(STATUS "${G_NAME} disabled because ${PRIMARY_DEPEND} is not available") + return() + else() + list(APPEND G_DEPENDS ${PRIMARY_DEPEND}) + endif() + endforeach() + + if(NOT G_SRC_REGEX) + set(G_SRC_REGEX "*.c") + endif() + + if(NOT G_SRCDIR) + set(G_SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}) + endif() + set(html_file "${G_SRCDIR}/${G_NAME}.html") + + foreach(G_HEADER ${G_HEADERS}) + if( EXISTS "${G_SRCDIR}/${G_HEADER}" ) + file(COPY ${G_SRCDIR}/${G_HEADER} DESTINATION "${CMAKE_BINARY_DIR}/include/grass") + else() + file(GLOB header_list_from_glob LIST_DIRECTORIES false "${G_SRCDIR}/${G_HEADER}") + if(NOT header_list_from_glob) + message(FATAL_ERROR "MUST copy '${G_SRCDIR}/${G_HEADER}' to ${CMAKE_BINARY_DIR}/include/grass") + endif() + foreach(header_I ${header_list_from_glob}) + file(COPY ${header_I} DESTINATION "${CMAKE_BINARY_DIR}/include/grass") + endforeach() + endif() + endforeach() + + if(NOT G_SOURCES) + file(GLOB ${G_NAME}_SRCS "${G_SRCDIR}/${G_SRC_REGEX}") + else() + set(${G_NAME}_SRCS ${G_SOURCES}) + endif() + + if(G_EXE) + add_executable(${G_NAME} ${${G_NAME}_SRCS}) + if("${G_NAME}" MATCHES "^v.*") + set_target_properties (${G_NAME} PROPERTIES FOLDER vector) + elseif("${G_NAME}" MATCHES "^r.*") + set_target_properties (${G_NAME} PROPERTIES FOLDER raster) + else() + set_target_properties (${G_NAME} PROPERTIES FOLDER bin) + endif() + set(default_html_file_name ${G_NAME}) + set(PGM_NAME ${G_NAME}) + if(WIN32) + set(PGM_NAME ${G_NAME}.exe) + endif() + + set(modules_list "${G_NAME};${modules_list}" CACHE INTERNAL "list of modules") + + + else() + add_library(${G_NAME} ${${G_NAME}_SRCS}) + set_target_properties (${G_NAME} PROPERTIES FOLDER lib) + set_target_properties(${G_NAME} PROPERTIES OUTPUT_NAME ${G_NAME}.${GRASS_VERSION_NUMBER}) + set(export_file_name "${CMAKE_BINARY_DIR}/include/export/${G_NAME}_export.h") + # Default is to use library target name without grass_ prefix + string(REPLACE "grass_" "" default_html_file_name ${G_NAME}) + set(PGM_NAME ${default_html_file_name}) + + generate_export_header(${G_NAME} + STATIC_DEFINE "STATIC_BUILD" + EXPORT_FILE_NAME ${export_file_name}) + endif() + + if(G_HTML_FILE_NAME) + set(HTML_FILE_NAME ${G_HTML_FILE_NAME}) + else() + set(HTML_FILE_NAME ${default_html_file_name}) + endif() + + get_property(MODULE_LIST GLOBAL PROPERTY MODULE_LIST) + set_property(GLOBAL PROPERTY MODULE_LIST "${MODULE_LIST};${G_NAME}") + + add_dependencies(${G_NAME} copy_header) + + foreach(G_OPTIONAL_DEPEND ${G_OPTIONAL_DEPENDS}) + if(TARGET ${G_OPTIONAL_DEPEND}) + add_dependencies(${G_NAME} ${G_OPTIONAL_DEPEND}) + endif() + endforeach() + foreach(G_DEPEND ${G_DEPENDS}) + if(NOT TARGET ${G_DEPEND}) + message(FATAL_ERROR "${G_DEPEND} not a target") + break() + endif() + + add_dependencies(${G_NAME} ${G_DEPEND}) + + set(${G_NAME}_INCLUDE_DIRS) + list(APPEND ${G_NAME}_INCLUDE_DIRS "${G_SRCDIR}") + foreach(G_INCLUDE ${G_INCLUDES}) + list(APPEND ${G_NAME}_INCLUDE_DIRS "${G_INCLUDE}") + endforeach() + + if(${G_NAME}_INCLUDE_DIRS) + list(REMOVE_DUPLICATES ${G_NAME}_INCLUDE_DIRS ) + endif() + + target_include_directories(${G_NAME} PUBLIC ${${G_NAME}_INCLUDE_DIRS}) + endforeach() + + foreach(G_DEF ${G_DEFS}) + target_compile_definitions(${G_NAME} PUBLIC "${G_DEF}") + endforeach() + + set(package_define) + if(NOT G_PACKAGE) + if(G_EXE) + set(package_define "grassmods") + else() + set(package_define "grasslibs") + endif() + else() + if(NOT G_PACKAGE STREQUAL "NONE") + set(package_define ${G_PACKAGE}) + endif() + endif() + + target_compile_definitions(${G_NAME} PRIVATE "-DPACKAGE=\"${package_define}\"") + + foreach(dep ${G_DEPENDS} ${G_OPTIONAL_DEPENDS}) + if(TARGET ${dep}) + get_target_property(interface_def ${dep} INTERFACE_COMPILE_DEFINITIONS) + if(interface_def) + target_compile_definitions(${G_NAME} PRIVATE "${interface_def}") + endif() + endif() + target_link_libraries(${G_NAME} ${dep}) + endforeach() + + set(RUN_HTML_DESCR TRUE) + # Auto set if to run RUN_HTML_DESCR + if(G_EXE) + set(RUN_HTML_DESCR TRUE) + if (G_RUNTIME_OUTPUT_DIR) + set(RUN_HTML_DESCR FALSE) + endif() + # g.parser and some others does not have --html-description. + if( ${G_NAME} IN_LIST NO_HTML_DESCR_TARGETS) + set(RUN_HTML_DESCR FALSE) + endif() + else() + set(RUN_HTML_DESCR FALSE) + endif() + + set(install_dest "") + if(NOT G_RUNTIME_OUTPUT_DIR) + if(G_EXE) + set(G_RUNTIME_OUTPUT_DIR "${GISBASE}/bin") + set(install_dest "bin") + else() + set(G_RUNTIME_OUTPUT_DIR "${GISBASE}/lib") + set(install_dest "lib") + endif() + else() + set(install_dest "${G_RUNTIME_OUTPUT_DIR}") + set(G_RUNTIME_OUTPUT_DIR "${GISBASE}/${install_dest}") + endif() + + # To use this property later in build_docs + set(PGM_EXT "") + if(WIN32) + if(G_EXE) + set(PGM_EXT ".exe") + endif() + endif() + + + if(WITH_DOCS) + + set(G_HTML_FILE_NAME "${HTML_FILE_NAME}.html") + + set(html_file ${G_SRCDIR}/${G_HTML_FILE_NAME}) + set(HTML_FILE) + set(no_docs_list "grass_sqlp;echo;clean_temp;lock;run") + + if(EXISTS ${html_file}) + set(HTML_FILE ${html_file}) + install(FILES ${GISBASE}/docs/html/${G_HTML_FILE_NAME} DESTINATION docs/html) + else() + file(GLOB html_files ${G_SRCDIR}/*.html) + if(html_files) + if(NOT ${target_name} IN_LIST no_docs_list) + message(FATAL_ERROR "${html_file} does not exists. ${G_SRCDIR} \n ${G_RUNTIME_OUTPUT_DIR} | ${target_name}") + endif() + endif() + endif() + + + if(NOT HTML_FILE) + add_custom_command(TARGET ${G_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ ${G_RUNTIME_OUTPUT_DIR} + ) + return() + endif() +##message("HTML_FILE=${HTML_FILE}") + +get_filename_component(HTML_FILE_NAME ${HTML_FILE} NAME) +get_filename_component(PGM_SOURCE_DIR ${HTML_FILE} PATH) + +string(REPLACE ".html" "" PGM_NAME "${HTML_FILE_NAME}" ) +string(REPLACE ".html" ".tmp.html" TMP_HTML_NAME ${HTML_FILE_NAME}) +set(TMP_HTML_FILE ${G_SRCDIR}/${TMP_HTML_NAME}) +set(OUT_HTML_FILE ${GISBASE}/docs/html/${HTML_FILE_NAME}) + +set(PGM_EXT "") +if(WIN32) + set(PGM_EXT ".exe") +endif() + +set(html_descr_argument "--html-description") +if(RUN_HTML_DESCR) +set(html_descr_command ${G_NAME}${PGM_EXT} "--html-description") +else() + set(html_descr_command ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${G_NAME}) +endif() + +file(GLOB IMG_FILES ${G_SRCDIR}/*.png ${G_SRCDIR}/*.jpg) +set(copy_images_command ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${G_NAME}) +if(IMG_FILES) + set(copy_images_command ${CMAKE_COMMAND} -E copy ${IMG_FILES} ${GISBASE}/docs/html/) +endif() + +add_custom_command(TARGET ${G_NAME} POST_BUILD + COMMAND ${grass_env_command} ${CMAKE_COMMAND} -E chdir ${G_SRCDIR} + ${html_descr_command} > ${TMP_HTML_FILE} + COMMAND ${grass_env_command} ${CMAKE_COMMAND} -E chdir ${G_SRCDIR} + ${PYTHON_EXECUTABLE} ${MKHTML_PY} ${PGM_NAME} > ${OUT_HTML_FILE} + COMMAND ${CMAKE_COMMAND} -E copy $ ${G_RUNTIME_OUTPUT_DIR} + COMMAND ${copy_images_command} + COMMAND ${CMAKE_COMMAND} -E remove ${TMP_HTML_FILE} + COMMENT "Creating ${OUT_HTML_FILE}") + +endif() # WITH_DOCS + +foreach(test_SOURCE ${G_TEST_SOURCES}) + add_test(NAME ${G_NAME}-test + COMMAND ${grass_env_command} ${PYTHON_EXECUTABLE} + ${G_SRCDIR}/testsuite/${test_SOURCE}) + message("[build_module] ADDING TEST ${G_NAME}-test") +endforeach() + + install(TARGETS ${G_NAME} DESTINATION ${install_dest}) + +endfunction() diff --git a/cmake/modules/build_program.cmake b/cmake/modules/build_program.cmake new file mode 100644 index 00000000000..31c381ab55f --- /dev/null +++ b/cmake/modules/build_program.cmake @@ -0,0 +1,8 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: Shortcut macro to call build_module with EXE argument set +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. +macro(build_program) + build_module(${ARGN} EXE) +endmacro() \ No newline at end of file diff --git a/cmake/modules/build_program_in_subdir.cmake b/cmake/modules/build_program_in_subdir.cmake new file mode 100644 index 00000000000..a026022aee6 --- /dev/null +++ b/cmake/modules/build_program_in_subdir.cmake @@ -0,0 +1,17 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: CMake macro to build a grass executable (program) under sub directory +# which is passed as argument to macro +# COPYRIGHT: (C) 2000 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. + +macro(build_program_in_subdir dir_name) + set (extra_args ${ARGN}) + if ("NAME" IN_LIST extra_args) + #message("dir_name=${dir_name} ${extra_args}") + build_program(SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${dir_name} ${ARGN} ) + else() + get_filename_component(pgm_name ${dir_name} NAME) + build_program(NAME ${pgm_name} SRCDIR ${CMAKE_CURRENT_SOURCE_DIR}/${dir_name} ${ARGN} ) + endif() +endmacro() diff --git a/cmake/modules/build_script_in_subdir.cmake b/cmake/modules/build_script_in_subdir.cmake new file mode 100644 index 00000000000..cc09a1cef32 --- /dev/null +++ b/cmake/modules/build_script_in_subdir.cmake @@ -0,0 +1,97 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: A CMake function that builds grass python script modules +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. + +function(build_script_in_subdir dir_name) + #build_py_module(NAME ${dir_name}) + set(G_NAME ${dir_name}) + + set(G_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${G_NAME}) + + file(GLOB PYTHON_FILES "${G_SRC_DIR}/*.py") + if(NOT PYTHON_FILES) + message(FATAL_ERROR "[${G_NAME}]: No PYTHON_FILES found.") + endif() + + + set(SRC_SCRIPT_FILE ${G_SRC_DIR}/${G_NAME}.py) + + if (NOT EXISTS ${SRC_SCRIPT_FILE}) + message(FATAL_ERROR "${SRC_SCRIPT_FILE} does not exists") + return() + endif() + + + set(SCRIPT_EXT "") + if(WIN32) + set(SCRIPT_EXT ".py") + endif() + + set(TRANSLATE_C_FILE + ${CMAKE_SOURCE_DIR}/locale/scriptstrings/${G_NAME}_to_translate.c) + + ADD_CUSTOM_COMMAND(OUTPUT ${TRANSLATE_C_FILE} + COMMAND ${CMAKE_COMMAND} + -DBINARY_DIR=${CMAKE_BINARY_DIR} + -DG_NAME=${G_NAME} + -DSRC_SCRIPT_FILE=${SRC_SCRIPT_FILE} + -DSOURCE_DIR=${CMAKE_SOURCE_DIR} + -DOUTPUT_FILE=${TRANSLATE_C_FILE} + -P ${CMAKE_SOURCE_DIR}/cmake/locale_strings.cmake + DEPENDS g.parser) + + set(HTML_FILE_NAME ${G_NAME}) + set(OUT_HTML_FILE "") + + if(WITH_DOCS) + + file(GLOB IMG_FILES ${G_SRC_DIR}/*.png ${G_SRC_DIR}/*.jpg) + set(copy_images_command ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${G_NAME}) + if(IMG_FILES) + set(copy_images_command ${CMAKE_COMMAND} -E copy ${IMG_FILES} ${GISBASE}/docs/html/) + endif() + + set(HTML_FILE ${G_SRC_DIR}/${G_NAME}.html) + if(EXISTS ${HTML_FILE}) + install(FILES ${GISBASE}/docs/html/${G_NAME}.html DESTINATION docs/html) + else() + set(HTML_FILE) + file(GLOB html_files ${G_SRC_DIR}/*.html) + if(html_files) + message(FATAL_ERROR "${html_file} does not exists. ${G_SRC_DIR} \n ${GISBASE}/scripts| ${G_NAME}") + endif() + endif() + + set(TMP_HTML_FILE ${G_SRC_DIR}/${G_NAME}.tmp.html) + set(OUT_HTML_FILE ${GISBASE}/docs/html/${G_NAME}.html) + + + ADD_CUSTOM_COMMAND(OUTPUT ${OUT_HTML_FILE} + COMMAND ${grass_env_command} ${CMAKE_COMMAND} -E chdir ${G_SRC_DIR} + ${PYTHON_EXECUTABLE} ${G_NAME}.py "--html-description" > ${TMP_HTML_FILE} + COMMAND ${grass_env_command} ${CMAKE_COMMAND} -E chdir ${G_SRC_DIR} + ${PYTHON_EXECUTABLE} ${MKHTML_PY} ${G_NAME} > ${OUT_HTML_FILE} + COMMAND ${copy_images_command} + COMMAND ${CMAKE_COMMAND} -E remove ${TMP_HTML_FILE} + COMMENT "Creating ${OUT_HTML_FILE}" + DEPENDS ${TRANSLATE_C_FILE} LIB_PYTHON) + + install(FILES ${OUT_HTML_FILE} DESTINATION docs/html/) + + endif() #WITH_DOCS + + ADD_CUSTOM_TARGET(${G_NAME} DEPENDS ${TRANSLATE_C_FILE} ${OUT_HTML_FILE}) + + set(modules_list "${G_NAME};${modules_list}" CACHE INTERNAL "list of modules") + + set_target_properties (${G_NAME} PROPERTIES FOLDER scripts) + + if(WIN32) + install(PROGRAMS ${GISBASE}/scripts/${G_NAME}.bat DESTINATION scripts) + endif() + + install(PROGRAMS ${GISBASE}/scripts/${G_NAME}${SCRIPT_EXT} DESTINATION scripts) + +endfunction() diff --git a/cmake/modules/check_target.cmake b/cmake/modules/check_target.cmake new file mode 100644 index 00000000000..ca6d3f855ef --- /dev/null +++ b/cmake/modules/check_target.cmake @@ -0,0 +1,7 @@ +macro(check_target target_name have_define_var) +set(${have_define_var} 0) +if(TARGET ${target_name}) + #message(STATUS "${target_name} package found. Setting ${have_define_var} to 1") + set(${have_define_var} 1) +endif() +endmacro() diff --git a/cmake/modules/copy_python_files_in_subdir.cmake b/cmake/modules/copy_python_files_in_subdir.cmake new file mode 100644 index 00000000000..62cee3f5816 --- /dev/null +++ b/cmake/modules/copy_python_files_in_subdir.cmake @@ -0,0 +1,15 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: Simply copy python file in given subdirectory +# Destination will be relative to GISBASE directory set in root CMakeLists.txt +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. +function(copy_python_files_in_subdir dir_name dst_prefix) +file(GLOB PY_FILES "${CMAKE_CURRENT_SOURCE_DIR}/${dir_name}/*.py") + string(REPLACE "/" "_" targ_name ${dir_name}) +add_custom_target(python_${targ_name} + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/${dst_prefix}/${dir_name}/ + COMMAND ${CMAKE_COMMAND} -E copy ${PY_FILES} ${GISBASE}/${dst_prefix}/${dir_name}/ + ) + set_target_properties (python_${targ_name} PROPERTIES FOLDER lib/python) +endfunction() diff --git a/cmake/modules/get_host_arch.cmake b/cmake/modules/get_host_arch.cmake new file mode 100644 index 00000000000..c4e7b8a7178 --- /dev/null +++ b/cmake/modules/get_host_arch.cmake @@ -0,0 +1,39 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: Get host system architecuture +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. +function(get_host_arch var_arch) + set(host_arch_value "x86_64") # default value + + if(WIN32) + if(MSVC) + execute_process( + COMMAND ${CMAKE_C_COMPILER} + ERROR_VARIABLE ev + OUTPUT_VARIABLE ov + OUTPUT_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if("${ev}" MATCHES "x86") + set(${host_arch_value} "x86") + else() + set(${host_arch_value} "x86_64") + endif() + + elseif(MINGW) + else() + message(FATAL_ERROR "compiler/platform is not supported") + endif() # if(MSVC) + + elseif(UNIX) + execute_process( + COMMAND uname -m + ERROR_VARIABLE ev + OUTPUT_VARIABLE ov + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(${host_arch_value} "${ov}") + endif() + + set(${var_arch} ${host_arch_value} PARENT_SCOPE) +endfunction() diff --git a/cmake/modules/get_versions.cmake b/cmake/modules/get_versions.cmake new file mode 100644 index 00000000000..5578440c2ed --- /dev/null +++ b/cmake/modules/get_versions.cmake @@ -0,0 +1,34 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: Read major, minor patch, date from given version file +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. +function(get_versions file_path var_major var_minor var_release var_date) + +set(version_major 0) +set(version_minor 0) +set(version_release 0) +set(version_date 00000000) +file(STRINGS "${file_path}" grass_version_strings) +list(LENGTH grass_version_strings grass_version_file_length) + +if(grass_version_file_length LESS 3 ) + message(FATAL_ERROR "include/VERSION is not a valid file") +endif() + +list(GET grass_version_strings 0 version_major) +list(GET grass_version_strings 1 version_minor) + +if(grass_version_file_length GREATER 2 ) + list(GET grass_version_strings 2 version_release) +endif() + +if(grass_version_file_length GREATER 3 ) + list(GET grass_version_strings 3 version_date) +endif() + +set(${var_major} ${version_major} PARENT_SCOPE) +set(${var_minor} ${version_minor} PARENT_SCOPE) +set(${var_release} ${version_release} PARENT_SCOPE) +set(${var_date} ${version_date} PARENT_SCOPE) +endfunction() \ No newline at end of file diff --git a/cmake/modules/repo_status.cmake b/cmake/modules/repo_status.cmake new file mode 100644 index 00000000000..ca13362fe45 --- /dev/null +++ b/cmake/modules/repo_status.cmake @@ -0,0 +1,36 @@ +# AUTHOR(S): Rashad Kanavath +# PURPOSE: Read git status of grass repository if building from git clone +# COPYRIGHT: (C) 2020 by the GRASS Development Team +# This program is free software under the GPL (>=v2) +# Read the file COPYING that comes with GRASS for details. +function(repo_status repo_dir version_git_var) + +if(NOT EXISTS "${repo_dir}/.git") + message(STATUS ".git directory not found. GRASS_VERSION_GIT is set to 'exported'") + set(GRASS_VERSION_GIT "exported") + return() +endif() +find_package(Git) +if(NOT GIT_FOUND) + message(WARNING "git not found. GRASS_VERSION_GIT is set to 'exported'") + set(GRASS_VERSION_GIT "exported") + return() +endif() + +execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE git_rev_OV + ERROR_VARIABLE git_rev_EV + RESULT_VARIABLE git_rev_RV + ) + + if(git_rev_RV ) + message(FATAL_ERROR "Error running git ${git_rev_EV}") + else() + string(STRIP ${git_rev_OV} GRASS_VERSION_GIT) + endif() + + set(${version_git_var} "${GRASS_VERSION_GIT}" PARENT_SCOPE) + +endfunction() #repo_status \ No newline at end of file diff --git a/cmake/modules/set_compiler_flags.cmake b/cmake/modules/set_compiler_flags.cmake new file mode 100644 index 00000000000..871f9f6bb2e --- /dev/null +++ b/cmake/modules/set_compiler_flags.cmake @@ -0,0 +1,13 @@ +macro(set_compiler_flags) +if(MSVC) + set(GRASS_C_FLAGS "/D_CRT_SECURE_NO_WARNINGS /DNOMINMAX /DGRASS_CMAKE_BUILD=1") + set(GRASS_CXX_FLAGS "${GRASS_C_FLAGS}") +else() + set(GRASS_C_FLAGS "-DGRASS_CMAKE_BUILD=1") + set(GRASS_CXX_FLAGS "${GRASS_C_FLAGS}") +endif() + +set(CMAKE_CXX_FLAGS "${GRASS_CXX_FLAGS} ${CMAKE_CXX_FLAGS}") +set(CMAKE_C_FLAGS "${GRASS_C_FLAGS} ${CMAKE_C_FLAGS}") + +endmacro() \ No newline at end of file diff --git a/cmake/tests/have_pbuffer.c b/cmake/tests/have_pbuffer.c new file mode 100644 index 00000000000..ebc7244acb9 --- /dev/null +++ b/cmake/tests/have_pbuffer.c @@ -0,0 +1,18 @@ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char glXCreatePbuffer(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_glXCreatePbuffer) || defined (__stub___glXCreatePbuffer) +choke me +#else +glXCreatePbuffer(); +#endif +; return 0; } + diff --git a/cmake/tests/have_pixmaps.c b/cmake/tests/have_pixmaps.c new file mode 100644 index 00000000000..88b501bde46 --- /dev/null +++ b/cmake/tests/have_pixmaps.c @@ -0,0 +1,20 @@ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char glXCreateGLXPixmap(); below. */ +#include +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char glXCreateGLXPixmap(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_glXCreateGLXPixmap) || defined (__stub___glXCreateGLXPixmap) +choke me +#else +glXCreateGLXPixmap(); +#endif + +; return 0; } diff --git a/cmake/tests/have_pqcmdtuples.c b/cmake/tests/have_pqcmdtuples.c new file mode 100644 index 00000000000..fcd05fe8d22 --- /dev/null +++ b/cmake/tests/have_pqcmdtuples.c @@ -0,0 +1,8 @@ +#include +int main() { + PGresult* res = NULL; + PGconn* conn = PQconnectdb(NULL); + res = PQexec(conn, NULL); + PQcmdTuples(res); + return 0; +} diff --git a/cmake/windows_launch.bat.in b/cmake/windows_launch.bat.in new file mode 100644 index 00000000000..aa03bb369bf --- /dev/null +++ b/cmake/windows_launch.bat.in @@ -0,0 +1,2 @@ +@echo off +"%GRASS_PYTHON%" "%GISBASE%\scripts\@PGM_NAME@.py" %* \ No newline at end of file diff --git a/db/CMakeLists.txt b/db/CMakeLists.txt new file mode 100644 index 00000000000..999a28566fb --- /dev/null +++ b/db/CMakeLists.txt @@ -0,0 +1,41 @@ + +set(db_drivers grass_gis) +add_subdirectory(drivers) + +build_program_in_subdir(db.columns DEPENDS grass_dbmiclient) +add_dependencies(db.columns ${db_drivers}) + +build_program_in_subdir(db.createdb DEPENDS grass_dbmiclient) +add_dependencies(db.createdb ${db_drivers}) + +build_program_in_subdir(db.describe DEPENDS grass_dbmiclient) +add_dependencies(db.describe ${db_drivers}) + +build_program_in_subdir(db.connect DEPENDS grass_dbmiclient) +add_dependencies(db.connect ${db_drivers}) + +build_program_in_subdir(db.copy DEPENDS grass_dbmiclient) +add_dependencies(db.copy ${db_drivers}) + +build_program_in_subdir(db.execute DEPENDS grass_dbmiclient) +add_dependencies(db.execute ${db_drivers}) + +build_program_in_subdir(db.drivers DEPENDS grass_dbmiclient) +add_dependencies(db.drivers ${db_drivers}) + +build_program_in_subdir(db.databases DEPENDS grass_dbmiclient) +add_dependencies(db.databases ${db_drivers}) + +build_program_in_subdir(db.dropdb DEPENDS grass_dbmiclient) +add_dependencies(db.dropdb ${db_drivers}) + +build_program_in_subdir(db.login DEPENDS grass_dbmiclient) +add_dependencies(db.login ${db_drivers}) + +build_program_in_subdir(db.select DEPENDS grass_dbmiclient) +add_dependencies(db.select ${db_drivers}) + +build_program_in_subdir(db.tables DEPENDS grass_dbmiclient) +add_dependencies(db.tables ${db_drivers}) + +#TODO: PGM = databaseintro diff --git a/db/drivers/CMakeLists.txt b/db/drivers/CMakeLists.txt new file mode 100644 index 00000000000..22ddb1dfa52 --- /dev/null +++ b/db/drivers/CMakeLists.txt @@ -0,0 +1,67 @@ +set(dbf_SRCS dbf/column.c dbf/create_table.c + dbf/cursor.c dbf/db.c dbf/dbfexe.c dbf/describe.c + dbf/driver.c dbf/error.c dbf/execute.c dbf/fetch.c + dbf/listtab.c dbf/main.c dbf/select.c dbf/str.c dbf/table.c) + +set(db_drivers) +set(grass_dbstubs_DEFS) +if(MSVC) +set(grass_dbstubs_DEFS "-DDB_DRIVER_C=1") +endif() +build_program_in_subdir(dbf + SOURCES ${dbf_SRCS} + DEPENDS grass_gis grass_dbmidriver grass_shape grass_sqlp + DEFS "${grass_dbstubs_DEFS}" + HTML_FILE_NAME grass-dbf + RUNTIME_OUTPUT_DIR "driver/db/") + +list(APPEND db_drivers dbf) + +build_program_in_subdir(ogr + DEPENDS grass_gis grass_dbmidriver grass_sqlp GDAL + DEFS "${grass_dbstubs_DEFS}" + HTML_FILE_NAME grass-ogr + RUNTIME_OUTPUT_DIR "driver/db/") + +list(APPEND db_drivers ogr) + +build_program_in_subdir(odbc + DEPENDS grass_gis grass_dbmidriver grass_sqlp + DEFS "${grass_dbstubs_DEFS}" + PRIMARY_DEPENDS ODBC + HTML_FILE_NAME grass-odbc + RUNTIME_OUTPUT_DIR "driver/db/") +if(TARGET ODBC) + list(APPEND db_drivers odbc) +endif() + +build_program_in_subdir(sqlite + DEPENDS grass_gis grass_dbmidriver grass_sqlp + DEFS "${grass_dbstubs_DEFS}" + PRIMARY_DEPENDS SQLITE + HTML_FILE_NAME grass-sqlite + RUNTIME_OUTPUT_DIR "driver/db/") + +if(TARGET SQLITE) + list(APPEND db_drivers sqlite) +endif() + +build_program_in_subdir(postgres + DEPENDS grass_gis grass_dbmidriver grass_sqlp + DEFS "${grass_dbstubs_DEFS}" + PRIMARY_DEPENDS POSTGRES + HTML_FILE_NAME grass-pg + RUNTIME_OUTPUT_DIR "driver/db/") + +if(TARGET POSTGRES) + list(APPEND db_drivers postgres) +endif() + + +if(MYSQL_LIB) + ##add_subdirectory(mysql) + #list(APPEND db_drivers "mysql") +endif() + + +set(db_drivers ${db_drivers} PARENT_SCOPE) diff --git a/demolocation/grassrc.cmake.in b/demolocation/grassrc.cmake.in new file mode 100644 index 00000000000..7b46331e401 --- /dev/null +++ b/demolocation/grassrc.cmake.in @@ -0,0 +1,4 @@ +GISDBASE: @gisbase_init_dir@ +LOCATION_NAME: demolocation +MAPSET: PERMANENT +GUI: text diff --git a/display/CMakeLists.txt b/display/CMakeLists.txt new file mode 100644 index 00000000000..fd16882eb2c --- /dev/null +++ b/display/CMakeLists.txt @@ -0,0 +1,27 @@ +build_program_in_subdir(d.barscale DEPENDS grass_sym grass_display grass_gis ) +build_program_in_subdir(d.colorlist DEPENDS grass_gis grass_display) +build_program_in_subdir(d.colortable DEPENDS grass_gis grass_display) +build_program_in_subdir(d.erase DEPENDS grass_gis grass_display) +if(NOT MSVC) + build_program_in_subdir(d.font DEPENDS grass_gis grass_display grass_raster) + #libgen.h does not exists on windows msvc + build_program_in_subdir(d.mon DEPENDS grass_gis grass_display) +endif() +build_program_in_subdir(d.fontlist DEPENDS grass_gis grass_display grass_raster) +build_program_in_subdir(d.geodesic DEPENDS grass_gis grass_display) +build_program_in_subdir(d.graph DEPENDS grass_gis grass_sym grass_display) +build_program_in_subdir(d.grid DEPENDS grass_gis grass_sym grass_gproj grass_display) +build_program_in_subdir(d.his DEPENDS grass_gis grass_display) +build_program_in_subdir(d.histogram DEPENDS grass_gis grass_display) +build_program_in_subdir(d.info DEPENDS grass_gis grass_display) +build_program_in_subdir(d.labels DEPENDS grass_gis grass_display) +build_program_in_subdir(d.legend DEPENDS grass_gis grass_display grass_raster3d) +build_program_in_subdir(d.legend.vect DEPENDS grass_gis grass_display grass_sym) +build_program_in_subdir(d.linegraph DEPENDS grass_gis grass_display grass_sym) +build_program_in_subdir(d.northarrow DEPENDS grass_gis grass_display grass_sym) +build_program_in_subdir(d.path DEPENDS grass_gis grass_display grass_vector) +build_program_in_subdir(d.profile DEPENDS grass_gis grass_display) +build_program_in_subdir(d.rast DEPENDS grass_gis grass_display grass_raster) +build_program_in_subdir(d.rast.arrow DEPENDS grass_gis grass_raster grass_display) +build_program_in_subdir(d.rast.num DEPENDS grass_gis grass_display grass_raster) +build_program_in_subdir(d.where DEPENDS grass_gis grass_display grass_gproj) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/general/CMakeLists.txt b/general/CMakeLists.txt new file mode 100644 index 00000000000..5bc110a2e35 --- /dev/null +++ b/general/CMakeLists.txt @@ -0,0 +1,44 @@ + +build_program_in_subdir(g.access DEPENDS grass_gis ) +build_program_in_subdir(g.copy DEPENDS grass_manage ) +build_program_in_subdir(g.dirseps DEPENDS grass_gis ) +build_program_in_subdir(g.filename DEPENDS grass_gis ) +build_program_in_subdir(g.findetc DEPENDS grass_gis ) +build_program_in_subdir(g.findfile DEPENDS grass_manage ) +build_program_in_subdir(g.gisenv DEPENDS grass_gis ) +build_program_in_subdir(g.mapset DEPENDS grass_gis ) +build_program_in_subdir(g.mapsets DEPENDS grass_gis ) +build_program_in_subdir(g.message DEPENDS grass_gis ) +build_program_in_subdir(g.mkfontcap DEPENDS grass_gis FREETYPE ) +build_program_in_subdir(g.parser DEPENDS grass_gis FREETYPE) +build_program_in_subdir(g.pnmcomp DEPENDS grass_gis ) +build_program_in_subdir(g.ppmtopng DEPENDS grass_gis LIBPNG) +build_program_in_subdir(g.proj DEPENDS grass_gis grass_gproj GDAL ) +build_program_in_subdir(g.region DEPENDS grass_gis grass_gproj + grass_vector grass_raster3d grass_gmath) + +build_program_in_subdir(g.rename DEPENDS grass_manage grass_raster ) +build_program_in_subdir(g.tempfile DEPENDS grass_gis ) + +build_program_in_subdir(g.version + DEPENDS grass_gis PROJ GEOS GDAL SQLITE + DEFS "-DGRASS_VERSION_NUMBER=\"${GRASS_VERSION_NUMBER}\"" + "-DGRASS_VERSION_GIT=\"${GRASS_VERSION_GIT}\"" + "-DGRASS_VERSION_UPDATE_PKG=${GRASS_VERSION_UPDATE_PKG}" + "-DARCH=\"${BUILD_ARCH}\"" + ) + +if(WITH_CAIRO) + if(NOT MSVC) + build_program_in_subdir(g.cairocomp DEPENDS grass_gis CAIRO grass_cairodriver) + endif() +endif() + +add_subdirectory(manage/lister) + +build_program_in_subdir(g.list DEPENDS grass_manage) +add_dependencies(g.list cell vector) + +build_program_in_subdir(g.remove DEPENDS grass_manage grass_raster) + +build_program_in_subdir(g.gui DEPENDS grass_raster) diff --git a/general/manage/lister/CMakeLists.txt b/general/manage/lister/CMakeLists.txt new file mode 100644 index 00000000000..43c7ae1e71b --- /dev/null +++ b/general/manage/lister/CMakeLists.txt @@ -0,0 +1,9 @@ +build_program(NAME cell +SOURCES "cell.c" +DEPENDS grass_vector grass_dbmibase grass_gis grass_raster +RUNTIME_OUTPUT_DIR etc/lister) + +build_program(NAME vector +SOURCES "vector.c" +DEPENDS grass_vector grass_dbmibase grass_gis grass_raster +RUNTIME_OUTPUT_DIR etc/lister) diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt new file mode 100644 index 00000000000..04d60dd4d9f --- /dev/null +++ b/gui/CMakeLists.txt @@ -0,0 +1,12 @@ + + +add_subdirectory(icons) +add_subdirectory(images) + + + +#add_subdirectory(scripts) + +add_subdirectory(wxpython) + +install(FILES xml/grass-interface.dtd DESTINATION gui/xml) diff --git a/gui/icons/CMakeLists.txt b/gui/icons/CMakeLists.txt new file mode 100644 index 00000000000..9072ecfbb44 --- /dev/null +++ b/gui/icons/CMakeLists.txt @@ -0,0 +1,52 @@ +file(GLOB GUI_ICONS "*.ico" "*.png") +file(GLOB GRASS_ICONS "grass/*.png") +file(GLOB FLAGS_ICONS "flags/*.png") + +add_custom_target(make_gui_icons_dirs + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/icons/grass + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/icons/flags + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/docs/html/icons + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/gui/images/symbols + ) + +set(output_icons) +foreach(ICON ${GUI_ICONS}) + get_filename_component(FILE_NAME ${ICON} NAME) + add_custom_command(OUTPUT ${GISBASE}/gui/icons/${FILE_NAME} + COMMAND ${CMAKE_COMMAND} -E copy ${ICON} ${GISBASE}/gui/icons/) + list(APPEND output_icons ${GISBASE}/gui/icons/${FILE_NAME}) +endforeach() + +foreach(ICON ${GRASS_ICONS}) + get_filename_component(FILE_NAME ${ICON} NAME) + add_custom_command(OUTPUT ${GISBASE}/gui/icons/grass/${FILE_NAME} + COMMAND ${CMAKE_COMMAND} -E copy ${ICON} ${GISBASE}/gui/icons/grass/ + COMMAND ${CMAKE_COMMAND} -E copy ${ICON} ${GISBASE}/docs/html/icons/) + list(APPEND output_icons ${GISBASE}/gui/icons/grass/${FILE_NAME}) + list(APPEND output_icons ${GISBASE}/docs/html/icons/${FILE_NAME}) +endforeach() + +foreach(ICON ${FLAGS_ICONS}) + get_filename_component(FILE_NAME ${ICON} NAME) + add_custom_command(OUTPUT ${GISBASE}/gui/icons/flags/${FILE_NAME} + COMMAND ${CMAKE_COMMAND} -E copy ${ICON} ${GISBASE}/gui/icons/flags/) + list(APPEND output_icons ${GISBASE}/gui/icons/flags/${FILE_NAME}) +endforeach() + +add_custom_target(gui_icons DEPENDS make_gui_icons_dirs ${output_icons}) + +install(FILES ${GUI_ICONS} DESTINATION gui/icons) +install(FILES ${GRASS_ICONS} DESTINATION gui/icons/grass) +install(FILES ${FLAGS_ICONS} DESTINATION gui/icons/flags) +install(FILES ${GRASS_ICONS} DESTINATION docs/html/icons) +install(FILES grass.desktop DESTINATION share/applications) +foreach(icon_type 8 16 22 24 32 36 40 42 48 64 72 80 96 128 192) + set(icon_size "${icon_type}x${icon_type}") + install(FILES grass-${icon_size}.png DESTINATION share/icons/hicolor/${icon_size}/apps) +endforeach() + +install(FILES grass.svg + DESTINATION share/icons/hicolor/scalable/apps + RENAME grass${GRASS_VERSION_MAJOR}${GRASS_VERSION_MINOR}.svg) + +install(FILES grass.appdata.xml DESTINATION share/appdata) diff --git a/gui/images/CMakeLists.txt b/gui/images/CMakeLists.txt new file mode 100644 index 00000000000..263c9ef1ad4 --- /dev/null +++ b/gui/images/CMakeLists.txt @@ -0,0 +1,26 @@ +file(GLOB GUI_IMAGES "*.png") + +set(output_images) +foreach(IMG ${GUI_IMAGES}) + get_filename_component(FILE_NAME ${IMG} NAME) + add_custom_command(OUTPUT ${GISBASE}/gui/images/${FILE_NAME} + COMMAND ${CMAKE_COMMAND} -E copy ${IMG} ${GISBASE}/gui/images/) + list(APPEND output_images ${GISBASE}/gui/images/${FILE_NAME}) +endforeach() + +add_custom_target(gui_images + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/symbols/basic/ ${GISBASE}/gui/images/symbols/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/symbols/demo/ ${GISBASE}/gui/images/symbols/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/symbols/extra/ ${GISBASE}/gui/images/symbols/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/symbols/geology/ ${GISBASE}/gui/images/symbols/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/symbols/legend/ ${GISBASE}/gui/images/symbols/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/symbols/n_arrows/ ${GISBASE}/gui/images/symbols/ + DEPENDS gui_icons ${output_images}) + +install(FILES ${GUI_IMAGES} DESTINATION gui/images/) +install(DIRECTORY basic DESTINATION gui/images/symbols/) +install(DIRECTORY demo DESTINATION gui/images/symbols/) +install(DIRECTORY extra DESTINATION gui/images/symbols/) +install(DIRECTORY geology DESTINATION gui/images/symbols/) +install(DIRECTORY legend DESTINATION gui/images/symbols/) +install(DIRECTORY n_arrows DESTINATION gui/images/symbols/) diff --git a/gui/wxpython/CMakeLists.txt b/gui/wxpython/CMakeLists.txt new file mode 100644 index 00000000000..ef69efa6076 --- /dev/null +++ b/gui/wxpython/CMakeLists.txt @@ -0,0 +1,77 @@ + +# missing docs + + +set(WXPYTHON_DIR ${GISBASE}/gui/wxpython) +set(gui_lib_DIRS core gui_core icons iscatt lmgr location_wizard +mapdisp mapwin modules nviz rdigit startup tools vnet web_services wxplot) + +set(gui_lib_targets) +foreach(gui_lib_DIR ${gui_lib_DIRS}) + copy_python_files_in_subdir(${gui_lib_DIR} gui/wxpython) + list(APPEND gui_lib_targets python_${gui_lib_DIR}) +endforeach() +add_custom_target(GUI_WXPYTHON + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/gis_set.py ${WXPYTHON_DIR}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/gis_set_error.py ${WXPYTHON_DIR}/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/wxgui.py ${WXPYTHON_DIR}/ + DEPENDS ${gui_lib_targets}) + +set(gui_DIRS animation datacatalog dbmgr gcp gmodeler +iclass image2target mapswipe photo2image psmap rlisetup timeline tplot vdigit) +set(g_gui_targets) +foreach(gui_DIR ${gui_DIRS}) + build_gui_in_subdir(${gui_DIR}) + list(APPEND g_gui_targets "g.gui.${gui_DIR}") +endforeach() + + +add_subdirectory(docs) + +install(FILES README DESTINATION gui/wxpython) + + ### copy all python files gui/ lib/python + ### compile all python files + ### so below target depends on MODULD_LIST + +add_custom_target(copy_wxpython_xml + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/xml ${WXPYTHON_DIR}/xml/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/../xml/grass-interface.dtd ${GISBASE}/gui/ + DEPENDS GUI_WXPYTHON) + +add_custom_target(compile_python_files + COMMAND ${PYTHON_EXECUTABLE} -m compileall ${GISBASE}/scripts + COMMAND ${PYTHON_EXECUTABLE} -m compileall ${WXPYTHON_DIR} + DEPENDS ALL_MODULES) + +add_custom_target(build_modules_items_xml + COMMAND ${grass_env_command} ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/tools/build_modules_xml.py > ${WXPYTHON_DIR}/xml/module_items.xml + DEPENDS copy_wxpython_xml compile_python_files ${g_gui_targets} + COMMENT "Generating interface description for all modules..." + VERBATIM) + +add_custom_target(build_xml_menudata + COMMAND ${grass_env_command} ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/core/toolboxes.py > ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/menudata.xml + COMMAND ${grass_env_command} ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/core/toolboxes.py "validate" ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/menudata.xml + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/menudata.xml ${WXPYTHON_DIR}/xml/ + DEPENDS build_modules_items_xml) + +add_custom_target(build_module_tree_menudata + COMMAND ${grass_env_command} ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/core/toolboxes.py "module_tree" > ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/module_tree_menudata.xml + COMMAND ${grass_env_command} ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/core/toolboxes.py "validate" ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/module_tree_menudata.xml + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/module_tree_menudata.xml ${WXPYTHON_DIR}/xml/ + DEPENDS build_xml_menudata) + +add_custom_target(build_menustrings ALL + COMMAND ${grass_env_command} ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/core/menutree.py "manager" >> ${CMAKE_CURRENT_SOURCE_DIR}/menustrings.py + COMMAND ${grass_env_command} ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/core/menutree.py "module_tree" >> ${CMAKE_CURRENT_SOURCE_DIR}/menustrings.py + COMMAND ${grass_env_command} ${PYTHON_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/core/menutree.py "psmap" >> ${CMAKE_CURRENT_SOURCE_DIR}/menustrings.py + DEPENDS build_module_tree_menudata gui_images) diff --git a/gui/wxpython/docs/CMakeLists.txt b/gui/wxpython/docs/CMakeLists.txt new file mode 100644 index 00000000000..a04446a98ba --- /dev/null +++ b/gui/wxpython/docs/CMakeLists.txt @@ -0,0 +1,13 @@ + +set(wxpython_html_files) + +ADD_CUSTOM_COMMAND(OUTPUT ${GISBASE}/docs/html/wxGUI.components.html + COMMAND ${grass_env_command} + ${PYTHON_EXECUTABLE} ${MKHTML_PY} wxGUI.components ${GRASS_VERSION_DATE} > ${GISBASE}/docs/html/wxGUI.components.html + COMMENT "Creating ${GISBASE}/docs/html/wxGUI.components.html" + DEPENDS GUI_WXPYTHON LIB_PYTHON + ) + +list(APPEND wxpython_html_files ${GISBASE}/docs/html/wxGUI.components.html) + +ADD_CUSTOM_TARGET(wxpython_docs DEPENDS ${wxpython_html_files}) diff --git a/imagery/CMakeLists.txt b/imagery/CMakeLists.txt new file mode 100644 index 00000000000..442c4823699 --- /dev/null +++ b/imagery/CMakeLists.txt @@ -0,0 +1,103 @@ +build_program_in_subdir(i.albedo DEPENDS grass_imagery grass_raster grass_vector grass_gis ) +build_program_in_subdir(i.aster.toar DEPENDS grass_imagery grass_raster grass_vector grass_gis ) + +build_program_in_subdir(i.atcorr + DEPENDS grass_imagery grass_raster grass_vector grass_gis SRC_REGEX "*.cpp") + +build_program_in_subdir(i.biomass DEPENDS grass_imagery grass_raster grass_vector grass_gis ) +build_program_in_subdir(i.cca DEPENDS grass_imagery grass_raster grass_vector grass_gis ) +build_program_in_subdir(i.cluster DEPENDS grass_imagery grass_raster grass_vector grass_gis grass_cluster) + +build_program_in_subdir(i.eb.evapfr DEPENDS grass_imagery grass_raster grass_vector grass_gis) +build_program_in_subdir(i.eb.eta DEPENDS grass_imagery grass_raster grass_vector grass_gis) +build_program_in_subdir(i.eb.hsebal01 DEPENDS grass_imagery grass_raster grass_vector grass_gis) +build_program_in_subdir(i.eb.netrad DEPENDS grass_imagery grass_raster grass_vector grass_gis) +build_program_in_subdir(i.eb.soilheatflux DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir(i.evapo.mh DEPENDS grass_imagery grass_raster grass_vector grass_gis) +build_program_in_subdir(i.evapo.pm DEPENDS grass_imagery grass_raster grass_vector grass_gis) +build_program_in_subdir(i.evapo.pt DEPENDS grass_imagery grass_raster grass_vector grass_gis) +build_program_in_subdir(i.evapo.time DEPENDS grass_imagery grass_raster grass_vector grass_gis) +build_program_in_subdir(i.emissivity DEPENDS grass_imagery grass_raster grass_vector grass_gis) +build_program_in_subdir(i.find + DEPENDS grass_imagery grass_raster grass_vector grass_gis + PACKAGE "grassmods" + RUNTIME_OUTPUT_DIR etc) + +build_program_in_subdir(i.gensig DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.gensigset + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.group + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.his.rgb + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.landsat.toar + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.maxlik + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.modis.qc + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.rectify + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.rgb.his + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.segment + DEPENDS grass_imagery grass_raster grass_vector grass_gis grass_segment) + +build_program_in_subdir( + i.smap + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.target + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.topo.corr + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.pca + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.vi + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.zc + DEPENDS grass_imagery grass_raster grass_vector grass_gis) + +build_program_in_subdir( + i.fft + DEPENDS grass_imagery grass_raster grass_gmath grass_gis + PRIMARY_DEPENDS FFTW) + +build_program_in_subdir( + i.ifft + DEPENDS grass_gis grass_raster grass_gmath grass_btree2 + PRIMARY_DEPENDS FFTW) + +build_program_in_subdir( + i.landsat.acca + DEPENDS grass_raster grass_gis) + +add_subdirectory(i.ortho.photo) diff --git a/imagery/i.ortho.photo/CMakeLists.txt b/imagery/i.ortho.photo/CMakeLists.txt new file mode 100644 index 00000000000..c442548d498 --- /dev/null +++ b/imagery/i.ortho.photo/CMakeLists.txt @@ -0,0 +1,17 @@ +build_library_in_subdir(lib + NAME grass_iortho + DEPENDS grass_gis grass_imagery grass_gmath) + +build_program_in_subdir(i.ortho.camera DEPENDS grass_iortho) + +build_program_in_subdir(i.ortho.elev DEPENDS grass_iortho) + +build_program_in_subdir(i.ortho.init DEPENDS grass_iortho) + +build_program_in_subdir(i.ortho.photo DEPENDS grass_iortho) + +build_program_in_subdir(i.ortho.rectify DEPENDS grass_iortho) + +build_program_in_subdir(i.ortho.target DEPENDS grass_iortho) + +build_program_in_subdir(i.ortho.transform DEPENDS grass_iortho) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 00000000000..eaee72ad362 --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,285 @@ +include(CheckIncludeFile) +include(CheckFunctionExists) #TODO: use CheckSymbolExists +check_include_file(limits.h HAVE_LIMITS_H) +check_include_file(termio.h HAVE_TERMIO_H) +check_include_file(termios.h HAVE_TERMIOS_H) +if(NOT MSVC) + check_include_file(unistd.h HAVE_UNISTD_H) +else() + # unistd.h in stocked in thirdparty/msvc/ + set(HAVE_UNISTD_H 1) +endif() +check_include_file(values.h HAVE_VALUES_H) +check_include_file(sys/ioctl.h HAVE_SYS_IOCTL_H) +check_include_file(sys/mtio.h HAVE_SYS_MTIO_H) +check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H) +check_include_file(sys/time.h HAVE_SYS_TIME_H) +check_include_file(time.h HAVE_TIME_H) +check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H) +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(sys/utsname.h HAVE_SYS_UTSNAME_H) +check_include_file(g2c.h HAVE_G2C_H) +check_include_file(f2c.h HAVE_F2C_H) + +if(MSVC) + set(HAVE_PTHREAD_H 0) + set(HAVE_REGEX_H 0) + set(HAVE_LIBINTL_H 0) + set(HAVE_LANGINFO_H 0) + set(HAVE_DBM_H 0) +else() + check_include_file(pthread.h HAVE_PTHREAD_H) + check_include_file(regex.h HAVE_REGEX_H) + check_include_file(libintl.h HAVE_LIBINTL_H) + check_include_file(langinfo.h HAVE_LANGINFO_H) + check_include_file(dbm.h HAVE_DBM_H) +endif() + +#set(CMAKE_REQUIRED_INCLUDES "${FFTW_INCLUDE_DIR}") +check_target(ICONV HAVE_ICONV_H) +check_target(BZIP2 HAVE_BZLIB_H) +check_target(ZLIB HAVE_ZLIB_H) +check_target(LIBJPEG HAVE_JPEGLIB_H) +check_target(LIBPNG HAVE_PNG_H) +check_target(TIFF HAVE_TIFFIO_H) +check_target(GEOS HAVE_GEOS) +check_target(GDAL HAVE_GDAL) +check_target(GDAL HAVE_OGR) +check_target(SQLITE HAVE_SQLITE) + +#TODO: check with more version of proj + +if(PROJ_VERSION_STRING GREATER 599 AND PROJ_VERSION_STRING LESS 700) + message(STATUS "Using PROJ.4 API version 6.x") + set(PROJMAJOR 6) + check_target(PROJ HAVE_PROJ_H) +elseif(PROJ_VERSION_STRING GREATER 499 AND PROJ_VERSION_STRING LESS 600) + check_target(PROJ HAVE_PROJ_H) + message(STATUS "Using PROJ.4 API version 5.x") + set(PROJMAJOR 5) +elseif(PROJ_VERSION_STRING GREATER 399 AND PROJ_VERSION_STRING LESS 500) + set(USE_PROJ4API 1) + message(STATUS "Using PROJ.4 API version 4.x") + set(PROJMAJOR 4) +endif() + +check_target(BLAS HAVE_LIBBLAS) +check_target(BLAS HAVE_CBLAS_H) + +check_target(LAPACK HAVE_LIBLAPACK) +check_target(LAPACK HAVE_CLAPACK_H) + +check_target(FREETYPE HAVE_FT2BUILD_H) +check_target(POSTGRES HAVE_POSTGRES) +check_target(ODBC HAVE_SQL_H) + +if(TARGET POSTGRES) + try_compile(HAVE_PQCMDTUPLES + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/cmake/tests/have_pqcmdtuples.c + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${PostgreSQL_INCLUDE_DIR}" + "-w" + "-DLINK_LIBRARIES:STRING=${PostgreSQL_LIBRARY}" + OUTPUT_VARIABLE COMPILE_HAVE_PQCMDTUPLES) + if(NOT COMPILE_HAVE_PQCMDTUPLES) + message("Performing Test HAVE_PQCMDTUPLES - Failed\n COMPILE_OUTPUT:${COMPILE_HAVE_PQCMDTUPLES}\n") + else() + message(STATUS "Performing Test HAVE_PQCMDTUPLES - Success") + set(HAVE_PQCMDTUPLES 1) + endif() +endif() + +if(MSVC) +check_target(PCRE HAVE_PCRE_H) +endif() + +check_target(POSTGRES HAVE_LIBPQ_FE_H) + +# Whether or not we are using G_socks for display communications +set(USE_G_SOCKS 0) + +if(WITH_LARGEFILES) + set(HAVE_LARGEFILES 1) +else() + set(HAVE_LARGEFILES 0) +endif() + +if(MSVC) + set(GID_TYPE int) + set(UID_TYPE int) + set(UID_TYPE int) + set(RETSIGTYPE "void") +else() + set(RETSIGTYPE "int") +endif() + +########################TODO######################## +#no target ATLAS in thirdpary/CMakeLists.txt +check_target(ATLAS HAVE_LIBATLAS) + +set(USE_NLS 0) +if(WITH_NLS) + set(USE_NLS 1) +endif() +set(HAVE_READLINE_READLINE_H 0) + +if(MSVC) +set(PID_TYPE int) +endif() + +set(_OE_SOCKETS 0) +set(USE_DELTA_FOR_TZ 0) +set(_REENTRANT 0) +########################TODO######################## + +set(X_DISPLAY_MISSING 1) +if(TARGET X11) + set(X_DISPLAY_MISSING 0) +endif() + +#used in config.cmake.in +set(STATIC_BUILD 0) +if(NOT BUILD_SHARED_LIBS) + set(STATIC_BUILD 1) +endif() + +#used in config.cmake.in +set(GDEBUG 0) +if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" ) + set(GDEBUG 1) +endif() + +include(CheckCSourceCompiles) + +set(CMAKE_REQUIRED_FLAGS ${CMAKE_C_FLAGS}) + +CHECK_C_SOURCE_COMPILES(" +int main(int argc, char *argv[]) +{ +long long int x; +return 0; +} +" +HAVE_LONG_LONG_INT) + +CHECK_C_SOURCE_COMPILES(" +#include +#include +#include +int main() { +struct tm *tp; +; return 0; } +" +TIME_WITH_SYS_TIME) + +CHECK_FUNCTION_EXISTS(ftime HAVE_FTIME) +CHECK_FUNCTION_EXISTS(gethostname HAVE_GETHOSTNAME) +CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY) +CHECK_FUNCTION_EXISTS(lseek HAVE_LSEEK) +CHECK_FUNCTION_EXISTS(time HAVE_TIME) +CHECK_FUNCTION_EXISTS(uname HAVE_UNAME) +CHECK_FUNCTION_EXISTS(seteuid HAVE_SETEUID) +CHECK_FUNCTION_EXISTS(setpriority HAVE_SETPRIORITY) +CHECK_FUNCTION_EXISTS(setreuid HAVE_SETREUID) +CHECK_FUNCTION_EXISTS(setruid HAVE_SETRUID) +CHECK_FUNCTION_EXISTS(setpgrp SETPGRP_VOID) +CHECK_FUNCTION_EXISTS(drand48 HAVE_DRAND48) +CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) +CHECK_FUNCTION_EXISTS(asprintf HAVE_ASPRINTF) +CHECK_FUNCTION_EXISTS(putenv HAVE_PUTENV) +CHECK_FUNCTION_EXISTS(setenv HAVE_SETENV) +CHECK_FUNCTION_EXISTS(socket HAVE_SOCKET) + +set(HAVE_PBUFFERS 0) +set(HAVE_PIXMAPS 0) +if(WITH_OPENGL) +try_compile(HAVE_PBUFFERS ${CMAKE_CURRENT_BINARY_DIR} +${CMAKE_SOURCE_DIR}/cmake/tests/have_pbuffer.c +CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${OPENGL_INCLUDE_DIR}" + "-w" + "-DLINK_LIBRARIES:STRING=${OPENGL_LIBRARIES}" +OUTPUT_VARIABLE COMPILE_HAVE_PBUFFERS +) +if(NOT COMPILE_HAVE_PBUFFERS) + message(FATAL_ERROR "Performing Test HAVE_PBUFFERS - Failed\n COMPILE_OUTPUT:${COMPILE_HAVE_PBUFFERS}\n") +else() + message(STATUS "Performing Test HAVE_PBUFFERS - Success") + set(HAVE_PBUFFERS 1) +endif() + + +try_compile(HAVE_PIXMAPS ${CMAKE_CURRENT_BINARY_DIR} +${CMAKE_SOURCE_DIR}/cmake/tests/have_pixmaps.c +CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${OPENGL_INCLUDE_DIR}" + "-w" + "-DLINK_LIBRARIES:STRING=${OPENGL_LIBRARIES}" + OUTPUT_VARIABLE COMPILE_HAVE_PIXMAPS + ) + +if(NOT COMPILE_HAVE_PIXMAPS) + message(FATAL_ERROR "Performing Test HAVE_PIXMAPS - Failed\n COMPILE_OUTPUT:${COMPILE_HAVE_PIXMAPS}\n") +else() + message(STATUS "Performing Test HAVE_PIXMAPS - Success") + set(HAVE_PIXMAPS 1) +endif() + +endif(WITH_OPENGL) + +CHECK_FUNCTION_EXISTS(fseeko HAVE_FSEEKO) + + +set(OPENGL_X11 0) +set(OPENGL_AQUA 0) +set(OPENGL_WINDOWS 0) +if(WITH_OPENGL) + if(APPLE) + set(OPENGL_AQUA 1) + elseif(WIN32) + set(OPENGL_WINDOWS 1) + else() + set(OPENGL_X11 1) + endif() +endif() + +file(GLOB_RECURSE SRCHS "*.h") + set(include_depends) +foreach(srch ${SRCHS}) + get_filename_component(srch_PATH ${srch} PATH) + get_filename_component(srch_NAME ${srch} NAME) + STRING(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}" "" dsth_PATH "${srch_PATH}") + set(output_dir ${CMAKE_BINARY_DIR}/include/grass${dsth_PATH}) + + add_custom_command( + OUTPUT ${output_dir}/${srch_NAME} + COMMAND ${CMAKE_COMMAND} -E make_directory ${output_dir} + COMMAND ${CMAKE_COMMAND} -E copy ${srch} ${output_dir} + COMMENT "Copy ${srch} to ${CMAKE_BINARY_DIR}/include/grass${dsth_PATH}/${srch_NAME}" + ) + list(APPEND include_depends ${output_dir}/${srch_NAME} ) +endforeach() + +add_custom_target(copy_header DEPENDS ${include_depends} LIB_PYTHON) + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in + "${CMAKE_CURRENT_BINARY_DIR}/grass/version.h") + +message(STATUS "Creating ${CMAKE_CURRENT_BINARY_DIR}/grass/config.h") + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/grass/config.h") + +file(WRITE ${CMAKE_BINARY_DIR}/include/grass/copying.h "") +file(STRINGS ${CMAKE_SOURCE_DIR}/COPYING copying_lines) +foreach(copying_line ${copying_lines}) + file(APPEND ${CMAKE_BINARY_DIR}/include/grass/copying.h "\"${copying_line} \\n\"\n" ) +endforeach() + +file(WRITE ${CMAKE_BINARY_DIR}/include/grass/citing.h "") +file(STRINGS ${CMAKE_SOURCE_DIR}/CITING citing_lines) +foreach(citing_line ${citing_lines}) + file(APPEND ${CMAKE_BINARY_DIR}/include/grass/citing.h "\"${citing_line}\\n\"\n" ) +endforeach() + +#TODO +#file(READ ${CMAKE_SOURCE_DIR}/config.status config_status_header) +file(WRITE ${CMAKE_BINARY_DIR}/include/grass/confparms.h "\"/* */\\n\"" ) diff --git a/include/config.h.cmake.in b/include/config.h.cmake.in new file mode 100644 index 00000000000..b695dfd6389 --- /dev/null +++ b/include/config.h.cmake.in @@ -0,0 +1,317 @@ +/* + #Generated by cmake from include/config.h.cmake.in + * config.h.cmake.in + */ + +#ifndef _config_h +#define _config_h + +#cmakedefine GDEBUG ${GDEBUG} + +/* define _OE_SOCKETS flag (OS/390 sys/socket.h) */ +#cmakedefine _OE_SOCKETS ${_OE_SOCKETS} + +/* define _REENTRANT flag (for SunOS) */ +#cmakedefine _REENTRANT ${_REENTRANT} + +/* define USE_DELTA_FOR_TZ (for AIX) */ +#cmakedefine USE_DELTA_FOR_TZ ${USE_DELTA_FOR_TZ} + +/* define for Windows static build */ +#cmakedefine STATIC_BUILD ${STATIC_BUILD} + +/* define if limits.h exists */ +#cmakedefine HAVE_LIMITS_H ${HAVE_LIMITS_H} + +/* define if termio.h exists */ +#cmakedefine HAVE_TERMIO_H ${HAVE_TERMIO_H} + +/* define if termios.h exists */ +#cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H} + +/* define if unistd.h exists */ +#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H} + +/* define if values.h exists */ +#cmakedefine HAVE_VALUES_H ${HAVE_VALUES_H} + +/* define if zlib.h exists */ +#cmakedefine HAVE_ZLIB_H ${HAVE_ZLIB_H} + +/* define if bzlib.h exists */ +#cmakedefine HAVE_BZLIB_H ${HAVE_BZLIB_H} + +/* define if sys/ioctl.h exists */ +#cmakedefine HAVE_SYS_IOCTL_H ${HAVE_SYS_IOCTL_H} + +/* define if sys/mtio.h exists */ +#cmakedefine HAVE_SYS_MTIO_H ${HAVE_SYS_MTIO_H} + +/* define if sys/resource.h exists */ +#cmakedefine HAVE_SYS_RESOURCE_H ${HAVE_SYS_RESOURCE_H} + +/* define if sys/time.h exists */ +#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H} + +/* define if time.h and sys/time.h can be included together */ +#cmakedefine TIME_WITH_SYS_TIME ${TIME_WITH_SYS_TIME} + +/* define if sys/timeb.h exists */ +#cmakedefine HAVE_SYS_TIMEB_H ${HAVE_SYS_TIMEB_H} + +/* define if sys/types.h exists */ +#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES_H} + +/* define if sys/utsname.h exists */ +#cmakedefine HAVE_SYS_UTSNAME_H ${HAVE_SYS_UTSNAME_H} + +/* define if g2c.h exists */ +#cmakedefine HAVE_G2C_H ${HAVE_G2C_H} + +/* define if f2c.h exists */ +#cmakedefine HAVE_F2C_H ${HAVE_F2C_H} + +/* define if cblas.h exists */ +#cmakedefine HAVE_CBLAS_H ${HAVE_CBLAS_H} + +/* define if clapack.h exists */ +#cmakedefine HAVE_CLAPACK_H ${HAVE_CLAPACK_H} + +/* define if "long long" is available */ +#cmakedefine HAVE_LONG_LONG_INT ${HAVE_LONG_LONG_INT} + +/* Define the return type of signal handlers */ +#define RETSIGTYPE ${RETSIGTYPE} + +/* define if ftime() exists */ +#cmakedefine HAVE_FTIME ${HAVE_FTIME} + +/* define if gethostname() exists */ +#cmakedefine HAVE_GETHOSTNAME ${HAVE_GETHOSTNAME} + +/* define if gettimeofday() exists */ +#cmakedefine HAVE_GETTIMEOFDAY ${HAVE_GETTIMEOFDAY} + +/* define if lseek() exists */ +#cmakedefine HAVE_LSEEK ${HAVE_LSEEK} + +/* define if time() exists */ +#cmakedefine HAVE_TIME ${HAVE_TIME} + +/* define if uname() exists */ +#cmakedefine HAVE_UNAME ${HAVE_UNAME} + +/* define if seteuid() exists */ +#cmakedefine HAVE_SETEUID ${HAVE_SETEUID} + +/* define if setpriority() exists */ +#cmakedefine HAVE_SETPRIORITY ${HAVE_SETPRIORITY} + +/* define if setreuid() exists */ +#cmakedefine HAVE_SETREUID ${HAVE_SETREUID} + +/* define if setruid() exists */ +#cmakedefine SETPGRP_VOID ${SETPGRP_VOID} + +/* define if setpgrp() takes no argument */ +#cmakedefine SETPGRP_VOID ${SETPGRP_VOID} + +/* define if drand48() exists */ +#cmakedefine HAVE_DRAND48 ${HAVE_DRAND48} + +/* define if nanosleep() exists */ +#cmakedefine HAVE_NANOSLEEP ${HAVE_NANOSLEEP} + +/* define if asprintf() exists */ +#cmakedefine HAVE_ASPRINTF ${HAVE_ASPRINTF} + +/* define if postgres is to be used */ +#cmakedefine HAVE_POSTGRES ${HAVE_POSTGRES} + +/* define if SQLite is to be used */ +#cmakedefine HAVE_SQLITE ${HAVE_SQLITE} + +/* define if GDAL is to be used */ +#cmakedefine HAVE_GDAL ${HAVE_GDAL} + +/* define if OGR is to be used */ +#cmakedefine HAVE_OGR ${HAVE_OGR} + +/* define if GEOS is to be used */ +#cmakedefine HAVE_GEOS ${HAVE_GEOS} + +/* define if postgres client header exists */ +#cmakedefine HAVE_LIBPQ_FE_H ${HAVE_LIBPQ_FE_H} + +/* define if PQcmdTuples in lpq */ +#cmakedefine HAVE_PQCMDTUPLES ${HAVE_PQCMDTUPLES} + +/* define if ODBC exists */ +#cmakedefine HAVE_SQL_H ${HAVE_SQL_H} + +/* define if tiffio.h exists */ +#cmakedefine HAVE_TIFFIO_H ${HAVE_TIFFIO_H} + +/* define if png.h exists */ +#cmakedefine HAVE_PNG_H ${HAVE_PNG_H} + +/* define if jpeglib.h exists */ +#cmakedefine HAVE_JPEGLIB_H ${HAVE_JPEGLIB_H} + +/* define if proj.h exists */ +#cmakedefine PROJMAJOR ${PROJMAJOR} +#cmakedefine HAVE_PROJ_H ${HAVE_PROJ_H} + +/* define if fftw3.h exists */ +#cmakedefine HAVE_FFTW3_H ${HAVE_FFTW3_H} + +/* define if fftw.h exists */ +#cmakedefine HAVE_FFTW_H ${HAVE_FFTW_H} + +/* define if dfftw.h exists */ +#cmakedefine HAVE_DFFTW_H ${HAVE_DFFTW_H} + +/* define if BLAS exists */ +#cmakedefine HAVE_LIBBLAS ${HAVE_LIBBLAS} + +/* define if LAPACK exists */ +#cmakedefine HAVE_LIBLAPACK ${HAVE_LIBLAPACK} + +/* define if ATLAS exists */ +#cmakedefine HAVE_LIBATLAS ${HAVE_LIBATLAS} + +/* define if dbm.h exists */ +#cmakedefine HAVE_DBM_H ${HAVE_DBM_H} + +/* define if readline exists */ +#cmakedefine HAVE_READLINE_READLINE_H ${HAVE_READLINE_READLINE_H} + +/* define if ft2build.h exists */ +#cmakedefine HAVE_FT2BUILD_H ${HAVE_FT2BUILD_H} + +/* Whether or not we are using G_socks for display communications */ +#cmakedefine USE_G_SOCKS ${USE_G_SOCKS} + +/* define if X is disabled or unavailable */ +#cmakedefine X_DISPLAY_MISSING ${X_DISPLAY_MISSING} + +/* define if libintl.h exists */ +#cmakedefine HAVE_LIBINTL_H ${HAVE_LIBINTL_H} + +/* define if iconv.h exists */ +#cmakedefine HAVE_ICONV_H ${HAVE_ICONV_H} + +/* define if NLS requested */ +#cmakedefine USE_NLS ${USE_NLS} + +/* define if putenv() exists */ +#cmakedefine HAVE_PUTENV ${HAVE_PUTENV} + +/* define if setenv() exists */ +#cmakedefine HAVE_SETENV ${HAVE_SETENV} + +/* define if socket() exists */ +#cmakedefine HAVE_SOCKET ${HAVE_SOCKET} + +/* define if glXCreatePbuffer exists */ +#cmakedefine HAVE_PBUFFERS ${HAVE_PBUFFERS} + +/* define if glXCreateGLXPixmap exists */ +#cmakedefine HAVE_PIXMAPS ${HAVE_PIXMAPS} + +/* define if OpenGL uses X11 */ +#cmakedefine OPENGL_X11 ${OPENGL_X11} + +/* define if OpenGL uses Aqua (MacOS X) */ +#cmakedefine OPENGL_AQUA ${OPENGL_AQUA} + +/* define if OpenGL uses Windows */ +#cmakedefine OPENGL_WINDOWS ${OPENGL_WINDOWS} + +/* define if regex.h exists */ +#cmakedefine HAVE_REGEX_H ${HAVE_REGEX_H} + +/* define if pcre.h exists */ +#cmakedefine HAVE_PCRE_H ${HAVE_PCRE_H} + +/* define if pthread.h exists */ +#cmakedefine HAVE_PTHREAD_H ${HAVE_PTHREAD_H} + +/* define if fseeko() exists */ +#cmakedefine HAVE_FSEEKO ${HAVE_FSEEKO} + +/* + * configuration information solely dependent on the above + * nothing below this point should need changing + */ + +#if defined(HAVE_VALUES_H) && !defined(HAVE_LIMITS_H) +#define INT_MIN -MAXINT +#endif + +/* + * Defines needed to get large file support - from cdrtools-2.01 + */ + +#define HAVE_LARGEFILES ${HAVE_LARGEFILES} + +/* define if langinfo.h exists */ +#cmakedefine HAVE_LANGINFO_H ${HAVE_LANGINFO_H} + +#if defined(__MINGW32__) && (!defined(_FILE_OFFSET_BITS) || (_FILE_OFFSET_BITS != 64)) +/* add/remove as needed */ +/* redefine off_t */ +#include +#define off_t off64_t +/* fseeko and ftello are safe because not defined by MINGW */ +#define HAVE_FSEEKO +#define fseeko fseeko64 +#define ftello ftello64 +/* redefine lseek */ +#include +#define lseek lseek64 +/* redefine stat and fstat */ +/* use _stati64 compatible with MSVCRT < 6.1 */ +#include +#define stat _stati64 +#define fstat _fstati64 + +#endif /* MINGW32 LFS */ + +#ifdef _MSC_VER +#define strncasecmp _strnicmp +#define strcasecmp _stricmp +#define fdopen _fdopen +#define open _open +#define read _read +#define write _write +#define close _close +#define unlink _unlink +#define getpid _getpid +#define creat _creat + +/* define gid_t type */ +typedef @GID_TYPE@ gid_t; + +/* define uid_t type */ +typedef @UID_TYPE@ uid_t; + +/* define pid_t type */ +typedef @PID_TYPE@ pid_t; + +#ifndef S_ISDIR +#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#endif + +#include +typedef SSIZE_T ssize_t; + +/* open for reading, writing, or both (not in fcntl.h) */ +#define O_ACCMODE (_O_RDONLY | _O_WRONLY | _O_RDWR) + +#endif //_MSC_VER + +/* To include export.h generated by cmake */ + +#define GRASS_CMAKE_BUILD 1 +#endif /* _config_h */ diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 00000000000..7aea8391226 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,163 @@ + +set(use_math_DEFS "") +if(MSVC) + set(use_math_DEFS "-D_USE_MATH_DEFINES=1") +endif() + +build_library_in_subdir(datetime) + +add_subdirectory(gis) + +build_library_in_subdir(driver + DEFS "${use_math_DEFS}" + DEPENDS grass_gis FREETYPE ICONV ZLIB) + +add_subdirectory(proj) + +file(GLOB raster_SRCS "./raster/*.c") +list(APPEND raster_SRCS "./gis/gisinit.c") +build_library_in_subdir(raster + DEFS "-DGDAL_DYNAMIC=1;-DGDAL_LINK=1" + SOURCES ${raster_SRCS} + DEPENDS GDAL PROJ grass_gproj) + +if(CMAKE_SYSTEM_NAME MATCHES "Linux") + find_library(DL_LIBRARY dl) + mark_as_advanced(DL_LIBRARY) + target_link_libraries(grass_raster ${DL_LIBRARY}) +endif() + +configure_file(external/ccmath/ccmath.h + ${CMAKE_BINARY_DIR}/include/grass/ccmath_grass.h + COPYONLY) +build_library_in_subdir(external/ccmath) + +build_library_in_subdir(external/shapelib NAME grass_shape + HEADERS "shapefil.h") + +build_library_in_subdir(gmath + DEPENDS grass_ccmath grass_gis + DEFS "${use_math_DEFS}" + OPTIONAL_DEPENDS FFTW) + +build_library_in_subdir(linkm) + +file(GLOB pngdriver_SRCS "./pngdriver/*.c") +list(APPEND pngdriver_SRCS "./driver/init.c") +build_library_in_subdir(pngdriver + SOURCES ${pngdriver_SRCS} + DEPENDS grass_driver LIBPNG ZLIB + INCLUDES "./driver") + +file(GLOB psdriver_SRCS "./psdriver/*.c") +list(APPEND psdriver_SRCS "./driver/init.c") +build_library_in_subdir(psdriver + SOURCES ${psdriver_SRCS} + DEPENDS grass_driver + INCLUDES "./driver") + +file(GLOB htmldriver_SRCS "./htmldriver/*.c") +list(APPEND htmldriver_SRCS "./driver/init.c") +build_library_in_subdir(htmldriver + SOURCES ${htmldriver_SRCS} + DEPENDS grass_driver + INCLUDES "./driver") + +set(_grass_display_DEFS) + +set(_grass_display_DEPENDS + grass_driver grass_raster + grass_htmldriver grass_pngdriver grass_psdriver) + +if(WITH_CAIRO) + + set(_cairodriver_DEPENDS CAIRO FREETYPE grass_driver) + if(WITH_X11) + list(APPEND _cairodriver_DEPENDS X11) + endif() + + file(GLOB cairodriver_SRCS "./cairodriver/*.c") + list(APPEND cairodriver_SRCS "./driver/init.c") + build_library_in_subdir(cairodriver + DEPENDS ${_cairodriver_DEPENDS} + SOURCES ${cairodriver_SRCS}) + + set(_grass_display_DEFS "-DUSE_CAIRO") + list(APPEND _grass_display_DEPENDS grass_cairodriver) +endif() + +build_library_in_subdir(bitmap +SOURCES "./bitmap/bitmap.c" "./bitmap/sparse.c" +DEPENDS grass_linkm) + +build_library_in_subdir(btree) + +build_library_in_subdir(btree2 HEADERS "kdtree.h" DEPENDS grass_gis) + +build_library_in_subdir(display + DEFS ${_grass_display_DEFS} + DEPENDS ${_grass_display_DEPENDS}) + +add_subdirectory(db) + +add_subdirectory(fonts) + +add_subdirectory(vector) + +build_library_in_subdir(imagery DEPENDS GDAL GEOS grass_vector) + +build_library_in_subdir(cluster DEPENDS grass_imagery) + +build_library_in_subdir(rowio DEPENDS grass_gis) + +build_library_in_subdir(segment DEPENDS grass_gis) #addeed DEPENDS grass_gis for uninstd.h + +add_subdirectory(rst) + +build_library_in_subdir(lidar +DEPENDS GDAL GEOS grass_vector grass_raster grass_dbmibase grass_segment +HEADERS "lidar.h") + +build_library_in_subdir(raster3d DEPENDS grass_raster) + +build_program_in_subdir(raster3d/test + NAME test.raster3d.lib + DEPENDS grass_gis grass_raster3d grass_raster) + +build_library_in_subdir(gpde HEADERS "N_*.h" + DEPENDS grass_gis grass_raster3d grass_gmath) + +build_library_in_subdir(dspf DEPENDS grass_gis) + +build_library_in_subdir(symbol NAME grass_sym DEPENDS grass_raster) + +add_subdirectory(init) + +build_library_in_subdir(cdhc DEPENDS grass_raster) + +build_library_in_subdir(stats DEPENDS grass_raster) + +build_library_in_subdir(arraystats DEPENDS grass_gis) + +if(WITH_OPENGL) + build_library_in_subdir(ogsf + DEPENDS grass_raster grass_raster3d OPENGL TIFF) + + build_library_in_subdir(nviz + DEPENDS grass_display grass_raster grass_vector grass_bitmap OPENGL TIFF) +endif() + +add_subdirectory(temporal) + +if(WITH_PYTHON) + add_subdirectory(python) +endif() + +build_library_in_subdir(iostream SRC_REGEX "*.cpp" DEPENDS grass_gis) + +build_library_in_subdir(manage DEPENDS grass_raster grass_vector grass_raster3d ) +file(COPY manage/element_list DESTINATION ${GISBASE}/etc) +install(FILES ${GISBASE}/etc/element_list DESTINATION etc) + +build_library_in_subdir(calc +DEPENDS grass_raster) diff --git a/lib/db/CMakeLists.txt b/lib/db/CMakeLists.txt new file mode 100644 index 00000000000..2796781e8e7 --- /dev/null +++ b/lib/db/CMakeLists.txt @@ -0,0 +1,28 @@ + +file(GLOB dbmibase_SRCS "./dbmi_base/*.c") +if(MSVC) + set(dbmibase_INCLUDES "./dbmi_base" "./dbmi_base/msvc") + list(APPEND dbmibase_SRCS "./dbmi_base/msvc/dirent.c") +endif() + +build_library_in_subdir(dbmi_base NAME grass_dbmibase + INCLUDES ${dbmibase_INCLUDES} + SOURCES ${dbmibase_SRCS} + DEPENDS grass_gis + HEADERS "dbstubs.h") + +build_library_in_subdir(dbmi_client NAME grass_dbmiclient + DEPENDS grass_dbmibase + INCLUDES "./dbmi_base" + ) + +build_library_in_subdir(stubs NAME grass_dstubs + DEPENDS grass_dbmibase + ) + +build_library_in_subdir(dbmi_driver NAME grass_dbmidriver + DEPENDS grass_dstubs + INCLUDES "./dbmi_base" + ) + +add_subdirectory(sqlp) diff --git a/lib/db/sqlp/CMakeLists.txt b/lib/db/sqlp/CMakeLists.txt new file mode 100644 index 00000000000..9fe5ca0f183 --- /dev/null +++ b/lib/db/sqlp/CMakeLists.txt @@ -0,0 +1,17 @@ + +FLEX_TARGET(sqlp.yy.c sqlp.l ${CMAKE_CURRENT_BINARY_DIR}/sqlp.yy.c) + +BISON_TARGET(sqlp.tab.c sqlp.y ${CMAKE_CURRENT_BINARY_DIR}/sqlp.tab.c ) + +ADD_FLEX_BISON_DEPENDENCY(sqlp.yy.c sqlp.tab.c) + +SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/sqlp.yy.c GENERATED) +SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/sqlp.tab.c GENERATED) + +set(sqlp_SRCS + alloc.c print.c sql.c + ${CMAKE_CURRENT_BINARY_DIR}/sqlp.tab.c + ${CMAKE_CURRENT_BINARY_DIR}/sqlp.yy.c + ) + +build_module(NAME grass_sqlp SOURCES "${sqlp_SRCS}" ) diff --git a/lib/fonts/CMakeLists.txt b/lib/fonts/CMakeLists.txt new file mode 100644 index 00000000000..f9bf1abc130 --- /dev/null +++ b/lib/fonts/CMakeLists.txt @@ -0,0 +1 @@ +#TODO diff --git a/lib/gis/CMakeLists.txt b/lib/gis/CMakeLists.txt new file mode 100644 index 00000000000..49a825d61d5 --- /dev/null +++ b/lib/gis/CMakeLists.txt @@ -0,0 +1,68 @@ +set(gislib_SRCS + adj_cellhd.c + copy_dir.c + get_ellipse.c ll_scan.c open_misc.c proj3.c units.c + alloc.c copy_file.c get_projinfo.c locale.c overwrite.c put_window.c user_config.c + area.c counter.c get_window.c location.c pager.c putenv.c verbose.c + area_ellipse.c date.c getl.c lrand48.c parser.c radii.c view.c + area_poly1.c datum.c gisbase.c ls.c parser_dependencies.c rd_cellhd.c whoami.c + area_poly2.c debug.c gisdbase.c ls_filter.c parser_help.c remove.c win32_pipes.c + area_sphere.c distance.c gisinit.c lz4.c parser_html.c rename.c wind_2_box.c + ascii_chk.c done_msg.c handler.c mach_name.c parser_interface.c rhumbline.c wind_format.c + asprintf.c endian.c home.c make_loc.c parser_rest.c rotate.c wind_in.c + basename.c env.c ilist.c make_mapset.c parser_script.c seek.c wind_limits.c + bres_line.c error.c intersect.c mapcase.c parser_standard_options.c set_window.c wind_overlap.c + clicker.c file_name.c is.c mapset.c parser_wps.c short_way.c wind_scan.c + cmprbzip.c find_etc.c key_value1.c mapset_msc.c paths.c sleep.c window_map.c + cmprlz4.c find_file.c key_value2.c mapset_nme.c percent.c snprintf.c worker.c + cmprrle.c find_rast.c key_value3.c mkstemp.c plot.c spawn.c wr_cellhd.c + cmprzlib.c find_rast3d.c key_value4.c myname.c pole_in_poly.c strings.c writ_zeros.c + color_rules.c find_vect.c legal_name.c named_colr.c popen.c tempfile.c xdr.c + color_str.c compress.c line_dist.c nl_to_spaces.c progrm_nme.c timestamp.c zero.c + commas.c geodesic.c list.c nme_in_mps.c proj1.c token.c zone.c + geodist.c ll_format.c open.c proj2.c trim_dec.c parser_json.c cmprzstd.c + compress.c band_reference.c + ) + +if(MINGW) + list(APPEND gislib_SRCS "fmode.c") +endif() + +set(grass_gis_DEFS "-DGRASS_VERSION_DATE=\"${GRASS_VERSION_DATE}\"") +if(MSVC) + set(grass_gis_DEFS "${grass_gis_DEFS};-D_USE_MATH_DEFINES=1") +endif() + +build_module(NAME grass_gis SOURCES "${gislib_SRCS}" + DEPENDS grass_datetime ZLIB + OPTIONAL_DEPENDS PTHREAD BZIP2 ICONV POSTGRES + DEFS "${grass_gis_DEFS}" + ) + +add_custom_command(TARGET grass_gis POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/proj + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/colors ${GISBASE}/etc/colors/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/ellipse.table ${GISBASE}/etc/proj/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/datum.table ${GISBASE}/etc/proj/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/datumtransform.table ${GISBASE}/etc/proj/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/FIPS.code ${GISBASE}/etc/proj/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/state27 ${GISBASE}/etc/proj/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/state83 ${GISBASE}/etc/proj/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/projections ${GISBASE}/etc/proj/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/ellipse.table.solar.system ${GISBASE}/etc/proj/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/colors.desc ${GISBASE}/etc/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/renamed_options ${GISBASE}/etc/ + ) + install(DIRECTORY colors DESTINATION etc/colors) + install(FILES ellipse.table ellipse.table.solar.system + datum.table datumtransform.table + FIPS.code state27 state83 projections DESTINATION etc/proj) + install(FILES colors.desc renamed_options DESTINATION etc) + +if(UNIX) + target_link_libraries(grass_gis LIBM) +endif() + +if(MSVC) +target_link_libraries(grass_gis PCRE) +endif() diff --git a/lib/init/CMakeLists.txt b/lib/init/CMakeLists.txt new file mode 100644 index 00000000000..7ac2d40a3ac --- /dev/null +++ b/lib/init/CMakeLists.txt @@ -0,0 +1,171 @@ + +# #for i18N support + +file(GLOB init_HTMLFILES "*.html") + +#START_UP is the variable used in grass.py, grass.sh.in and grass.bat.in +set(START_UP "grass${GRASS_VERSION_MAJOR}${GRASS_VERSION_MINOR}.py") +if(WIN32) +set(script_file_name "grass.bat") +else() +set(script_file_name "grass.sh") +endif() + +file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR}/bin BINARY_DIR) + +set(CONFIG_PROJSHARE) +get_filename_component(PROJ_INSTALL_PREFIX ${PROJ_INCLUDE_DIR} PATH) +if(DEFINED ENV{PROJSHARE}) + message(WARNING "External PROJ.4 directory not specified; default will be used") + set(CONFIG_PROJSHARE "$ENV{PROJSHARE}") +else() + set(CONFIG_PROJSHARE "${PROJ_INSTALL_PREFIX}/share/proj") + if(EXISTS ${CONFIG_PROJSHARE}/epsg) + message(STATUS "PROJ.4 directory ${CONFIG_PROJSHARE}") + endif() +endif() +file(TO_NATIVE_PATH "${PROJ_INSTALL_PREFIX}/share/proj" PROJ_LIB) +file(TO_NATIVE_PATH ${CONFIG_PROJSHARE} GRASS_PROJSHARE) + +find_path(gdal_share_dir "gdal" PATH_SUFFIXES share) +if(NOT gdal_share_dir) + message(FATAL_ERROR "Cannot find share/gdal") +endif() +mark_as_advanced(gdal_share_dir) + +file(TO_NATIVE_PATH "${gdal_share_dir}/gdal" GDAL_DATA) + +if(MSVC) + find_path(geotiff_share_dir "epsg_csv" PATH_SUFFIXES share) + mark_as_advanced(geotiff_share_dir) + if(geotiff_share_dir) + file(TO_NATIVE_PATH "${geotiff_share_dir}/epsg_csv" GEOTIFF_CSV) + else() + message(FATAL_ERROR "Cannot find share/epsg_csv.") + endif() +endif() #MSVC + +get_filename_component(GDAL_DIR ${GDAL_LIBRARY} PATH) +get_filename_component(GDAL_DIR ${GDAL_DIR} PATH) + +file(TO_NATIVE_PATH ${GDAL_DIR}/bin DEPS_DLL_PATH) +list(APPEND DLL_PATH_LIST ${DEPS_DLL_PATH}) + +file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} GRASS_PYTHON) + +# For install tree (first do install tree) +if(UNIX OR MINGW) + if( DEFINED ENV{LD_LIBRARY_PATH}) + set(LD_LIBRARY_PATH_VAR "${CMAKE_INSTALL_PREFIX}/lib:$ENV{LD_LIBRARY_PATH}") + else() + set(LD_LIBRARY_PATH_VAR "${CMAKE_INSTALL_PREFIX}/lib") + endif() +endif() + +if(WIN32) + set(app_data_dir $ENV{APPDATA}) + if(NOT EXISTS ${app_data_dir}) + # this can happen with some strange settings + message(FATAL_ERROR "The APPDATA variable is not set, ask your operating system support") + endif() + file(TO_NATIVE_PATH "${app_data_dir}/GRASS7" grass_config_dir) +else() + set(grass_config_dir "$ENV{HOME}/.grass7") +endif() + +file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}" gisbase_init_dir) +message(STATUS "GISBASE (install) : ${gisbase_init_dir}") +message(STATUS "grass config directory (install): ${grass_config_dir}") + +#configure and install env.sh +if(NOT MSVC) + configure_file(env.sh ${CMAKE_CURRENT_BINARY_DIR}/bashrc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bashrc + DESTINATION ${grass_config_dir}) +endif() + +#configure and install grass.py +configure_file(grass.py ${CMAKE_CURRENT_BINARY_DIR}/etc/${START_UP} @ONLY) +install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/etc/${START_UP} DESTINATION etc) + +#configure and install grass wrapper script (grass.bat or grass.sh +configure_file(${script_file_name}.in ${CMAKE_CURRENT_BINARY_DIR}/${script_file_name} @ONLY) +install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${script_file_name} DESTINATION bin) + + +# For build tree +file(TO_NATIVE_PATH ${GISBASE} gisbase_init_dir) +file(TO_NATIVE_PATH "${GISBASE}/etc/config" grass_config_dir) +configure_file(${script_file_name}.in ${GISBASE}/${script_file_name} @ONLY) +file(COPY ${CMAKE_SOURCE_DIR}/demolocation/PERMANENT DESTINATION ${GISBASE}/demolocation/) + +configure_file(${CMAKE_SOURCE_DIR}/demolocation/grassrc.cmake.in +"${grass_config_dir}/rc" @ONLY) + +file(TO_NATIVE_PATH ${GISBASE}/bin grass_dll_dir) +set(DLL_PATH_LIST) +list(APPEND DLL_PATH_LIST ${grass_dll_dir}) +separate_arguments(DLL_PATH_LIST) + +set(LD_LIBRARY_PATH_VAR) +if(UNIX OR MINGW) + if( DEFINED ENV{LD_LIBRARY_PATH}) + set(LD_LIBRARY_PATH_VAR "${GISBASE}/lib:$ENV{LD_LIBRARY_PATH}") + else() + set(LD_LIBRARY_PATH_VAR "${GISBASE}/lib") + endif() +endif() +message(STATUS "GISBASE (build) : ${gisbase_init_dir}") +message(STATUS "grass config directory (build): ${grass_config_dir}") +if(NOT MSVC) + configure_file(env.sh ${grass_config_dir}/bashrc @ONLY) + message(STATUS "env variables: ${GISBASE}/etc/config/bashrc") +endif() + +configure_file(grass.py ${GISBASE}/etc/${START_UP} @ONLY) +message(STATUS "Startup (build): ${GISBASE}/${script_file_name}") +message(STATUS "gisrc (build): ${GISBASE}/etc/config/rc") + +#finish installtree and buildtree configurations + + +build_program(NAME echo + SOURCES echo.c + PACKAGE "grasslibs" + RUNTIME_OUTPUT_DIR etc) + +build_program(NAME run + SOURCES run.c + PACKAGE "grasslibs" + RUNTIME_OUTPUT_DIR etc) + +build_program(NAME clean_temp + SOURCES clean_temp.c + DEPENDS grass_gis + PACKAGE "grasslibs" + RUNTIME_OUTPUT_DIR etc) + +build_program(NAME lock + SOURCES lock.c + DEPENDS grass_gis grass_datetime + PACKAGE "grasslibs" + RUNTIME_OUTPUT_DIR etc) + +if(MINGW) +build_program(NAME winlocale + SOURCES winlocale.c + RUNTIME_OUTPUT_DIR etc) +endif() + +set(VERSIONNUMBER_CONTENTS "${GRASS_VERSION_NUMBER}") +if(GRASS_VERSION_GIT) + list(APPEND VERSIONNUMBER_CONTENTS "${VERSIONNUMBER_CONTENTS} ${GRASS_VERSION_GIT}") +endif() + +file(WRITE ${CMAKE_BINARY_DIR}/gisbase/etc/VERSIONNUMBER "${VERSIONNUMBER_CONTENTS}") +install(FILES ${CMAKE_BINARY_DIR}/gisbase/etc/VERSIONNUMBER DESTINATION etc) + +configure_file(license.txt.in ${CMAKE_BINARY_DIR}/gisbase/etc/license) + +install(FILES ${CMAKE_BINARY_DIR}/gisbase/etc/VERSIONNUMBER DESTINATION etc) +install(FILES ${CMAKE_BINARY_DIR}/gisbase/etc/license DESTINATION etc) diff --git a/lib/proj/CMakeLists.txt b/lib/proj/CMakeLists.txt new file mode 100644 index 00000000000..6481331b3a4 --- /dev/null +++ b/lib/proj/CMakeLists.txt @@ -0,0 +1,14 @@ +file(COPY desc.table DESTINATION etc/proj) +file(COPY parms.table DESTINATION etc/proj) +file(COPY units.table DESTINATION etc/proj) + +set(grass_gproj_SOURCES + convert.c datum.c do_proj.c ellipse.c get_proj.c) +if(MINGW) + list(APPEND grass_gproj_SOURCES "ftol.c") +endif() + +build_module(NAME grass_gproj + DEPENDS grass_driver GDAL ZLIB PROJ + SOURCES "${grass_gproj_SOURCES}" + INCLUDES "../driver") diff --git a/lib/python/CMakeLists.txt b/lib/python/CMakeLists.txt new file mode 100644 index 00000000000..d5c83185200 --- /dev/null +++ b/lib/python/CMakeLists.txt @@ -0,0 +1,42 @@ + +copy_python_files_in_subdir(bandref etc/python/grass) +copy_python_files_in_subdir(exceptions etc/python/grass) +copy_python_files_in_subdir(gunittest etc/python/grass) +copy_python_files_in_subdir(imaging etc/python/grass) +copy_python_files_in_subdir(pydispatch etc/python/grass) +copy_python_files_in_subdir(script etc/python/grass) +copy_python_files_in_subdir(temporal etc/python/grass) +copy_python_files_in_subdir(pygrass etc/python/grass) +copy_python_files_in_subdir(pygrass/messages etc/python/grass) +copy_python_files_in_subdir(pygrass/modules etc/python/grass) +copy_python_files_in_subdir(pygrass/raster etc/python/grass) +copy_python_files_in_subdir(pygrass/vector etc/python/grass) +copy_python_files_in_subdir(pygrass/gis etc/python/grass) +copy_python_files_in_subdir(pygrass/shell etc/python/grass) +copy_python_files_in_subdir(pygrass/tests etc/python/grass) +copy_python_files_in_subdir(pygrass/rpc etc/python/grass) +copy_python_files_in_subdir(pygrass/modules/interface etc/python/grass) +copy_python_files_in_subdir(pygrass/modules/grid etc/python/grass) + + +configure_file(script/setup.py + ${CMAKE_BINARY_DIR}/etc/python/grass/script/setup.py + COPYONLY) + +add_custom_target(LIB_PYTHON + COMMAND ${CMAKE_COMMAND} -E echo "#coding=utf-8" > ${GISBASE}/etc/python/__init__.py + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${GISBASE}/etc/python/grass/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/etc/python/grass/script/setup.py ${GISBASE}/etc/python/grass/script/ + DEPENDS python_bandref python_exceptions python_imaging python_pydispatch python_script python_temporal + python_pygrass python_pygrass_messages python_pygrass_modules python_pygrass_modules + python_pygrass_raster python_pygrass_vector python_pygrass_gis python_pygrass_shell + python_pygrass_tests python_pygrass_rpc + python_pygrass_modules_interface + python_pygrass_modules_grid) + +#TODO: MODULES DISABLED +# add_subdirectory(ctypes) + +set_target_properties (LIB_PYTHON PROPERTIES FOLDER lib) + +install(DIRECTORY ${GISBASE}/etc/python/grass DESTINATION etc/python/grass/) diff --git a/lib/python/ctypes/CMakeLists.txt b/lib/python/ctypes/CMakeLists.txt new file mode 100644 index 00000000000..b243f459da4 --- /dev/null +++ b/lib/python/ctypes/CMakeLists.txt @@ -0,0 +1,85 @@ +set(MODULES + date gis raster gmath proj imagery vector rtree display + stats dbmi raster3d arraystats cluster vedit segment rowio temporal) + +if(WITH_OPENGL) + list(APPEND MODULES ogsf nviz) +endif() + +set(date_HDRS datetime.h defs/datetime.h) +set(date_LIBS grass_datetime) +set(date_TARGET_NAME grass_datetime_py) + +set(gis_HDRS gis.h defs/gis.h colors.h defs/colors.h) +set(raster_HDRS raster.h defs/raster.h) +set(gmath_HDRS gmath.h defs/gmath.h) +set(proj_HDRS gprojects.h defs/gprojects.h) +set(proj_LIBS grass_gproj) +set(vector_HDRS vector.h defs/vector.h vect/dig_structs.h vect/dig_defines.h vect/dig_externs.h ) +set(display_HDRS display.h defs/display.h ) +set(dbmi_HDRS dbmi.h defs/dbmi.h ) +set(dbmi_LIBS grass_dbmibase grass_dbmiclient ) +set(arraystats_HDRS arraystats.h defs/arraystats.h ) +set(vedit_HDRS vedit.h defs/vedit.h) +set(nviz_HDRS nviz.h defs/nviz.h) +set(rowio_HDRS rowio.h defs/rowio.h) +set(temporal_HDRS temporal.h) +set(ogsf_HDRS ogsf.h defs/ogsf.h) +set(segment_HDRS segment.h defs/segment.h) +set(imagery_HDRS imagery.h defs/imagery.h ) +set(rtree_HDRS rtree.h) +set(stats_HDRS stats.h defs/stats.h) +set(raster3d_HDRS raster3d.h defs/raster3d.h) +set(cluster_HDRS cluster.h defs/cluster.h) + +#TODO +# set(VECT_INC ${PQINCPATH} ) +# set(proj_INC "${PROJ_INCLUDE_DIR}") +# set(vector_INC "${PQINCPATH};${GDAL_INCLUDE_DIR}") +# set(vedit_INC "${GDAL_INCLUDE_DIR}") + +foreach(module ${MODULES}) + if(NOT ${module}_LIBS) + set(${module}_LIBS grass_${module}) + endif() + + if(NOT ${module}_HDRS) + message(FATAL_ERROR "${module}_HDRS is not set") + endif() + + foreach(${module}_LIB ${${module}_LIBS}) + if(NOT TARGET ${${module}_LIB} ) + message(FATAL_ERROR "${${module}_LIB} is not a target") + endif() + endforeach() + + if(NOT ${module}_TARGET_NAME) + list(GET ${module}_LIBS 0 first_lib) + set(${module}_TARGET_NAME ${first_lib}_py) + endif() + + if(NOT ${module}_TARGET_NAME) + message(FATAL_ERROR "${${module}_TARGET_NAME} is not set") + endif() + + set(output_file "${GISBASE}/etc/python/grass/lib/${module}.py") + + add_custom_command(OUTPUT ${output_file} + DEPENDS ${${module}_LIBS} + COMMAND ${CMAKE_COMMAND} + -DCTYPESGEN_PY=${CMAKE_CURRENT_SOURCE_DIR}/ctypesgen.py + -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DCOMPILER=${CMAKE_C_COMPILER} + -DBIN_DIR=${GISBASE} + -DHDRS=${${module}_HDRS} + -DLIBS=${${module}_LIBS} + -DOUT_FILE=${output_file} + -P ${CMAKE_SOURCE_DIR}/cmake/ctypesgen.cmake + COMMENT "Generating ${output_file}" + VERBATIM) + + add_custom_target(${${module}_TARGET_NAME} ALL DEPENDS ${output_file}) + set_target_properties (${${module}_TARGET_NAME} PROPERTIES FOLDER lib/python) + install(FILES ${output_file} DESTINATION etc/python/grass/lib) + +endforeach() diff --git a/lib/python/script/core.py b/lib/python/script/core.py index 1874f2fb90c..cc057dc708a 100644 --- a/lib/python/script/core.py +++ b/lib/python/script/core.py @@ -129,6 +129,8 @@ def scan(gisbase, directory): dir_path = os.path.join(gisbase, directory) if os.path.exists(dir_path): for fname in os.listdir(os.path.join(gisbase, directory)): + if fname == '__pycache__': + continue if scripts: # win32 name, ext = os.path.splitext(fname) if ext != '.manifest': diff --git a/lib/rst/CMakeLists.txt b/lib/rst/CMakeLists.txt new file mode 100644 index 00000000000..ff48fe130f4 --- /dev/null +++ b/lib/rst/CMakeLists.txt @@ -0,0 +1,21 @@ +#add_subdirectory(data) +#add_subdirectory(qtree) +#add_subdirectory(interp_float) + +build_library_in_subdir(data + NAME grass_interpdata + DEPENDS grass_gis + HEADERS "dataquad.h") + +build_library_in_subdir(qtree + NAME grass_qtree + DEPENDS grass_gis + HEADERS "qtree.h") + + +build_library_in_subdir(interp_float + NAME grass_interpfl + DEFS "-DPOINT2D_C=1" + DEPENDS GEOS grass_gis grass_raster grass_bitmap grass_vector grass_qtree grass_interpdata + HEADERS "interpf.h") + diff --git a/lib/temporal/CMakeLists.txt b/lib/temporal/CMakeLists.txt new file mode 100644 index 00000000000..8b1873bdf4f --- /dev/null +++ b/lib/temporal/CMakeLists.txt @@ -0,0 +1,5 @@ +file(GLOB SQLFILES "SQL/*.sql") +foreach(sqlfile ${SQLFILES}) + install(FILES "${sqlfile}" DESTINATION etc/sql) +endforeach() +build_library_in_subdir(lib NAME grass_temporal DEPENDS grass_dbmibase grass_datetime) diff --git a/lib/vector/CMakeLists.txt b/lib/vector/CMakeLists.txt new file mode 100644 index 00000000000..9e17ce093b8 --- /dev/null +++ b/lib/vector/CMakeLists.txt @@ -0,0 +1,23 @@ +#TODO: docs vectorascii +# PGM = vectorascii + +build_library_in_subdir(rtree HEADERS "rtree.h" DEPENDS grass_gis) + +add_subdirectory(dglib) +add_subdirectory(diglib) + +build_library_in_subdir(Vlib + NAME grass_vector + DEPENDS grass_gis grass_raster grass_rtree + grass_graph grass_dig2 grass_dbmibase + grass_btree2 grass_dbmiclient + grass_linkm grass_gproj + ) + +if(TARGET POSTGRES) + target_link_libraries(grass_vector POSTGRES) +endif() + +add_subdirectory(vedit) + +add_subdirectory(neta) diff --git a/lib/vector/dglib/CMakeLists.txt b/lib/vector/dglib/CMakeLists.txt new file mode 100644 index 00000000000..8c6fe422c1a --- /dev/null +++ b/lib/vector/dglib/CMakeLists.txt @@ -0,0 +1,56 @@ +# MODULE_TOPDIR = ../../.. + +# include $(MODULE_TOPDIR)/include/Make/Vars.make + +# MOD_OBJS := $(filter-out %-template.o,$(AUTO_OBJS)) + +# LIB = GRAPH + +# include $(MODULE_TOPDIR)/include/Make/Lib.make +# include $(MODULE_TOPDIR)/include/Make/Doxygen.make + +# DGLINC = $(ARCH_INCDIR)/dgl + +# default: headers +# $(MAKE) lib + +# headers: $(DGLINC)/avl.h $(DGLINC)/tavl.h $(DGLINC)/graph.h $(DGLINC)/heap.h \ +# $(DGLINC)/tree.h $(DGLINC)/type.h $(DGLINC)/helpers.h $(DGLINC)/graph_v1.h $(DGLINC)/graph_v2.h \ +# $(ARCH_INCDIR)/dgl.h + +# $(DGLINC)/%.h: %.h | $(DGLINC) +# $(INSTALL_DATA) $< $@ + +set(DGL_headers + avl.h + tavl.h + graph.h + heap.h + tree.h + type.h + helpers.h + graph_v1.h + graph_v2.h +) +foreach(DGL_header ${DGL_headers}) + file(COPY ${DGL_header} DESTINATION ${CMAKE_BINARY_DIR}/include/grass/dgl) +endforeach() + +set(graphlib_SRCS + avl.c + graph.c + graph_v2.c + helpers.c + tree.c + graph_v1.c + heap.c + tavl.c + ) + +build_module( + NAME grass_graph + SOURCES "${graphlib_SRCS}" + HEADERS "dgl.h" + ) + + diff --git a/lib/vector/diglib/CMakeLists.txt b/lib/vector/diglib/CMakeLists.txt new file mode 100644 index 00000000000..6bef6eb5711 --- /dev/null +++ b/lib/vector/diglib/CMakeLists.txt @@ -0,0 +1,8 @@ +set(dig2_SRCS +allocation.c cindex.c frmt.c line_dist.c plus.c plus_node.c port_init.c prune.c struct_alloc.c update.c +angle.c cindex_rw.c head.c linecros.c plus_area.c plus_struct.c spindex.c +box.c file.c inside.c list.c plus_line.c poly.c portable.c spindex_rw.c type.c +) +build_module(NAME grass_dig2 + SOURCES ${dig2_SRCS} + DEPENDS GDAL GEOS grass_gmath grass_gis grass_rtree) diff --git a/lib/vector/neta/CMakeLists.txt b/lib/vector/neta/CMakeLists.txt new file mode 100644 index 00000000000..98986c8d33a --- /dev/null +++ b/lib/vector/neta/CMakeLists.txt @@ -0,0 +1,24 @@ +# MODULE_TOPDIR = ../../.. + +# LIB = NETA + +# LIBES = $(VECTORLIB) $(DBMILIB) $(GISLIB) $(GRAPHLIB) +# DEPENDENCIES= $(VECTORDEP) $(DBMIDEP) $(GISDEP) +# EXTRA_INC = $(VECT_INC) +# EXTRA_CFLAGS = $(VECT_CFLAGS) + +# include $(MODULE_TOPDIR)/include/Make/Lib.make +# include $(MODULE_TOPDIR)/include/Make/Doxygen.make + +# default: lib + +# DOXNAME=neta + +build_module(NAME grass_neta +DEPENDS GDAL GEOS +grass_dbmiclient +grass_gis +grass_graph +grass_vector +) + diff --git a/lib/vector/vedit/CMakeLists.txt b/lib/vector/vedit/CMakeLists.txt new file mode 100644 index 00000000000..f48250ec31f --- /dev/null +++ b/lib/vector/vedit/CMakeLists.txt @@ -0,0 +1,21 @@ +# MODULE_TOPDIR = ../../.. + +# LIB = VEDIT + +# DEPENDENCIES = $(VECTORDEP) $(GISDEP) + +# EXTRA_INC = $(VECT_INC) +# EXTRA_CFLAGS = $(VECT_CFLAGS) + +# include $(MODULE_TOPDIR)/include/Make/Lib.make +# include $(MODULE_TOPDIR)/include/Make/Doxygen.make + +# default: lib + +# # doxygen +# DOXNAME=vedit + + +build_module(NAME grass_vedit + DEPENDS grass_vector GDAL GEOS) + diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt new file mode 100644 index 00000000000..d5137a06571 --- /dev/null +++ b/man/CMakeLists.txt @@ -0,0 +1,5 @@ + +set(data_files grassdocs.css grass_logo.png grass_icon.png jquery.fixedheadertable.min.js parser_standard_options.js parser_standard_options.css) + +file(COPY ${data_files} DESTINATION docs/html) +install(FILES ${data_files} DESTINATION docs/html) diff --git a/misc/CMakeLists.txt b/misc/CMakeLists.txt new file mode 100644 index 00000000000..9298252633e --- /dev/null +++ b/misc/CMakeLists.txt @@ -0,0 +1,23 @@ + +build_program_in_subdir( + m.cogo + DEPENDS grass_gis) + +build_program_in_subdir( + m.measure + DEPENDS grass_gis) + +build_program_in_subdir( + m.transform + DEPENDS grass_gis grass_imagery grass_raster grass_vector) + +if(WITH_OPENGL) +build_program_in_subdir( + m.nviz.image + DEPENDS grass_gis grass_ogsf grass_nviz) + +build_program_in_subdir( + m.nviz.script + DEPENDS grass_gis grass_ogsf grass_nviz) +endif(WITH_OPENGL) + diff --git a/raster/CMakeLists.txt b/raster/CMakeLists.txt new file mode 100644 index 00000000000..82e321c567d --- /dev/null +++ b/raster/CMakeLists.txt @@ -0,0 +1,514 @@ +build_program_in_subdir( + r.basins.fill + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.buffer + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.carve + DEPENDS grass_gis grass_raster grass_vector grass_bitmap) + +build_program_in_subdir( + r.category + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.circle + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.clump + DEPENDS grass_gis grass_raster grass_btree2) + +build_program_in_subdir( +r.coin + DEPENDS grass_gis grass_raster ) + +add_subdirectory(r.colors) + +add_subdirectory(r.colors.out) + +build_program_in_subdir( + r.composite + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.compress + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.contour + DEPENDS grass_gis grass_raster grass_vector) + +build_program_in_subdir( + r.cost + DEPENDS grass_gis grass_raster grass_segment grass_vector) + +build_program_in_subdir( + r.covar + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.cross + DEPENDS grass_gis grass_raster grass_btree grass_btree2) + +build_program_in_subdir( + r.describe + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.distance + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.drain + DEPENDS grass_gis grass_raster grass_vector) + +build_program_in_subdir( + r.external + DEPENDS grass_gis grass_raster grass_imagery grass_gproj) + +build_program_in_subdir( + r.external.out + DEPENDS grass_gis grass_raster ) + + build_program_in_subdir( + r.fill.dir + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.flow + DEPENDS grass_gis grass_raster grass_segment grass_vector grass_bitmap) + +build_program_in_subdir(r.geomorphon DEPENDS grass_gis grass_raster grass_gmath) + +build_program_in_subdir( + r.grow.distance + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.gwflow + DEPENDS grass_gis grass_raster grass_gpde) + +build_program_in_subdir( + r.his + DEPENDS grass_gis grass_raster grass_gproj) + +build_program_in_subdir( + r.horizon + DEPENDS grass_gis grass_raster grass_gproj) + +build_program_in_subdir( + r.in.ascii + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.in.bin + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.in.gdal + DEPENDS grass_gis grass_raster grass_gproj grass_imagery) + +build_program_in_subdir( + r.in.gridatb + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.in.mat + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.in.png + DEPENDS grass_gis grass_raster LIBPNG) + +build_program_in_subdir( + r.in.poly + DEPENDS grass_gis grass_raster) + +if(NOT MSVC) +build_program_in_subdir( + r.in.xyz + DEPENDS grass_gis grass_raster) +endif() +build_program_in_subdir( + r.info + TEST_SOURCES "test_r_info.py" + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.kappa + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.latlong + DEPENDS grass_gis grass_raster grass_gproj) + +build_program_in_subdir( + r.lake + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.mfilter + DEPENDS grass_gis grass_raster grass_rowio) + +build_program_in_subdir( + r.mode + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.neighbors + DEPENDS grass_gis grass_raster grass_stats) + +build_program_in_subdir( + r.null + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.ascii + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.bin + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.gdal + DEPENDS grass_gis grass_raster grass_dbmibase grass_imagery) + +set_source_files_properties(r.out.gdal/main.c + PROPERTIES COMPILE_DEFINITIONS + "GRASS_VERSION_NUMBER=\"${GRASS_VERSION_NUMBER}\";GDAL_VERSION_MAJOR=\"2\";GDAL_VERSION_MINOR=\"1\";GDAL_VERSION_REV=\"1\"" + ) + + build_program_in_subdir( + r.out.gridatb + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.mat + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.mpeg + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.png + DEPENDS grass_gis grass_raster LIBPNG) + +build_program_in_subdir( + r.out.pov + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.ppm + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.ppm3 + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.vrml + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.out.vtk + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.param.scale + DEPENDS grass_gis grass_raster grass_interpfl + grass_interpdata grass_qtree ) + +build_program_in_subdir( + r.patch + DEPENDS grass_gis grass_raster) + +build_program_in_subdir(r.path DEPENDS grass_gis grass_raster grass_vector) + +build_program_in_subdir( + r.profile + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.proj + DEPENDS grass_gis grass_raster grass_gproj) + +build_program_in_subdir( + r.quant + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.quantile + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.random + DEPENDS grass_gis grass_raster grass_vector) + +build_program_in_subdir( + r.random.cells + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.random.surface + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.reclass + DEPENDS grass_gis grass_raster grass_manage ) + +build_program_in_subdir( + r.recode + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.region + DEPENDS grass_gis grass_raster grass_vector) + +build_program_in_subdir( + r.regression.line + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.regression.multi + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.report + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.resamp.bspline + DEPENDS grass_gis grass_raster grass_vector grass_segment grass_lidar) + +build_program_in_subdir( + r.resamp.filter + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.resamp.interp + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.resamp.rst + DEPENDS grass_gis grass_raster grass_interpfl grass_interpdata grass_qtree) + +build_program_in_subdir( + r.resamp.stats + DEPENDS grass_gis grass_raster grass_stats) + +build_program_in_subdir( + r.resample + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.rescale + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.rescale.eq + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.ros + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.series + DEPENDS grass_gis grass_raster grass_stats ) + +build_program_in_subdir( + r.series.accumulate + DEPENDS grass_gis grass_raster grass_stats ) + +build_program_in_subdir( + r.series.interp + DEPENDS grass_gis grass_raster grass_stats ) + +build_program_in_subdir( + r.relief + DEPENDS grass_gis grass_raster) + +add_subdirectory(r.sim) + +build_program_in_subdir( + r.slope.aspect + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.solute.transport + DEPENDS grass_gis grass_raster grass_gmath grass_gpde) + +add_subdirectory(r.spread) + +build_program_in_subdir( + r.spreadpath + DEPENDS grass_gis grass_raster grass_segment) + +build_program_in_subdir( + r.statistics + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.stats.zonal + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.stats.quantile + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.stats + DEPENDS grass_gis grass_raster) + + build_program_in_subdir( + r.stream.extract + DEPENDS grass_gis grass_raster grass_segment grass_vector) + +build_program_in_subdir( + r.sun + DEPENDS grass_gmath grass_raster grass_gproj) + +build_program_in_subdir( + r.sunhours + DEPENDS grass_gis grass_raster grass_gproj) + +build_program_in_subdir( + r.sunmask + DEPENDS grass_gis grass_raster grass_gproj) + +build_program_in_subdir( + r.support + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.support.stats + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.surf.area + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.surf.contour + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.surf.fractal + DEPENDS grass_gis grass_raster grass_gmath ) + +build_program_in_subdir( + r.surf.gauss + DEPENDS grass_gis grass_raster grass_gmath ) + +build_program_in_subdir( + r.surf.idw + DEPENDS grass_gis grass_raster ) + +build_program_in_subdir( + r.surf.random + DEPENDS grass_gis grass_raster grass_gmath ) + +if(MSVC) + set(USER_NAME $ENV{USERNAME}) +else() + set(USER_NAME $ENV{USER}) +endif() + +build_program_in_subdir( + r.texture + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.thin + DEPENDS grass_gis grass_raster grass_rowio) + +build_program_in_subdir( + r.tile + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.timestamp + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.to.rast3 + DEPENDS grass_gis grass_raster3d) + +build_program_in_subdir( + r.to.rast3elev + DEPENDS grass_gis grass_raster3d) + +build_program_in_subdir( + r.to.vect + DEPENDS grass_gis grass_raster grass_vector) + +build_program_in_subdir( + r.topidx + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.topmodel + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.transect + DEPENDS grass_gis grass_raster) + +add_subdirectory(r.univar) + +build_program_in_subdir( + r.uslek + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.usler + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.volume + DEPENDS grass_gis grass_raster grass_vector) + +build_program_in_subdir( + r.walk + DEPENDS grass_gis grass_raster grass_segment grass_vector) + +build_program_in_subdir( + r.water.outlet + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.what + DEPENDS grass_gis grass_raster grass_vector) + +build_program_in_subdir( + r.what.color + DEPENDS grass_gis grass_raster) + +build_program_in_subdir( + r.in.lidar + DEPENDS grass_gis grass_raster grass_lidar + PRIMARY_DEPENDS LIBLAS) + +add_subdirectory(r.li) + +add_subdirectory(r.mapcalc) + +build_program_in_subdir( + r.viewshed + DEPENDS grass_gis grass_raster grass_iostream + SRC_REGEX "*.cpp" + DEFS "-DUSER=${USER_NAME}") + + build_program_in_subdir( + r.terraflow + DEPENDS grass_gis grass_raster grass_iostream + SRC_REGEX "*.cpp" + DEFS "-DUSER=${USER_NAME};-DNODATA_FIX;-DELEV_FLOAT") + + add_subdirectory(r.watershed) diff --git a/raster/r.colors.out/CMakeLists.txt b/raster/r.colors.out/CMakeLists.txt new file mode 100644 index 00000000000..dd6ee9e6fc6 --- /dev/null +++ b/raster/r.colors.out/CMakeLists.txt @@ -0,0 +1,16 @@ +set(r_colors_out_SRCS raster_main.c) +set(r3_colors_out_SRCS raster3d_main.c) + +build_program( + NAME r.colors.out + SOURCES "${r_colors_out_SRCS}" + DEPENDS grass_gis grass_raster + ) + +build_program(NAME r3.colors.out + SOURCES "${r3_colors_out_SRCS}" + DEPENDS grass_gis grass_raster3d) + + + + diff --git a/raster/r.colors/CMakeLists.txt b/raster/r.colors/CMakeLists.txt new file mode 100644 index 00000000000..84a6f8a4b41 --- /dev/null +++ b/raster/r.colors/CMakeLists.txt @@ -0,0 +1,12 @@ + +set(r_colors_SRCS raster_main.c edit_colors.c rules.c stats.c) +set(r3_colors_SRCS + raster3d_main.c edit_colors.c rules.c stats.c) + +build_program(NAME r.colors + SOURCES "${r_colors_SRCS}" + DEPENDS grass_gis grass_raster3d) + +build_program(NAME r3.colors + SOURCES "${r3_colors_SRCS}" + DEPENDS grass_gis grass_raster3d) diff --git a/raster/r.li/CMakeLists.txt b/raster/r.li/CMakeLists.txt new file mode 100644 index 00000000000..aca14286828 --- /dev/null +++ b/raster/r.li/CMakeLists.txt @@ -0,0 +1,27 @@ +set(SUBDIRS1 + r.li.cwed + r.li.dominance + r.li.edgedensity + r.li.mpa + r.li.mps + r.li.padcv + r.li.padrange + r.li.padsd + r.li.patchdensity + r.li.patchnum + r.li.pielou + r.li.renyi + r.li.richness + r.li.shannon + r.li.shape + r.li.simpson) +# r.li.setup + +build_library_in_subdir(r.li.daemon + NAME grass_rli + DEPENDS grass_gis grass_raster + HTML_FILE_NAME "r.li.daemon") + +foreach(SUBDIR ${SUBDIRS1}) + build_program_in_subdir(${SUBDIR} DEPENDS grass_rli) +endforeach() diff --git a/raster/r.mapcalc/CMakeLists.txt b/raster/r.mapcalc/CMakeLists.txt new file mode 100644 index 00000000000..f360fa3abe4 --- /dev/null +++ b/raster/r.mapcalc/CMakeLists.txt @@ -0,0 +1,22 @@ + +FLEX_TARGET(mapcalc.yy.c mapcalc.l ${CMAKE_CURRENT_BINARY_DIR}/mapcalc.yy.c ) +BISON_TARGET(mapcalc.tab.c mapcalc.y ${CMAKE_CURRENT_BINARY_DIR}/mapcalc.tab.c ) +ADD_FLEX_BISON_DEPENDENCY(mapcalc.yy.c mapcalc.tab.c) +SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/mapcalc.yy.c GENERATED) +SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/mapcalc.tab.c GENERATED) + +set(r_mapcalc_common_SRCS + column_shift.c evaluate.c expression.c function.c main.c xrowcol.c + ${CMAKE_CURRENT_BINARY_DIR}/mapcalc.tab.c + ${CMAKE_CURRENT_BINARY_DIR}/mapcalc.yy.c ) + +set(r_mapcalc_SRCS ${r_mapcalc_common_SRCS} map.c xarea.c xcoor.c xres.c) +set(r3_mapcalc_SRCS ${r_mapcalc_common_SRCS} map3.c xarea.c xcoor3.c xres3.c) + +build_program(NAME r.mapcalc + SOURCES "${r_mapcalc_SRCS}" + DEPENDS grass_gis grass_btree grass_calc grass_raster) + +#build_program(NAME r3.mapcalc +# SOURCES "${r3_mapcalc_SRCS}" +# DEPENDS grass_gis grass_btree grass_calc grass_raster3d) diff --git a/raster/r.sim/CMakeLists.txt b/raster/r.sim/CMakeLists.txt new file mode 100644 index 00000000000..1e87178a9d3 --- /dev/null +++ b/raster/r.sim/CMakeLists.txt @@ -0,0 +1,15 @@ + +build_library_in_subdir(simlib + NAME grass_sim + DEPENDS grass_datetime grass_raster grass_vector + HEADERS "waterglobs.h" "simlib.h") + +build_program_in_subdir( + r.sim.water + DEPENDS grass_gis grass_gmath grass_sim + INCLUDES "../simlib") + +build_program_in_subdir( + r.sim.sediment + DEPENDS grass_gis grass_gmath grass_sim + INCLUDES "../simlib") diff --git a/raster/r.spread/CMakeLists.txt b/raster/r.spread/CMakeLists.txt new file mode 100644 index 00000000000..75381ff7aeb --- /dev/null +++ b/raster/r.spread/CMakeLists.txt @@ -0,0 +1,8 @@ +set(r_spread_SRCS collect_ori.c deleteHa.c fixHa.c + get_minHa.c insert2Ha.c insertHa.c main.c pick_dist.c + pick_ignite.c ram2out.c replaceHa.c select_linksB.c spot.c spread.c + ) + +build_program(NAME r.spread + SOURCES "${r_spread_SRCS}" + DEPENDS grass_gis grass_raster grass_display) diff --git a/raster/r.univar/CMakeLists.txt b/raster/r.univar/CMakeLists.txt new file mode 100644 index 00000000000..c0d2f41a86b --- /dev/null +++ b/raster/r.univar/CMakeLists.txt @@ -0,0 +1,15 @@ + +set(r_univar_SRCS + r.univar_main.c sort.c stats.c + ) +set(r3_univar_SRCS + r3.univar_main.c sort.c stats.c) + +build_program(NAME r.univar + SOURCES "${r_univar_SRCS}" + DEPENDS grass_gis grass_raster) + +build_program(NAME r3.univar + SOURCES "${r3_univar_SRCS}" + DEPENDS grass_gis grass_raster3d) + diff --git a/raster/r.watershed/CMakeLists.txt b/raster/r.watershed/CMakeLists.txt new file mode 100644 index 00000000000..215183613b2 --- /dev/null +++ b/raster/r.watershed/CMakeLists.txt @@ -0,0 +1,11 @@ +build_program_in_subdir(ram +DEPENDS grass_gis grass_raster grass_btree2 grass_gmath +RUNTIME_OUTPUT_DIR etc/r.watershed) + +build_program_in_subdir(seg +DEPENDS grass_gis grass_raster grass_gmath grass_segment +RUNTIME_OUTPUT_DIR etc/r.watershed) + +build_program_in_subdir(front +NAME r.watershed +DEPENDS grass_gis grass_raster) \ No newline at end of file diff --git a/raster3d/CMakeLists.txt b/raster3d/CMakeLists.txt new file mode 100644 index 00000000000..25734cf71dd --- /dev/null +++ b/raster3d/CMakeLists.txt @@ -0,0 +1,97 @@ + +build_program_in_subdir( + r3.cross.rast + DEPENDS grass_gis grass_raster3d ) + +add_subdirectory(r3.flow) + +build_program_in_subdir( + r3.gradient + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.gwflow + DEPENDS grass_gis grass_raster3d grass_gpde ) + +build_program_in_subdir( + r3.in.ascii + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.in.bin + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.info + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.mask + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.null + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.neighbors + DEPENDS grass_gis grass_raster3d grass_stats) + +build_program_in_subdir( + r3.out.ascii + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.out.bin + DEPENDS grass_gis grass_raster3d ) + +if(NOT MSVC) +build_program_in_subdir( + r3.out.v5d + DEPENDS grass_gis grass_raster3d ) +endif() + +build_program_in_subdir( + r3.retile + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.stats + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.support + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.timestamp + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.to.rast + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.out.vtk + DEPENDS grass_gis grass_raster3d ) + +build_program_in_subdir( + r3.mkdspf + DEPENDS grass_gis grass_raster3d grass_gpde grass_dspf) + +build_program_in_subdir( + r3.in.lidar + DEPENDS grass_gis grass_raster3d grass_segment + PRIMARY_DEPENDS LIBLAS) + +build_program_in_subdir( + r3.out.netcdf + DEPENDS grass_gis grass_raster3d + PRIMARY_DEPENDS NETCDF) + +# mode_t is not available on msvc. Discuss +if(NOT MSVC) + build_program_in_subdir( + r3.in.v5d + DEPENDS grass_gis grass_raster3d) +endif() \ No newline at end of file diff --git a/raster3d/r3.flow/CMakeLists.txt b/raster3d/r3.flow/CMakeLists.txt new file mode 100644 index 00000000000..7a01819e898 --- /dev/null +++ b/raster3d/r3.flow/CMakeLists.txt @@ -0,0 +1,14 @@ +set(r3_flow_SRCS + main.c flowline.c integrate.c interpolate.c voxel_traversal.c + ) + +build_program(NAME r3.flow + SOURCES "${r3_flow_SRCS}" + DEPENDS grass_gis grass_raster3d grass_vector ) + +set(test_r3flow_SRCS + test_main.c flowline.c integrate.c interpolate.c voxel_traversal.c) + +build_program(NAME test.r3flow + SOURCES "${test_r3flow_SRCS}" + DEPENDS grass_gis grass_raster3d grass_vector) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt new file mode 100644 index 00000000000..54aa07d1fdf --- /dev/null +++ b/scripts/CMakeLists.txt @@ -0,0 +1,102 @@ +set(script_DIRS + r.shade + d.correlate + d.frame + d.out.file + d.to.rast + d.polar + d.rast.edit + d.rast.leg + d.redraw + d.shade + d.what.rast + d.what.vect + db.dropcolumn + db.droptable + db.in.ogr + db.out.ogr + db.test + db.univar + g.extension + g.extension.all + g.manual + g.search.modules + i.colors.enhance + i.image.mosaic + i.in.spotvgt + i.oif + i.pansharpen + i.spectral + i.tasscap + m.proj + r.blend + r.buffer.lowmem + r.colors.stddev + r.fillnulls + r.grow + r.import + r.in.aster + r.in.srtm + r.mask + r.out.xyz + r.pack + r.plane + r.reclass.area + r.rgb + r.tileset + r.unpack + r3.in.xyz + v.build.all + v.centroids + v.clip + v.db.addcolumn + v.db.addtable + v.db.join + v.db.dropcolumn + v.db.droprow + v.db.droptable + v.db.renamecolumn + v.db.reconnect.all + v.db.univar + v.db.update + v.dissolve + v.import + v.in.e00 + v.in.geonames + v.in.lines + v.in.mapgen + v.in.wfs + v.rast.stats + v.report + v.pack + v.to.lines + v.unpack + v.what.strds + v.what.vect + wxpyimgview + r.mapcalc.simple + r.in.wms + ) + +foreach(script_DIR ${script_DIRS}) + build_script_in_subdir(${script_DIR}) +endforeach() + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/r.in.wms + DESTINATION ${CMAKE_BINARY_DIR}/etc/) + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/wxpyimgview/wxpyimgview_gui.py + DESTINATION ${CMAKE_BINARY_DIR}/etc/) + +add_custom_target(r.in.wms_files + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/etc/r.in.wms/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/r.in.wms/wms_base.py ${GISBASE}/etc/r.in.wms/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/r.in.wms/wms_cap_parsers.py ${GISBASE}/etc/r.in.wms/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/r.in.wms/wms_drv.py ${GISBASE}/etc/r.in.wms/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/r.in.wms/wms_gdal_drv.py ${GISBASE}/etc/r.in.wms/ + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/r.in.wms/srs.py ${GISBASE}/etc/r.in.wms/ + DEPENDS v.to.lines + ) +add_dependencies(r.in.wms r.in.wms_files) + + set_target_properties (r.in.wms_files PROPERTIES FOLDER scripts) \ No newline at end of file diff --git a/temporal/CMakeLists.txt b/temporal/CMakeLists.txt new file mode 100644 index 00000000000..22f03ce97c7 --- /dev/null +++ b/temporal/CMakeLists.txt @@ -0,0 +1,56 @@ +set(temporal_DIRS + t.create + t.support + t.topology + t.list + t.info + t.merge + t.remove + t.sample + t.register + t.unregister + t.rast.accumulate + t.rast.accdetect + t.rast.aggregate + t.rast.aggregate.ds + t.rast.colors + t.rast.contour + t.rast.to.rast3 + t.rast.univar + t.rast.list + t.rast.mapcalc + t.rast.algebra + t.rast.neighbors + t.rast.series + t.rast.export + t.rast.out.vtk + t.rast.import + t.rast.gapfill + t.rast.extract + t.rast.to.vect + t.rast.what + t.rast3d.list + t.rast3d.extract + t.rast3d.mapcalc + t.rast3d.algebra + t.rast3d.univar + t.rename + t.select + t.snap + t.shift + t.vect.list + t.vect.db.select + t.vect.export + t.vect.extract + t.vect.algebra + t.vect.import + t.vect.what.strds + t.vect.observe.strds + t.vect.univar + ) + +build_program_in_subdir(t.connect DEPENDS grass_gis grass_temporal) + +foreach(temporal_DIR ${temporal_DIRS}) + build_script_in_subdir(${temporal_DIR}) +endforeach() diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt new file mode 100644 index 00000000000..766989972ea --- /dev/null +++ b/thirdparty/CMakeLists.txt @@ -0,0 +1,180 @@ +find_package(FLEX REQUIRED) + +find_package(BISON REQUIRED) + +find_package(PROJ REQUIRED) +add_library(PROJ INTERFACE IMPORTED GLOBAL) +set_property(TARGET PROJ PROPERTY INTERFACE_LINK_LIBRARIES ${PROJ_LIBRARY${find_library_suffix}} ) +set_property(TARGET PROJ PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PROJ_INCLUDE_DIR} ) + +find_package(GDAL REQUIRED) +add_library(GDAL INTERFACE IMPORTED GLOBAL) +set_property(TARGET GDAL PROPERTY INTERFACE_LINK_LIBRARIES ${GDAL_LIBRARY} ) +set_property(TARGET GDAL PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GDAL_INCLUDE_DIR} ) + +find_package(PNG REQUIRED) +add_library(LIBPNG INTERFACE IMPORTED GLOBAL) +set_property(TARGET LIBPNG PROPERTY INTERFACE_LINK_LIBRARIES ${PNG_LIBRARY${find_library_suffix}} ) +set_property(TARGET LIBPNG PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PNG_INCLUDE_DIR} ) + +find_package(JPEG) +if(JPEG_FOUND) + add_library(LIBJPEG INTERFACE IMPORTED GLOBAL) + set_property(TARGET LIBJPEG PROPERTY INTERFACE_LINK_LIBRARIES ${JPEG_LIBRARY${find_library_suffix}} ) + set_property(TARGET LIBJPEG PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${JPEG_INCLUDE_DIR} ) +endif() +find_package(ZLIB REQUIRED) +add_library(ZLIB INTERFACE IMPORTED GLOBAL) +set_property(TARGET ZLIB PROPERTY INTERFACE_LINK_LIBRARIES ${ZLIB_LIBRARY${find_library_suffix}} ) +set_property(TARGET ZLIB PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIR} ) +if(UNIX) +find_library(M_LIBRARY m) +add_library(LIBM INTERFACE IMPORTED GLOBAL) +set_property(TARGET LIBM PROPERTY INTERFACE_LINK_LIBRARIES ${M_LIBRARY} ) +mark_as_advanced(M_LIBRARY) +endif() + +find_package(Freetype REQUIRED) +add_library(FREETYPE INTERFACE IMPORTED GLOBAL) +set_property(TARGET FREETYPE PROPERTY INTERFACE_LINK_LIBRARIES ${FREETYPE_LIBRARY${find_library_suffix}} ) +set_property(TARGET FREETYPE PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${FREETYPE_INCLUDE_DIRS} ) + +find_package(FFTW REQUIRED) +if(FFTW_FOUND) + add_library(FFTW INTERFACE IMPORTED GLOBAL) + set_property(TARGET FFTW PROPERTY INTERFACE_LINK_LIBRARIES ${FFTW_LIBRARIES} ) + set_property(TARGET FFTW PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${FFTW_INCLUDE_DIR} ) +endif() + +if(WITH_CAIRO) + find_package(Cairo REQUIRED) + add_library(CAIRO INTERFACE IMPORTED GLOBAL) + set_property(TARGET CAIRO PROPERTY INTERFACE_LINK_LIBRARIES ${CAIRO_LIBRARIES} ) + set_property(TARGET CAIRO PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CAIRO_INCLUDE_DIRS} ) +endif() + +if(WITH_X11) + find_package(X11 REQUIRED) + add_library(X11 INTERFACE IMPORTED GLOBAL) + set_property(TARGET X11 PROPERTY INTERFACE_LINK_LIBRARIES ${X11_LIBRARIES} ) + set_property(TARGET X11 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${X11_INCLUDE_DIR}) +endif() + +if(WIN32) + find_package(ODBC QUIET) + if(ODBC_FOUND) + add_library(ODBC INTERFACE IMPORTED GLOBAL) + set_property(TARGET ODBC PROPERTY INTERFACE_LINK_LIBRARIES ${ODBC_LIBRARIES} ) + set_property(TARGET PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ODBC_INCLUDE_DIRS}) + endif() +endif() + +find_package(TIFF REQUIRED) +add_library(TIFF INTERFACE IMPORTED GLOBAL) +set_property(TARGET TIFF PROPERTY INTERFACE_LINK_LIBRARIES ${TIFF_LIBRARY${find_library_suffix}} ) +set_property(TARGET TIFF PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${TIFF_INCLUDE_DIR}) + +find_package(Iconv QUIET) +if(ICONV_FOUND) +add_library(ICONV INTERFACE IMPORTED GLOBAL) +set_property(TARGET ICONV PROPERTY INTERFACE_LINK_LIBRARIES ${ICONV_LIBRARIES} ) +set_property(TARGET ICONV PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ICONV_INCLUDE_DIR}) +#if(ICONV_SECOND_ARGUMENT_IS_CONST) +#set() update this value in include/config.cmake.in +endif() + +if(WITH_BZLIB) + find_package(BZip2) + if(BZIP2_FOUND) + add_library(BZIP2 INTERFACE IMPORTED GLOBAL) + set_property(TARGET BZIP2 PROPERTY INTERFACE_LINK_LIBRARIES ${BZIP2_LIBRARY${find_library_suffix}} ) + set_property(TARGET BZIP2 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${BZIP2_INCLUDE_DIR}) + endif() +endif() + +if(WITH_BLAS) + find_package(BLAS) + if(BLAS_FOUND) + add_library(BLAS INTERFACE IMPORTED GLOBAL) + set_property(TARGET BLAS PROPERTY INTERFACE_LINK_LIBRARIES ${BLAS_LIBRARIES} ) + endif() +endif() + +if(WITH_LAPACK) + find_package(LAPACK) + if(LAPACK_FOUND) + add_library(LAPACK INTERFACE IMPORTED GLOBAL) + set_property(TARGET LAPACK PROPERTY INTERFACE_LINK_LIBRARIES ${LAPACK_LIBRARIES} ) + endif() +endif() + +if(WITH_OPENGL) + find_package(OpenGL REQUIRED) + add_library(OPENGL INTERFACE IMPORTED GLOBAL) + set_property(TARGET OPENGL PROPERTY INTERFACE_LINK_LIBRARIES ${OPENGL_LIBRARIES} ) + set_property(TARGET OPENGL PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OPENGL_INCLUDE_DIR} ) +endif() + +if(WITH_POSTGRES) + find_package(PostgreSQL REQUIRED) + add_library(POSTGRES INTERFACE IMPORTED GLOBAL) + set_property(TARGET POSTGRES PROPERTY INTERFACE_LINK_LIBRARIES ${PostgreSQL_LIBRARY} ) + set_property(TARGET POSTGRES PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PostgreSQL_INCLUDE_DIR} ) +endif() + +if(WITH_SQLITE) + find_package(SQLite REQUIRED) + add_library(SQLITE INTERFACE IMPORTED GLOBAL) + set_property(TARGET SQLITE PROPERTY INTERFACE_LINK_LIBRARIES ${SQLITE_LIBRARY} ) + set_property(TARGET SQLITE PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SQLITE_INCLUDE_DIRS} ) +endif() + +find_package(PDAL QUIET) +if(PDAL_FOUND) +add_library(PDAL INTERFACE IMPORTED GLOBAL) +set_property(TARGET PDAL PROPERTY INTERFACE_LINK_LIBRARIES ${PDAL_LIBRARIES} ) +set_property(TARGET PDAL PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PDAL_INCLUDE_DIRS} ) +endif() + +find_package(LibLAS QUIET) +if(LIBLAS_FOUND) + add_library(LIBLAS INTERFACE IMPORTED GLOBAL) + set_property(TARGET LIBLAS PROPERTY INTERFACE_LINK_LIBRARIES ${LibLAS_C_LIBRARY} ) + set_property(TARGET LIBLAS PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${LibLAS_INCLUDE_DIR} ) +endif() + +find_package(NetCDF QUIET) +if(NETCDF_FOUND) + add_library(NETCDF INTERFACE IMPORTED GLOBAL) + set_property(TARGET NETCDF PROPERTY INTERFACE_LINK_LIBRARIES ${NetCDF_LIBRARY} ) + set_property(TARGET NETCDF PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${NetCDF_INCLUDE_DIR} ) +endif() + +find_package(GEOS REQUIRED) +add_library(GEOS INTERFACE IMPORTED GLOBAL) +set_property(TARGET GEOS PROPERTY INTERFACE_LINK_LIBRARIES ${GEOS_C_LIBRARY${find_library_suffix}} ) +set_property(TARGET GEOS PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GEOS_INCLUDE_DIR} ) + +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads) +if(Threads_FOUND) + add_library(PTHREAD INTERFACE IMPORTED GLOBAL) + if(THREADS_HAVE_PTHREAD_ARG) + set_property(TARGET PTHREAD PROPERTY INTERFACE_COMPILE_OPTIONS "-pthread") + endif() + if(CMAKE_THREAD_LIBS_INIT) + set_property(TARGET PTHREAD PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") + endif() +endif() + +if(MSVC) + find_package(PCRE REQUIRED) + add_library(PCRE INTERFACE IMPORTED GLOBAL) + set_property(TARGET PCRE PROPERTY INTERFACE_LINK_LIBRARIES ${PCRE_LIBRARY${find_library_suffix}} ) + set_property(TARGET PCRE PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${PCRE_INCLUDE_DIR} ) +endif() + +# find_package (PythonLibs REQUIRED ) +set(Python_ADDITIONAL_VERSIONS 3.5 3.6) +find_package (PythonInterp REQUIRED ) +# find_package ( Numpy ) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 00000000000..af18a2a4f1f --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,24 @@ +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/mkhtml.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) + +set(current_time_s_ms_SRCS "timer/main.c") +if(MSVC) + list(APPEND current_time_s_ms_SRCS "timer/msvc/gettimeofday.c") +endif() +build_program_in_subdir(timer +NAME current_time_s_ms +DEPENDS grass_gis +SOURCES "${current_time_s_ms_SRCS}" +RUNTIME_OUTPUT_DIR etc) + +build_program(NAME g.echo + SOURCES g.echo.c + RUNTIME_OUTPUT_DIR tools + PACKAGE "NONE") + add_dependencies(g.echo python_doc_tools) + add_custom_target(python_doc_tools + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/mkhtml.py ${GISBASE}/tools + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/g.html2man/g.html2man.py ${GISBASE}/tools + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/g.html2man/ghtml.py ${GISBASE}/tools + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/g.html2man/ggroff.py ${GISBASE}/tools + ) + diff --git a/vector/CMakeLists.txt b/vector/CMakeLists.txt new file mode 100644 index 00000000000..bfa2dbd53ef --- /dev/null +++ b/vector/CMakeLists.txt @@ -0,0 +1,212 @@ + +build_program_in_subdir(v.buffer DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.build DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.build.polylines DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.category DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.class DEPENDS grass_gis grass_vector grass_arraystats) + +build_program_in_subdir(v.clean DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.cluster DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.colors DEPENDS grass_gis grass_vector grass_raster3d) + +build_program_in_subdir(v.colors.out DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.db.connect DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.db.select DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.decimate DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.delaunay DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.distance DEPENDS grass_gis grass_vector grass_gmath) + +build_program_in_subdir(v.drape DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.edit DEPENDS grass_gis grass_vector grass_vedit) + +build_program_in_subdir(v.extract DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.extrude DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.generalize DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.hull DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.info DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.in.ascii DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.in.db DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.in.dxf DEPENDS grass_gis grass_vector) + +file(GLOB v_in_pdal_SOURCES "v.in.pdal/*.c" "v.in.pdal/main.cpp") +build_program_in_subdir( + v.in.pdal + SOURCES "${v_in_pdal_SOURCES}" + DEPENDS grass_gis grass_vector + PRIMARY_DEPENDS PDAL) + +build_program_in_subdir(v.in.region DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.kcv DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.kernel DEPENDS grass_gis grass_vector ) + +build_program_in_subdir(v.label DEPENDS grass_gis grass_vector grass_display) + +build_program_in_subdir(v.label.sa DEPENDS grass_gis grass_vector grass_display) + +build_program_in_subdir(v.proj DEPENDS grass_gis grass_vector grass_gproj) + +build_program_in_subdir(v.profile DEPENDS grass_gis grass_vector) + +add_subdirectory(v.lrs) + +build_program_in_subdir(v.mkgrid DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.neighbors DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.net DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.net.alloc DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.net.allpairs DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.bridge DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.centrality DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.components DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.connectivity DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.distance DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.flow DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.iso DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.path DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.salesman DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.spanningtree DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.steiner DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.timetable DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.net.visibility DEPENDS grass_gis grass_vector grass_neta) + +build_program_in_subdir(v.normal DEPENDS grass_gis grass_vector grass_cdhc) + +build_program_in_subdir(v.out.ascii DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.out.dxf DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.out.pov DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.out.svg DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.out.vtk DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.outlier DEPENDS grass_gis grass_vector grass_lidar) + +build_program_in_subdir(v.overlay DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.parallel DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.patch DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.perturb DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.split DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.qcount DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.random DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.reclass DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.rectify DEPENDS grass_gis grass_vector grass_imagery) + +build_program_in_subdir(v.sample DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.segment DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.select DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.support DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.surf.bspline DEPENDS grass_gis grass_vector grass_lidar grass_gpde) + +build_program_in_subdir(v.surf.idw DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.surf.rst + DEPENDS grass_gis grass_vector grass_interpdata grass_interpfl grass_qtree) + +build_program_in_subdir(v.transform DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.timestamp DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.to.3d DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.to.db DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.to.points DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.to.rast DEPENDS grass_gis grass_vector grass_raster) + +build_program_in_subdir(v.to.rast3 DEPENDS grass_gis grass_vector grass_raster3d) + +build_program_in_subdir(v.type DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.univar DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.voronoi DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.what DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.what.rast DEPENDS grass_gis grass_vector grass_raster) + +build_program_in_subdir(v.what.rast3 DEPENDS grass_gis grass_vector grass_raster3d) + +build_program_in_subdir(v.vect.stats DEPENDS grass_gis grass_vector grass_stats) + +build_program_in_subdir(v.vol.rst + DEPENDS grass_gis grass_vector grass_raster3d grass_bitmap) + +build_program_in_subdir(v.out.ogr DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.in.ogr DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.external DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.external.out DEPENDS grass_gis grass_vector) + +build_program_in_subdir(v.in.lidar DEPENDS grass_gis grass_vector PRIMARY_DEPENDS LIBLAS) + +build_program_in_subdir(v.lidar.correction DEPENDS grass_gis grass_vector grass_lidar + PRIMARY_DEPENDS LIBLAS) + +build_program_in_subdir(v.lidar.edgedetection + DEPENDS grass_gis grass_vector grass_lidar grass_dbmibase grass_gmath + PRIMARY_DEPENDS LIBLAS) + +build_program_in_subdir(v.lidar.growing DEPENDS grass_gis grass_vector PRIMARY_DEPENDS LIBLAS) + +build_program_in_subdir(v.out.lidar DEPENDS grass_gis grass_vector PRIMARY_DEPENDS LIBLAS) + +build_program_in_subdir(v.out.postgis DEPENDS grass_gis grass_vector PRIMARY_DEPENDS POSTGRES) + +if(WITH_OPENDWG) + build_program_in_subdir(v.in.dwg DEPENDS grass_gis grass_vector) +endif() \ No newline at end of file diff --git a/vector/v.lrs/CMakeLists.txt b/vector/v.lrs/CMakeLists.txt new file mode 100644 index 00000000000..f38a7ff17f2 --- /dev/null +++ b/vector/v.lrs/CMakeLists.txt @@ -0,0 +1,19 @@ +build_library_in_subdir(lib NAME grass_lrs + DEPENDS grass_gis grass_vector + HEADERS "lrs.h" ) +add_dependencies(grass_lrs db.drivers) +build_program_in_subdir( + v.lrs.create + DEPENDS grass_lrs) + +build_program_in_subdir( + v.lrs.segment + DEPENDS grass_lrs) + +build_program_in_subdir( + v.lrs.label + DEPENDS grass_lrs) + +build_program_in_subdir( + v.lrs.where + DEPENDS grass_lrs) From 628e04b1d65d46b7a1adcf37091e1ed7aa30ce56 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 14 Jan 2020 12:00:00 +0100 Subject: [PATCH 02/37] Avoid use of bare-exception --- gui/wxpython/tools/build_modules_xml.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gui/wxpython/tools/build_modules_xml.py b/gui/wxpython/tools/build_modules_xml.py index 3dc63921ee1..df7cf79fda4 100644 --- a/gui/wxpython/tools/build_modules_xml.py +++ b/gui/wxpython/tools/build_modules_xml.py @@ -19,6 +19,7 @@ import grass.script.core as gcore import grass.script.task as gtask +from grass.exceptions import ScriptError def escapeXML(text): @@ -80,10 +81,10 @@ def get_module_metadata(name): """ try: task = gtask.parse_interface(name) - except: + except ScriptError as exc: sys.stderr.write("Cannot parse interface for module %s. Empty strings" - " will be placed instead of description and keywords." - "\n" % name) + " will be placed instead of description and keywords. Reason: %s" + "\n" % (name, str(exc))) return '', '' return task.get_description(full=True), \ From 2d3d0ba80f1199d761ecf0031f1946e71ccf0dd9 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 14 Jan 2020 12:00:00 +0100 Subject: [PATCH 03/37] use python3 --- lib/init/grass.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/init/grass.sh b/lib/init/grass.sh index 6c8f6113991..654abc6d3ce 100755 --- a/lib/init/grass.sh +++ b/lib/init/grass.sh @@ -24,7 +24,7 @@ trap "echo 'User break!' ; exit" 2 3 9 15 if [ -z "$GRASS_PYTHON" ] ; then - GRASS_PYTHON=python + GRASS_PYTHON=python3 fi export GRASS_PYTHON From 6ea13bc44fa1d3fd8ebca8dbaefe520d7bcdef03 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Wed, 15 Jan 2020 02:10:00 +0100 Subject: [PATCH 04/37] check for GRASS_CONFIG_DIR to load rc and env.sh from it --- lib/init/grass.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/init/grass.py b/lib/init/grass.py index 1d7887177a9..784d2f89e8d 100644 --- a/lib/init/grass.py +++ b/lib/init/grass.py @@ -371,6 +371,8 @@ def get_grass_config_dir(): Configuration directory is for example used for grass env file (the one which caries mapset settings from session to session). """ + if 'GRASS_CONFIG_DIR' in os.environ: + return os.environ['GRASS_CONFIG_DIR'] if sys.platform == 'win32': grass_config_dirname = "GRASS7" win_conf_path = os.getenv('APPDATA') @@ -627,7 +629,8 @@ def set_paths(grass_config_dir): # Set LD_LIBRARY_PATH (etc) to find GRASS shared libraries # this works for subprocesses but won't affect the current process - path_prepend(gpath("lib"), LD_LIBRARY_PATH_VAR) + if not LD_LIBRARY_PATH_VAR == '': + path_prepend(gpath("lib"), LD_LIBRARY_PATH_VAR) def find_exe(pgm): @@ -1533,7 +1536,7 @@ def get_grass_env_file(sh, grass_config_dir): """Get name of the shell-specific GRASS environment (rc) file""" if sh in ['csh', 'tcsh']: grass_env_file = os.path.join(grass_config_dir, 'cshrc') - elif sh in ['bash', 'msh', 'cygwin', 'sh']: + elif sh in ['bash', 'ash', 'msh', 'cygwin', 'sh']: grass_env_file = os.path.join(grass_config_dir, 'bashrc') elif sh == 'zsh': grass_env_file = os.path.join(grass_config_dir, 'zshrc') From 6de92e69ba6e2c3908425121e5d01a58d25f4162 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Wed, 15 Jan 2020 02:43:00 +0100 Subject: [PATCH 05/37] Add cmake configure input files --- lib/init/env.sh | 10 ++++++++++ lib/init/grass.bat.in | 29 +++++++++++++++++++++++++++++ lib/init/grass.sh.in | 6 ++++++ lib/init/license.txt.in | 11 +++++++++++ 4 files changed, 56 insertions(+) create mode 100644 lib/init/env.sh create mode 100644 lib/init/grass.bat.in create mode 100644 lib/init/grass.sh.in create mode 100644 lib/init/license.txt.in diff --git a/lib/init/env.sh b/lib/init/env.sh new file mode 100644 index 00000000000..95eff198af5 --- /dev/null +++ b/lib/init/env.sh @@ -0,0 +1,10 @@ +export GRASS_PROJSHARE=@GRASS_PROJSHARE@ +export PROJ_LIB=@PROJ_LIB@ +export GDAL_DATA=@GDAL_DATA@ +export GISBASE=@gisbase_init_dir@ +export GRASS_PYTHON=@GRASS_PYTHON@ +export GRASS_CONFIG_DIR=@grass_config_dir@ + +# export PYTHONHOME=$gisbase_init_dir\Python37 +# export FONTCONFIG_FILE=@gisbase_init_dir@\etc\fonts.conf +# export LD_LIBRARY_PATH=@DLL_PATH_LIST@:PATH% diff --git a/lib/init/grass.bat.in b/lib/init/grass.bat.in new file mode 100644 index 00000000000..cb95984ee55 --- /dev/null +++ b/lib/init/grass.bat.in @@ -0,0 +1,29 @@ +@echo off +::set PYTHONHOME=%GISBASE%\Python37 + +set GRASS_PROJSHARE=@GRASS_PROJSHARE@ + +set PROJ_LIB=@PROJ_LIB@ + +set GDAL_DATA=@GDAL_DATA@ + +set GEOTIFF_CSV=@GEOTIFF_CSV@ + +::set FONTCONFIG_FILE=%GISBASE%\etc\fonts.conf + +set PATH=@gisbase_init_dir@\bin;@BINARY_DIR@;@DLL_PATH_LIST@;%PATH% + +set GISBASE=@gisbase_init_dir@ + +set PYTHONPATH=@gisbase_init_dir@\etc\python;@gisbase_init_dir@\gui\wxpython;@gisbase_init_dir@\etc + +set GRASS_PYTHON=@GRASS_PYTHON@ + +set GRASS_CONFIG_DIR=@grass_config_dir@ + +"@GRASS_PYTHON@" "@gisbase_init_dir@\etc\@START_UP@" %* + +rem +rem Pause on error +rem +if %ERRORLEVEL% GEQ 1 pause diff --git a/lib/init/grass.sh.in b/lib/init/grass.sh.in new file mode 100644 index 00000000000..a37f5b2e624 --- /dev/null +++ b/lib/init/grass.sh.in @@ -0,0 +1,6 @@ +#! /bin/sh +trap "echo 'User break!' ; exit" 2 3 9 15 + +. @grass_config_dir@/bashrc + +"$GRASS_PYTHON" "@gisbase_init_dir@/etc/@START_UP@" "$@" diff --git a/lib/init/license.txt.in b/lib/init/license.txt.in new file mode 100644 index 00000000000..c40844420c5 --- /dev/null +++ b/lib/init/license.txt.in @@ -0,0 +1,11 @@ +Geographic Resources Analysis Support System (GRASS) is Copyright, +1999-@GRASS_VERSION_DATE@ by the GRASS Development Team, and licensed under terms of the +GNU General Public License (GPL) version >=2. + +This GRASS GIS @GRASS_VERSION_NUMBER@ release is coordinated and produced by +the GRASS Development Team with contributions from all over the world. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. From 4c97b176e380681bc9ef8fb333f0bcfb35e70f1d Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Wed, 15 Jan 2020 03:00:00 +0100 Subject: [PATCH 06/37] fix install commands --- gui/images/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gui/images/CMakeLists.txt b/gui/images/CMakeLists.txt index 263c9ef1ad4..3f7051820f6 100644 --- a/gui/images/CMakeLists.txt +++ b/gui/images/CMakeLists.txt @@ -18,9 +18,9 @@ add_custom_target(gui_images DEPENDS gui_icons ${output_images}) install(FILES ${GUI_IMAGES} DESTINATION gui/images/) -install(DIRECTORY basic DESTINATION gui/images/symbols/) -install(DIRECTORY demo DESTINATION gui/images/symbols/) -install(DIRECTORY extra DESTINATION gui/images/symbols/) -install(DIRECTORY geology DESTINATION gui/images/symbols/) -install(DIRECTORY legend DESTINATION gui/images/symbols/) -install(DIRECTORY n_arrows DESTINATION gui/images/symbols/) +install(DIRECTORY symbols/basic DESTINATION gui/images/symbols/) +install(DIRECTORY symbols/demo DESTINATION gui/images/symbols/) +install(DIRECTORY symbols/extra DESTINATION gui/images/symbols/) +install(DIRECTORY symbols/geology DESTINATION gui/images/symbols/) +install(DIRECTORY symbols/legend DESTINATION gui/images/symbols/) +install(DIRECTORY symbols/n_arrows DESTINATION gui/images/symbols/) From 7aed3130104d7dc38cf7d003c5e4c9f7f3d94705 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Wed, 15 Jan 2020 03:10:00 +0100 Subject: [PATCH 07/37] PROJ.4 -> PROJ --- cmake/find_scripts/FindPROJ.cmake | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cmake/find_scripts/FindPROJ.cmake b/cmake/find_scripts/FindPROJ.cmake index cc579ed5116..0c63cf8cbcc 100644 --- a/cmake/find_scripts/FindPROJ.cmake +++ b/cmake/find_scripts/FindPROJ.cmake @@ -1,10 +1,10 @@ ############################################################################### -# CMake module to search for PROJ.4 library +# CMake module to search for PROJ library # # On success, the macro sets the following variables: # PROJ_FOUND = if the library found # PROJ_LIBRARY = full path to the library -# PROJ_INCLUDE_DIR = where to find the library headers +# PROJ_INCLUDE_DIR = where to find the library headers # also defined, but not for general use are # PROJ_LIBRARY, where to find the PROJ.4 library. # @@ -51,8 +51,7 @@ MARK_AS_ADVANCED( # Handle the QUIETLY and REQUIRED arguments and set SPATIALINDEX_FOUND to TRUE # if all listed variables are TRUE INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ FOUND_VAR PROJ_FOUND REQUIRED_VARS PROJ_LIBRARY PROJ_INCLUDE_DIR PROJ_VERSION_STRING VERSION_VAR PROJ_VERSION_STRING) - From cbbb42ea512b684a60d10692952655fa6ee0e82a Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 00:14:27 +0100 Subject: [PATCH 08/37] fix ctypesgen --- cmake/ctypesgen.cmake | 10 +++++----- lib/python/CMakeLists.txt | 7 +++---- lib/python/ctypes/CMakeLists.txt | 1 + 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmake/ctypesgen.cmake b/cmake/ctypesgen.cmake index 7fc3edd46d3..48dc84c5ad8 100644 --- a/cmake/ctypesgen.cmake +++ b/cmake/ctypesgen.cmake @@ -4,7 +4,7 @@ # This program is free software under the GPL (>=v2) # Read the file COPYING that comes with GRASS for details. -set(ENV{GISRC} "${BIN_DIR}/demolocation/.grassrc${GRASS_VERSION_MAJOR}${GRASS_VERSION_MINOR}") +set(ENV{GISRC} "${BIN_DIR}/etc/config/rc") set(ENV{GISBASE} "${BIN_DIR}") set(ENV{PATH} "${BIN_DIR}/bin:${BIN_DIR}/scripts:$ENV{PATH}") set(ENV{PYTHONPATH} "${BIN_DIR}/gui/wxpython:${BIN_DIR}/etc/python:$ENV{PYTHONPATH}") @@ -16,12 +16,12 @@ set(ENV{LC_ALL} C) set(LIBRARIES) foreach(LIB ${LIBS}) if(WIN32) - list(APPEND LIBRARIES "--library=${BIN_DIR}/bin/${LIB}.dll") + list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/${LIB}.${GRASS_VERSION_NUMBER}.dll") elseif(APPLE) - list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.so") + list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.${GRASS_VERSION_NUMBER}.so") else() #This can be linux or unix - list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.so") + list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.${GRASS_VERSION_NUMBER}.so") endif() endforeach() @@ -49,7 +49,7 @@ execute_process( --includedir="${BIN_DIR}/include" --runtime-libdir="${BIN_DIR}/lib" ${HEADERS} - ${LIBRARIES} + ${LIBRARIES} --output=${OUT_FILE} OUTPUT_VARIABLE ctypesgen_OV ERROR_VARIABLE ctypesgen_EV diff --git a/lib/python/CMakeLists.txt b/lib/python/CMakeLists.txt index d5c83185200..b6f103f58b4 100644 --- a/lib/python/CMakeLists.txt +++ b/lib/python/CMakeLists.txt @@ -28,14 +28,13 @@ add_custom_target(LIB_PYTHON COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/__init__.py ${GISBASE}/etc/python/grass/ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/etc/python/grass/script/setup.py ${GISBASE}/etc/python/grass/script/ DEPENDS python_bandref python_exceptions python_imaging python_pydispatch python_script python_temporal - python_pygrass python_pygrass_messages python_pygrass_modules python_pygrass_modules - python_pygrass_raster python_pygrass_vector python_pygrass_gis python_pygrass_shell + python_pygrass python_pygrass_messages python_pygrass_modules python_pygrass_modules + python_pygrass_raster python_pygrass_vector python_pygrass_gis python_pygrass_shell python_pygrass_tests python_pygrass_rpc python_pygrass_modules_interface python_pygrass_modules_grid) -#TODO: MODULES DISABLED -# add_subdirectory(ctypes) +add_subdirectory(ctypes) set_target_properties (LIB_PYTHON PROPERTIES FOLDER lib) diff --git a/lib/python/ctypes/CMakeLists.txt b/lib/python/ctypes/CMakeLists.txt index b243f459da4..eabbf11ffea 100644 --- a/lib/python/ctypes/CMakeLists.txt +++ b/lib/python/ctypes/CMakeLists.txt @@ -74,6 +74,7 @@ foreach(module ${MODULES}) -DHDRS=${${module}_HDRS} -DLIBS=${${module}_LIBS} -DOUT_FILE=${output_file} + -DGRASS_VERSION_NUMBER=${GRASS_VERSION_NUMBER} -P ${CMAKE_SOURCE_DIR}/cmake/ctypesgen.cmake COMMENT "Generating ${output_file}" VERBATIM) From 4a915f7cc5fdad4be0636aba9cbd63fa212bdd3f Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 00:15:22 +0100 Subject: [PATCH 09/37] fix build gui/icons --- gui/icons/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gui/icons/CMakeLists.txt b/gui/icons/CMakeLists.txt index 9072ecfbb44..a71e06215be 100644 --- a/gui/icons/CMakeLists.txt +++ b/gui/icons/CMakeLists.txt @@ -20,12 +20,15 @@ endforeach() foreach(ICON ${GRASS_ICONS}) get_filename_component(FILE_NAME ${ICON} NAME) add_custom_command(OUTPUT ${GISBASE}/gui/icons/grass/${FILE_NAME} - COMMAND ${CMAKE_COMMAND} -E copy ${ICON} ${GISBASE}/gui/icons/grass/ - COMMAND ${CMAKE_COMMAND} -E copy ${ICON} ${GISBASE}/docs/html/icons/) + COMMAND ${CMAKE_COMMAND} -E copy ${ICON} ${GISBASE}/gui/icons/grass/) list(APPEND output_icons ${GISBASE}/gui/icons/grass/${FILE_NAME}) + + add_custom_command(OUTPUT ${GISBASE}/docs/html/icons/${FILE_NAME} + COMMAND ${CMAKE_COMMAND} -E copy ${ICON} ${GISBASE}/docs/html/icons/) list(APPEND output_icons ${GISBASE}/docs/html/icons/${FILE_NAME}) endforeach() + foreach(ICON ${FLAGS_ICONS}) get_filename_component(FILE_NAME ${ICON} NAME) add_custom_command(OUTPUT ${GISBASE}/gui/icons/flags/${FILE_NAME} From 4f75c294eaa4c9219fc826e84e01eb759c2cf40b Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 00:16:11 +0100 Subject: [PATCH 10/37] fix cmake deps of nviz, ogsf --- lib/CMakeLists.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 7aea8391226..131f7ccb971 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -8,7 +8,7 @@ build_library_in_subdir(datetime) add_subdirectory(gis) -build_library_in_subdir(driver +build_library_in_subdir(driver DEFS "${use_math_DEFS}" DEPENDS grass_gis FREETYPE ICONV ZLIB) @@ -67,10 +67,10 @@ set(_grass_display_DEFS) set(_grass_display_DEPENDS grass_driver grass_raster - grass_htmldriver grass_pngdriver grass_psdriver) + grass_htmldriver grass_pngdriver grass_psdriver) if(WITH_CAIRO) - + set(_cairodriver_DEPENDS CAIRO FREETYPE grass_driver) if(WITH_X11) list(APPEND _cairodriver_DEPENDS X11) @@ -86,7 +86,7 @@ if(WITH_CAIRO) list(APPEND _grass_display_DEPENDS grass_cairodriver) endif() -build_library_in_subdir(bitmap +build_library_in_subdir(bitmap SOURCES "./bitmap/bitmap.c" "./bitmap/sparse.c" DEPENDS grass_linkm) @@ -114,8 +114,8 @@ build_library_in_subdir(segment DEPENDS grass_gis) #addeed DEPENDS grass_gis for add_subdirectory(rst) -build_library_in_subdir(lidar -DEPENDS GDAL GEOS grass_vector grass_raster grass_dbmibase grass_segment +build_library_in_subdir(lidar +DEPENDS GDAL GEOS grass_vector grass_raster grass_dbmibase grass_segment HEADERS "lidar.h") build_library_in_subdir(raster3d DEPENDS grass_raster) @@ -141,10 +141,10 @@ build_library_in_subdir(arraystats DEPENDS grass_gis) if(WITH_OPENGL) build_library_in_subdir(ogsf - DEPENDS grass_raster grass_raster3d OPENGL TIFF) + DEPENDS grass_raster grass_raster3d grass_vector grass_bitmap OPENGL TIFF) build_library_in_subdir(nviz - DEPENDS grass_display grass_raster grass_vector grass_bitmap OPENGL TIFF) + DEPENDS grass_display grass_raster grass_vector grass_bitmap grass_ogsf OPENGL TIFF) endif() add_subdirectory(temporal) @@ -159,5 +159,5 @@ build_library_in_subdir(manage DEPENDS grass_raster grass_vector grass_raster3d file(COPY manage/element_list DESTINATION ${GISBASE}/etc) install(FILES ${GISBASE}/etc/element_list DESTINATION etc) -build_library_in_subdir(calc +build_library_in_subdir(calc DEPENDS grass_raster) From abea61cd2ba2f7920155b351ee22628a8d1d2382 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Fri, 14 Feb 2020 22:10:00 +0100 Subject: [PATCH 11/37] Support for MSVC. Use _WIN32 instead of __MINGW32__ This is not a search and replace of __MING32__ with _WIN32. There are places where __MINGW32__ is still used and all changes are tested with MSVC 2019 compiler. Although, this commit alone will not work on MSVC because there are plenty of other things to be done which are seperated into multiple PR. PR #289 is the one that "works" on MSVC and unix as well. But that contains too many changes which shouldn't in a single PR. Even though this PR alone won't compile GRASS GIS on MSVC, it sure will not break existing compilers which I think is very important. Complete support for MSVC will be ready after 2/3 PRs https://github.com/OSGeo/grass/pull/289 --- db/drivers/odbc/odbc.h | 2 +- include/gis.h | 6 +++--- include/iostream/rtimer.h | 5 +++-- lib/cairodriver/graph.c | 4 ++-- lib/calc/calc.c | 4 ++-- lib/db/dbmi_base/dbmscap.c | 6 +++--- lib/db/dbmi_client/start.c | 6 +++--- lib/gis/mapset_msc.c | 2 +- lib/gis/paths.c | 10 +++++----- lib/gis/popen.c | 2 +- lib/gis/sleep.c | 6 +++--- lib/gis/spawn.c | 10 +++++----- lib/gis/user_config.c | 4 ++-- lib/gis/whoami.c | 7 +++---- lib/init/clean_temp.c | 5 ++--- lib/init/lock.c | 4 ++-- lib/init/run.c | 2 +- lib/manage/sighold.c | 2 +- lib/pngdriver/graph_close.c | 4 ++-- lib/pngdriver/graph_set.c | 4 ++-- lib/pngdriver/pngdriver.h | 4 ++-- lib/raster/close.c | 4 ++-- lib/raster3d/close.c | 4 ++-- raster/r.li/r.li.daemon/daemon.c | 2 +- raster/r.li/r.li.daemon/worker.c | 2 +- raster/r.terraflow/flow.cpp | 2 +- raster/r.terraflow/main.cpp | 2 +- raster/r.terraflow/stats.cpp | 10 ++++++---- raster/r.to.vect/lines_io.c | 2 +- raster/r.to.vect/util.c | 2 +- 30 files changed, 65 insertions(+), 64 deletions(-) diff --git a/db/drivers/odbc/odbc.h b/db/drivers/odbc/odbc.h index 29294bd87cc..4a63287db82 100644 --- a/db/drivers/odbc/odbc.h +++ b/db/drivers/odbc/odbc.h @@ -1,7 +1,7 @@ #ifndef _ODBC_H_ #define _ODBC_H_ -#ifdef __MINGW32__ +#ifdef _WIN32 #include #endif diff --git a/include/gis.h b/include/gis.h index 75518a6c1be..4a74567de16 100644 --- a/include/gis.h +++ b/include/gis.h @@ -61,7 +61,7 @@ static const char *GRASS_copyright __attribute__ ((unused)) /*! \brief Cross-platform Newline Character */ #define NEWLINE '\n' -#ifdef __MINGW32__ +#ifdef _WIN32 # define HOST_NEWLINE "\r\n" #else # define HOST_NEWLINE "\n" @@ -194,7 +194,7 @@ static const char *GRASS_copyright __attribute__ ((unused)) /* Cross-platform Directory Separator Character and null device stuff */ #define GRASS_DIRSEP '/' -#ifdef __MINGW32__ +#ifdef _WIN32 # define HOST_DIRSEP '\\' # define G_DEV_NULL "NUL:" #else @@ -593,7 +593,7 @@ typedef float FCELL; #if HAVE_INT64_T #include typedef int64_t grass_int64; -#elif defined(__MINGW32__) +#elif defined(_WIN32) typedef __int64 grass_int64; #elif HAVE_LONG_LONG_INT typedef long long int grass_int64; diff --git a/include/iostream/rtimer.h b/include/iostream/rtimer.h index a65fd38650b..9104bb792d9 100644 --- a/include/iostream/rtimer.h +++ b/include/iostream/rtimer.h @@ -38,13 +38,14 @@ #ifndef RTIMER_H #define RTIMER_H -#ifdef __MINGW32__ +#ifdef _WIN32 #include #include #include +#ifdef __MINGW32__ #include - +#endif typedef struct { time_t tv1, tv2; } Rtimer; diff --git a/lib/cairodriver/graph.c b/lib/cairodriver/graph.c index 0bca6e87fe1..3d4e1ba7dae 100644 --- a/lib/cairodriver/graph.c +++ b/lib/cairodriver/graph.c @@ -29,7 +29,7 @@ #endif #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #include #include @@ -390,7 +390,7 @@ static int ends_with(const char *string, const char *suffix) static void map_file(void) { -#ifndef __MINGW32__ +#ifndef _WIN32 size_t size = HEADER_SIZE + ca.width * ca.height * sizeof(unsigned int); void *ptr; int fd; diff --git a/lib/calc/calc.c b/lib/calc/calc.c index 8de40351837..68a6348ae6f 100644 --- a/lib/calc/calc.c +++ b/lib/calc/calc.c @@ -21,7 +21,7 @@ static RETSIGTYPE handle_fpe(int n) void pre_exec(void) { -#ifndef __MINGW32__ +#ifndef _WIN32 #ifdef SIGFPE struct sigaction act; @@ -38,7 +38,7 @@ void pre_exec(void) void post_exec(void) { -#ifndef __MINGW32__ +#ifndef _WIN32 #ifdef SIGFPE struct sigaction act; diff --git a/lib/db/dbmi_base/dbmscap.c b/lib/db/dbmi_base/dbmscap.c index 421655ef665..20c94fba5a0 100644 --- a/lib/db/dbmi_base/dbmscap.c +++ b/lib/db/dbmi_base/dbmscap.c @@ -158,7 +158,7 @@ dbDbmscap *db_read_dbmscap(void) /* START OF NEW CODE FOR SEARCH IN $(GISBASE)/driver/db/ */ /* opend db drivers directory */ -#ifdef __MINGW32__ +#ifdef _WIN32 dirpath = G_malloc(strlen("\\driver\\db\\") + strlen(G_gisbase()) + 1); sprintf(dirpath, "%s\\driver\\db\\", G_gisbase()); G_convert_dirseps_to_host(dirpath); @@ -182,7 +182,7 @@ dbDbmscap *db_read_dbmscap(void) || (strcmp(ent->d_name, "..") == 0)) continue; -#ifdef __MINGW32__ +#ifdef _WIN32 /* skip manifest files on Windows */ if (strstr(ent->d_name, ".manifest")) continue; @@ -191,7 +191,7 @@ dbDbmscap *db_read_dbmscap(void) /* Remove '.exe' from name (windows extension) */ name = G_str_replace(ent->d_name, ".exe", ""); -#ifdef __MINGW32__ +#ifdef _WIN32 dirpath = G_malloc(strlen("\\driver\\db\\") + strlen(G_gisbase()) + strlen(ent->d_name) + 1); sprintf(dirpath, "%s\\driver\\db\\%s", G_gisbase(), ent->d_name); diff --git a/lib/db/dbmi_client/start.c b/lib/db/dbmi_client/start.c index 7bc06fa4bf0..0d6d3041719 100644 --- a/lib/db/dbmi_client/start.c +++ b/lib/db/dbmi_client/start.c @@ -16,7 +16,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #include #include @@ -30,7 +30,7 @@ static void close_on_exec(int fd) { -#ifndef __MINGW32__ +#ifndef _WIN32 int flags = fcntl(fd, F_GETFD); fcntl(fd, F_SETFD, flags | FD_CLOEXEC); #endif @@ -129,7 +129,7 @@ dbDriver *db_start_driver(const char *name) /* run the driver as a child process and create pipes to its stdin, stdout */ -#ifdef __MINGW32__ +#ifdef _WIN32 #define pipe(fds) _pipe(fds, 250000, _O_BINARY | _O_NOINHERIT) #endif diff --git a/lib/gis/mapset_msc.c b/lib/gis/mapset_msc.c index e5b4903c46b..634ba962b0e 100644 --- a/lib/gis/mapset_msc.c +++ b/lib/gis/mapset_msc.c @@ -119,7 +119,7 @@ int G__make_mapset_element_misc(const char *dir, const char *name) static int check_owner(const struct stat *info) { -#if defined(__MINGW32__) || defined(SKIP_MAPSET_OWN_CHK) +#if defined(_WIN32) || defined(SKIP_MAPSET_OWN_CHK) return 1; #else const char *check = getenv("GRASS_SKIP_MAPSET_OWNER_CHECK"); diff --git a/lib/gis/paths.c b/lib/gis/paths.c index 3d5ce59d974..b779f0f1704 100644 --- a/lib/gis/paths.c +++ b/lib/gis/paths.c @@ -3,7 +3,7 @@ #include #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #else #include @@ -26,7 +26,7 @@ int G_mkdir(const char *path) { -#ifdef __MINGW32__ +#ifdef _WIN32 return mkdir(path); #else return mkdir(path, 0777); @@ -62,7 +62,7 @@ int G_is_dirsep(char c) int G_is_absolute_path(const char *path) { if (G_is_dirsep(path[0]) -#ifdef __MINGW32__ +#ifdef _WIN32 || (isalpha(path[0]) && (path[1] == ':') && G_is_dirsep(path[2])) #endif ) @@ -144,7 +144,7 @@ int G_stat(const char *file_name, struct stat *buf) int G_lstat(const char *file_name, struct stat *buf) { -#ifdef __MINGW32__ +#ifdef _WIN32 return stat(file_name, buf); #else return lstat(file_name, buf); @@ -164,7 +164,7 @@ int G_lstat(const char *file_name, struct stat *buf) int G_owner(const char *path) { -#ifndef __MINGW32__ +#ifndef _WIN32 struct stat info; G_stat(path, &info); diff --git a/lib/gis/popen.c b/lib/gis/popen.c index 7d742f46e48..5971ed7838a 100644 --- a/lib/gis/popen.c +++ b/lib/gis/popen.c @@ -6,7 +6,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #include #define pipe(fds) _pipe(fds, 4096, O_BINARY|O_NOINHERIT) diff --git a/lib/gis/sleep.c b/lib/gis/sleep.c index 1a5e2a07ae0..2f3bdce969c 100644 --- a/lib/gis/sleep.c +++ b/lib/gis/sleep.c @@ -1,8 +1,8 @@ #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #endif -#ifdef __MINGW32__ +#ifdef _WIN32 #include #endif #include @@ -10,7 +10,7 @@ /* Sleep */ void G_sleep(unsigned int seconds) { -#ifdef __MINGW32__ +#ifdef _WIN32 /* note: Sleep() cannot be interrupted */ Sleep((seconds) * 1000); #else diff --git a/lib/gis/spawn.c b/lib/gis/spawn.c index 0c88540ac98..329d6aa0c04 100644 --- a/lib/gis/spawn.c +++ b/lib/gis/spawn.c @@ -24,7 +24,7 @@ #include #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #else #include @@ -72,7 +72,7 @@ struct signal int action; int signum; int valid; -#ifndef __MINGW32__ +#ifndef _WIN32 struct sigaction old_act; sigset_t old_mask; #endif @@ -101,7 +101,7 @@ struct spawn static void parse_arglist(struct spawn *sp, va_list va); static void parse_argvec(struct spawn *sp, const char **va); -#ifdef __MINGW32__ +#ifdef _WIN32 struct buffer { char *str; @@ -941,7 +941,7 @@ int G_spawn(const char *command, ...) status = G_spawn_ex( command, -#ifndef __MINGW32__ +#ifndef _WIN32 SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGINT, SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGQUIT, SF_SIGNAL, SST_PRE, SSA_BLOCK, SIGCHLD, @@ -954,7 +954,7 @@ int G_spawn(const char *command, ...) int G_wait(int i_pid) { -#ifdef __MINGW32__ +#ifdef _WIN32 DWORD rights = PROCESS_QUERY_INFORMATION | SYNCHRONIZE; HANDLE hProcess = OpenProcess(rights, FALSE, (DWORD) i_pid); DWORD exitcode; diff --git a/lib/gis/user_config.c b/lib/gis/user_config.c index 5267eb355a9..d4e3c834b8c 100644 --- a/lib/gis/user_config.c +++ b/lib/gis/user_config.c @@ -31,7 +31,7 @@ #include #include #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #endif #include @@ -46,7 +46,7 @@ * path [caller must G_free ()] on success, or NULL on failure *************************************************************************/ -#ifndef __MINGW32__ /* TODO */ +#ifndef _WIN32 /* TODO */ static char *_make_toplevel(void) { size_t len; diff --git a/lib/gis/whoami.c b/lib/gis/whoami.c index 0f704a266b7..590efa702d8 100644 --- a/lib/gis/whoami.c +++ b/lib/gis/whoami.c @@ -10,11 +10,10 @@ * * \author Original author CERL */ - #include #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #endif @@ -40,7 +39,7 @@ const char *G_whoami(void) if (G_is_initialized(&initialized)) return name; -#ifdef __MINGW32__ +#ifdef _WIN32 name = getenv("USERNAME"); #endif if (!name || !*name) @@ -49,7 +48,7 @@ const char *G_whoami(void) if (!name || !*name) name = getenv("USER"); -#ifndef __MINGW32__ +#ifndef _WIN32 if (!name || !*name) { struct passwd *p = getpwuid(getuid()); if (p && p->pw_name && *p->pw_name) diff --git a/lib/init/clean_temp.c b/lib/init/clean_temp.c index 638db98891d..4e1db10f840 100644 --- a/lib/init/clean_temp.c +++ b/lib/init/clean_temp.c @@ -35,7 +35,6 @@ #define SLEEP 30 /* 30 seconds */ /* Recursively scan the directory pathname, removing directory and files */ - void clean_dir(const char *pathname, uid_t uid, pid_t pid, time_t now, int max_age) { @@ -138,7 +137,7 @@ int main(int argc, char *argv[]) G_file_name(tmppath, element, "", mapset = G_mapset()); /* get user id and current time in seconds */ -#ifdef __MINGW32__ +#ifdef _WIN32 /* TODO */ uid = -1; #else @@ -170,7 +169,7 @@ int main(int argc, char *argv[]) int find_process(int pid) { -#ifdef __MINGW32__ +#ifdef _WIN32 /* TODO */ return -1; #else diff --git a/lib/init/lock.c b/lib/init/lock.c index 9bac591bbf5..926a70ac53a 100644 --- a/lib/init/lock.c +++ b/lib/init/lock.c @@ -38,7 +38,7 @@ int main(int argc, char *argv[]) G_fatal_error(_("Usage: %s file pid"), argv[0]); #define file argv[1] -#ifdef __MINGW32__ +#ifdef _WIN32 G_warning(_("Concurrent mapset locking is not supported on Windows")); exit(0); #else @@ -71,7 +71,7 @@ int find_process(int pid) kill failed because no such process, or because user is not owner of process */ -#ifdef __MINGW32__ +#ifdef _WIN32 return 0; #else if (kill(pid, 0) == 0) diff --git a/lib/init/run.c b/lib/init/run.c index 19162cbbc0c..42a1dd64b13 100644 --- a/lib/init/run.c +++ b/lib/init/run.c @@ -23,7 +23,7 @@ the user's shell to re-activate interrupts in shell-ese. int main(int argc, char *argv[]) { signal(SIGINT, SIG_DFL); -#ifndef __MINGW32__ +#ifndef _WIN32 signal(SIGQUIT, SIG_DFL); #endif diff --git a/lib/manage/sighold.c b/lib/manage/sighold.c index d907df01b23..038f76bdccb 100644 --- a/lib/manage/sighold.c +++ b/lib/manage/sighold.c @@ -27,7 +27,7 @@ int M__hold_signals(int hold) signal(SIGINT, sig); -#ifndef __MINGW32__ +#ifndef _WIN32 signal(SIGQUIT, sig); #endif diff --git a/lib/pngdriver/graph_close.c b/lib/pngdriver/graph_close.c index 9fe2ae4bdce..6f7e1e7e513 100644 --- a/lib/pngdriver/graph_close.c +++ b/lib/pngdriver/graph_close.c @@ -16,7 +16,7 @@ #include #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include @@ -33,7 +33,7 @@ static void unmap_file(void) if (!png.mapped) return; -#ifdef __MINGW32__ +#ifdef _WIN32 UnmapViewOfFile(ptr); CloseHandle(png.handle); #else diff --git a/lib/pngdriver/graph_set.c b/lib/pngdriver/graph_set.c index 3092e1bac06..263d4c776d2 100644 --- a/lib/pngdriver/graph_set.c +++ b/lib/pngdriver/graph_set.c @@ -18,7 +18,7 @@ #include #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include @@ -41,7 +41,7 @@ static void map_file(void) if (fd < 0) return; -#ifdef __MINGW32__ +#ifdef _WIN32 png.handle = CreateFileMapping((HANDLE) _get_osfhandle(fd), NULL, PAGE_READWRITE, 0, size, NULL); diff --git a/lib/pngdriver/pngdriver.h b/lib/pngdriver/pngdriver.h index b2fb384700d..3174b63368a 100644 --- a/lib/pngdriver/pngdriver.h +++ b/lib/pngdriver/pngdriver.h @@ -16,7 +16,7 @@ #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #endif @@ -35,7 +35,7 @@ struct png_state int true_color; int has_alpha; int mapped; -#ifdef __MINGW32__ +#ifdef _WIN32 HANDLE handle; #endif diff --git a/lib/raster/close.c b/lib/raster/close.c index 85ba35ad751..a7773d9ebcb 100644 --- a/lib/raster/close.c +++ b/lib/raster/close.c @@ -12,7 +12,7 @@ * \author USACERL and many others */ -#ifdef __MINGW32__ +#ifdef _WIN32 # include #endif @@ -51,7 +51,7 @@ static void sync_and_close(int fd, char *element, char *name) * after you are done writing all your data. */ -#ifndef __MINGW32__ +#ifndef _WIN32 if (fsync(fd)) { G_warning(_("Unable to flush file %s for raster map %s: %s"), element, name, strerror(errno)); diff --git a/lib/raster3d/close.c b/lib/raster3d/close.c index f20bb6abd9a..7e1e5ed551e 100644 --- a/lib/raster3d/close.c +++ b/lib/raster3d/close.c @@ -12,7 +12,7 @@ \author USACERL and many others */ -#ifdef __MINGW32__ +#ifdef _WIN32 # include #endif #include @@ -53,7 +53,7 @@ static int close_new(RASTER3D_Map * map) /* finally move tempfile to data file */ Rast3d_filename(path, RASTER3D_CELL_ELEMENT, map->fileName, map->mapset); -#ifdef __MINGW32__ +#ifdef _WIN32 if (CopyFile(map->tempName, path, FALSE) == 0) { #else if (link(map->tempName, path) < 0) { diff --git a/raster/r.li/r.li.daemon/daemon.c b/raster/r.li/r.li.daemon/daemon.c index c0c9b34385c..cbe43ab3347 100644 --- a/raster/r.li/r.li.daemon/daemon.c +++ b/raster/r.li/r.li.daemon/daemon.c @@ -24,7 +24,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include diff --git a/raster/r.li/r.li.daemon/worker.c b/raster/r.li/r.li.daemon/worker.c index eec45494452..1768b2fcfbd 100644 --- a/raster/r.li/r.li.daemon/worker.c +++ b/raster/r.li/r.li.daemon/worker.c @@ -23,7 +23,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include diff --git a/raster/r.terraflow/flow.cpp b/raster/r.terraflow/flow.cpp index 1d87e9e366a..59e9c92493c 100644 --- a/raster/r.terraflow/flow.cpp +++ b/raster/r.terraflow/flow.cpp @@ -66,7 +66,7 @@ computeFlowAccumulation(AMI_STREAM* fillStream, perror("time"); exit(1); } -#ifdef __MINGW32__ +#ifdef _WIN32 strcpy(buf, ctime(&t)); #else ctime_r(&t, buf); diff --git a/raster/r.terraflow/main.cpp b/raster/r.terraflow/main.cpp index e191a1ad21a..8067a21a221 100644 --- a/raster/r.terraflow/main.cpp +++ b/raster/r.terraflow/main.cpp @@ -300,7 +300,7 @@ void record_args(int argc, char **argv) { exit(1); } -#ifdef __MINGW32__ +#ifdef _WIN32 strcpy(buf, ctime(&t)); #else ctime_r(&t, buf); diff --git a/raster/r.terraflow/stats.cpp b/raster/r.terraflow/stats.cpp index 1d83771605c..3e14a707bc2 100644 --- a/raster/r.terraflow/stats.cpp +++ b/raster/r.terraflow/stats.cpp @@ -20,8 +20,10 @@ #include #include #include +#ifndef _MSC_VER #include -#ifndef __MINGW32__ +#endif +#ifndef _WIN32 #include #endif #include @@ -126,7 +128,7 @@ statsRecorder::statsRecorder(char *fname) : ofstream(noclobberFileName(fname)){ //ofstream that takes an fd; wrote another noclobber() function that //closes fd and returns the name; rt_start(tm); -#ifndef __MINGW32__ +#ifndef _WIN32 bss = sbrk(0); #endif char buf[BUFSIZ]; @@ -137,7 +139,7 @@ statsRecorder::statsRecorder(char *fname) : ofstream(noclobberFileName(fname)){ long statsRecorder::freeMem() { -#ifdef __MINGW32__ +#ifdef _WIN32 return -1; #else struct rlimit rlim; @@ -153,7 +155,7 @@ statsRecorder::freeMem() { } long freeMem = rlim.rlim_cur - ((char*)sbrk(0)-(char*)bss); return freeMem; -#endif /* __MINGW32__ */ +#endif /* _WIN32 */ } char * diff --git a/raster/r.to.vect/lines_io.c b/raster/r.to.vect/lines_io.c index eddc6c23287..470ce65a18a 100644 --- a/raster/r.to.vect/lines_io.c +++ b/raster/r.to.vect/lines_io.c @@ -26,7 +26,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include diff --git a/raster/r.to.vect/util.c b/raster/r.to.vect/util.c index 1219025818b..a58e9ead004 100644 --- a/raster/r.to.vect/util.c +++ b/raster/r.to.vect/util.c @@ -1,7 +1,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include From 4478942806529bc24862334cd2e77aade5cc05e5 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Fri, 14 Feb 2020 23:30:00 +0100 Subject: [PATCH 12/37] MSVC: add unistd.h --- msvc/unistd.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 msvc/unistd.h diff --git a/msvc/unistd.h b/msvc/unistd.h new file mode 100644 index 00000000000..473069b5cf4 --- /dev/null +++ b/msvc/unistd.h @@ -0,0 +1,58 @@ +#ifndef _UNISTD_H +#define _UNISTD_H 1 + +/* This file intended to serve as a drop-in replacement for + * unistd.h on Windows. + * Please add functionality as neeeded. + * Original file from: http://stackoverflow.com/a/826027 + */ + +#include +#include +#include /* for getpid() and the exec..() family */ +#include /* for _getcwd() and _chdir() */ + +#define srandom srand +#define random rand + +/* Values for the second argument to access. + These may be OR'd together. */ +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK R_OK /* execute permission - unsupported in Windows, + use R_OK instead. */ +#define F_OK 0 /* Test for existence. */ + +#define access _access +#define dup2 _dup2 +#define execve _execve +#define ftruncate _chsize +#define unlink _unlink +#define fileno _fileno +#define getcwd _getcwd +#define chdir _chdir +#define isatty _isatty +#define lseek _lseek +/* read, write, and close are NOT being #defined here, + * because while there are file handle specific versions for Windows, + * they probably don't work for sockets. + * You need to look at your app and consider whether + * to call e.g. closesocket(). + */ + +//#define ssize_t int + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 +/* should be in some equivalent to */ + +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; + +#endif /* unistd.h */ From a24d946ff7173463d26a6551cb0473560f7e6eff Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Fri, 14 Feb 2020 23:35:00 +0100 Subject: [PATCH 13/37] MSVC: missing strings.h --- msvc/strings.h | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 msvc/strings.h diff --git a/msvc/strings.h b/msvc/strings.h new file mode 100644 index 00000000000..12d39f1a473 --- /dev/null +++ b/msvc/strings.h @@ -0,0 +1,5 @@ +/* MSVC does not have strings.h */ +#ifndef _INC_STRINGS_H +#define _INC_STRINGS_H 1 +#include +#endif From 69d32cd0c4c91ed23b7fec3a4fc6e65de2cb316a Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Fri, 14 Feb 2020 23:42:00 +0100 Subject: [PATCH 14/37] MSVC: missing dirent on MSVC --- lib/db/dbmi_base/msvc/dirent.c | 113 +++++++++++++++++++++++++++++++++ lib/db/dbmi_base/msvc/dirent.h | 50 +++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 lib/db/dbmi_base/msvc/dirent.c create mode 100644 lib/db/dbmi_base/msvc/dirent.h diff --git a/lib/db/dbmi_base/msvc/dirent.c b/lib/db/dbmi_base/msvc/dirent.c new file mode 100644 index 00000000000..a5466566ecc --- /dev/null +++ b/lib/db/dbmi_base/msvc/dirent.c @@ -0,0 +1,113 @@ + +#include +#include +#include + +typedef ptrdiff_t handle_type; /* C99's intptr_t not sufficiently portable */ + +struct DIR +{ + handle_type handle; /* -1 for failed rewind */ + struct _finddata_t info; + struct dirent result; /* d_name null iff first time */ + char* name; /* null-terminated char string */ +}; + +DIR* opendir(const char* name) +{ + DIR* dir = 0; + + if (name && name[0]) + { + size_t base_length = strlen(name); + const char* all = /* search pattern must end with suitable wildcard */ + strchr("/\\", name[base_length - 1]) ? "*" : "/*"; + + if ((dir = (DIR*)malloc(sizeof * dir)) != 0 && + (dir->name = (char*)malloc(base_length + strlen(all) + 1)) != 0) + { + strcat(strcpy(dir->name, name), all); + + if ((dir->handle = + (handle_type)_findfirst(dir->name, &dir->info)) != -1) + { + dir->result.d_name = 0; + } + else /* rollback */ + { + free(dir->name); + free(dir); + dir = 0; + } + } + else /* rollback */ + { + free(dir); + dir = 0; + errno = ENOMEM; + } + } + else + { + errno = EINVAL; + } + + return dir; +} + +int closedir(DIR* dir) +{ + int result = -1; + + if (dir) + { + if (dir->handle != -1) + { + result = _findclose(dir->handle); + } + + free(dir->name); + free(dir); + } + + if (result == -1) /* map all errors to EBADF */ + { + errno = EBADF; + } + + return result; +} + +struct dirent* readdir(DIR* dir) +{ + struct dirent* result = 0; + + if (dir && dir->handle != -1) + { + if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) + { + result = &dir->result; + result->d_name = dir->info.name; + } + } + else + { + errno = EBADF; + } + + return result; +} + +void rewinddir(DIR* dir) +{ + if (dir && dir->handle != -1) + { + _findclose(dir->handle); + dir->handle = (handle_type)_findfirst(dir->name, &dir->info); + dir->result.d_name = 0; + } + else + { + errno = EBADF; + } +} diff --git a/lib/db/dbmi_base/msvc/dirent.h b/lib/db/dbmi_base/msvc/dirent.h new file mode 100644 index 00000000000..a02a0d828a7 --- /dev/null +++ b/lib/db/dbmi_base/msvc/dirent.h @@ -0,0 +1,50 @@ +#ifndef DIRENT_INCLUDED +#define DIRENT_INCLUDED + +/* + + Declaration of POSIX directory browsing functions and types for Win32. + + Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com) + History: Created March 1997. Updated June 2003. + Rights: See end of file. + +*/ + +#ifdef __cplusplus +extern "C" +{ +#endif + +typedef struct DIR DIR; + +struct dirent +{ + char *d_name; +}; + +DIR *opendir(const char *); +int closedir(DIR *); +struct dirent *readdir(DIR *); +void rewinddir(DIR *); + +/* + + Copyright Kevlin Henney, 1997, 2003. All rights reserved. + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose is hereby granted without fee, provided + that this copyright and permissions notice appear in all copies and + derivatives. + + This software is supplied "as is" without express or implied warranty. + + But that said, if there are any problems please get in touch. + +*/ + +#ifdef __cplusplus +} +#endif + +#endif From 2236aa62408a7cdabc4847c3883aca3e0765b34f Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Fri, 14 Feb 2020 23:48:00 +0100 Subject: [PATCH 15/37] MSVC: win32 gettimeofday replacement from postgresql --- tools/timer/msvc/gettimeofday.c | 122 ++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 tools/timer/msvc/gettimeofday.c diff --git a/tools/timer/msvc/gettimeofday.c b/tools/timer/msvc/gettimeofday.c new file mode 100644 index 00000000000..faf6eb24f1e --- /dev/null +++ b/tools/timer/msvc/gettimeofday.c @@ -0,0 +1,122 @@ +/* + * gettimeofday.c + * Win32 gettimeofday() replacement + * + * src/port/gettimeofday.c + * + * Copyright (c) 2003 SRA, Inc. + * Copyright (c) 2003 SKC, Inc. + * + * Permission to use, copy, modify, and distribute this software and + * its documentation for any purpose, without fee, and without a + * written agreement is hereby granted, provided that the above + * copyright notice and this paragraph and the following two + * paragraphs appear in all copies. + * + * IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, + * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING + * LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS + * DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS + * IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, + * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ +#include + + /* + * 64-bit integers + */ + +#define UINT64CONST(x) (x##UL) + +/* FILETIME of Jan 1 1970 00:00:00, the PostgreSQL epoch */ +static const unsigned __int64 epoch = UINT64CONST(116444736000000000); + +/* + * FILETIME represents the number of 100-nanosecond intervals since + * January 1, 1601 (UTC). + */ +#define FILETIME_UNITS_PER_SEC 10000000L +#define FILETIME_UNITS_PER_USEC 10 + + /* + * Both GetSystemTimeAsFileTime and GetSystemTimePreciseAsFileTime share a + * signature, so we can just store a pointer to whichever we find. This + * is the pointer's type. + */ +typedef VOID(WINAPI * PgGetSystemTimeFn) (LPFILETIME); + +/* One-time initializer function, must match that signature. */ +static void WINAPI init_gettimeofday(LPFILETIME lpSystemTimeAsFileTime); + +/* Storage for the function we pick at runtime */ +static PgGetSystemTimeFn pg_get_system_time = &init_gettimeofday; + +/* + * One time initializer. Determine whether GetSystemTimePreciseAsFileTime + * is available and if so, plan to use it; if not, fall back to + * GetSystemTimeAsFileTime. + */ +static void WINAPI +init_gettimeofday(LPFILETIME lpSystemTimeAsFileTime) +{ + /* + * Because it's guaranteed that kernel32.dll will be linked into our + * address space already, we don't need to LoadLibrary it and worry about + * closing it afterwards, so we're not using Pg's dlopen/dlsym() wrapper. + * + * We'll just look up the address of GetSystemTimePreciseAsFileTime if + * present. + * + * While we could look up the Windows version and skip this on Windows + * versions below Windows 8 / Windows Server 2012 there isn't much point, + * and determining the windows version is its self somewhat Windows + * version and development SDK specific... + */ + pg_get_system_time = (PgGetSystemTimeFn)GetProcAddress( + GetModuleHandle(TEXT("kernel32.dll")), + "GetSystemTimePreciseAsFileTime"); + if (pg_get_system_time == NULL) + { + /* + * The expected error from GetLastError() is ERROR_PROC_NOT_FOUND, if + * the function isn't present. No other error should occur. + * + * We can't report an error here because this might be running in + * frontend code; and even if we're in the backend, it's too early to + * elog(...) if we get some unexpected error. Also, it's not a + * serious problem, so just silently fall back to + * GetSystemTimeAsFileTime irrespective of why the failure occurred. + */ + pg_get_system_time = &GetSystemTimeAsFileTime; + } + + (*pg_get_system_time) (lpSystemTimeAsFileTime); +} + +/* + * timezone information is stored outside the kernel so tzp isn't used anymore. + * + * Note: this function is not for Win32 high precision timing purposes. See + * elapsed_time(). + */ +int +gettimeofday(struct timeval* tp, struct timezone* tzp) +{ + FILETIME file_time; + ULARGE_INTEGER ularge; + + (*pg_get_system_time) (&file_time); + ularge.LowPart = file_time.dwLowDateTime; + ularge.HighPart = file_time.dwHighDateTime; + + tp->tv_sec = (long)((ularge.QuadPart - epoch) / FILETIME_UNITS_PER_SEC); + tp->tv_usec = (long)(((ularge.QuadPart - epoch) % FILETIME_UNITS_PER_SEC) + / FILETIME_UNITS_PER_USEC); + + return 0; +} From fb134e02cdd592767bcd2ddbc7a57aebaa1bce35 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 13:12:00 +0100 Subject: [PATCH 16/37] MSVC: add __declspec attribute on windows --- include/calc.h | 12 +++++++++--- include/iostream/mm.h | 10 +++++++--- lib/dspf/viz.h | 8 ++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/include/calc.h b/include/calc.h index e0ba60c695f..2e6fcc87d3d 100644 --- a/include/calc.h +++ b/include/calc.h @@ -33,12 +33,18 @@ typedef struct func_desc #define SET_NULL_F(x) (Rast_set_f_null_value((x),1)) #define SET_NULL_D(x) (Rast_set_d_null_value((x),1)) -extern volatile int floating_point_exception; -extern volatile int floating_point_exception_occurred; +#ifdef GRASS_CMAKE_BUILD +#include +#else +#define GRASS_CALC_EXPORT +#endif + +extern GRASS_CALC_EXPORT volatile int floating_point_exception; +extern GRASS_CALC_EXPORT volatile int floating_point_exception_occurred; extern int columns; -extern func_desc calc_func_descs[]; +extern GRASS_CALC_EXPORT func_desc calc_func_descs[]; #include diff --git a/include/iostream/mm.h b/include/iostream/mm.h index c85c3ddc651..92d934ae8be 100644 --- a/include/iostream/mm.h +++ b/include/iostream/mm.h @@ -84,11 +84,15 @@ enum MM_stream_usage { }; - +#ifdef GRASS_CMAKE_BUILD +#include +#else +#define GRASS_IOSTREAM_EXPORT +#endif // Declarations of a very simple memory manager designed to work with // BTEs that rely on the underlying OS to manage physical memory. -class MM_register { +class GRASS_IOSTREAM_EXPORT MM_register { private: // The number of instances of this class and descendents that exist. static int instances; @@ -170,7 +174,7 @@ static mm_register_init source_file_mm_register_init; // Here is the single memory management object (defined in mm.C). -extern MM_register MM_manager; +extern GRASS_IOSTREAM_EXPORT MM_register MM_manager; diff --git a/lib/dspf/viz.h b/lib/dspf/viz.h index 8628e710ac1..73f8ed87212 100644 --- a/lib/dspf/viz.h +++ b/lib/dspf/viz.h @@ -97,5 +97,9 @@ int print_head_info(file_info *); /* struct_copy.c */ int struct_copy(char *, char *, int); - -extern CELL_ENTRY cell_table[]; +#ifdef GRASS_CMAKE_BUILD +#include +#else +#define GRASS_DSPF_EXPORT +#endif +extern GRASS_DSPF_EXPORT CELL_ENTRY cell_table[]; From d1caa3ec7e1d118c6d5ee9d86ca56cdf3eb48e12 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 13:18:00 +0100 Subject: [PATCH 17/37] export static int initialized static int initialized is not working for MSVC and must export this with __declspec so that it appears in a DLL correctly. This change has been tested on Ubuntu and MSVC 2019 and is working as expected. --- lib/gis/gisinit.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/gis/gisinit.c b/lib/gis/gisinit.c index 864a44924a7..ddfef70f183 100644 --- a/lib/gis/gisinit.c +++ b/lib/gis/gisinit.c @@ -26,9 +26,25 @@ #include "G.h" #include "gis_local_proto.h" +#ifdef GRASS_CMAKE_BUILD +#include +#else +#define GRASS_GIS_EXPORT +#endif struct G__ G__; -static int initialized = 0; /** Is set when engine is initialized */ +/** initialized is set to 1 when engine is initialized */ +/* GRASS_GIS_EXPORT static int initialized on windows msvc throws below error. +"Error C2201 'initialized': must have external linkage in order to be exported/imported" +So we do an ifndef on msvc. without GRASS_GIS_EXPORT it will be exported in DLL. +*/ +#ifndef _MSC_VER +static int initialized = 0; +#else +GRASS_GIS_EXPORT int initialized; +#endif + + static int gisinit(void); /*! From 57a6ed18aa7a6a351f54ae3196dd428438a5ec37 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 13:44:00 +0100 Subject: [PATCH 18/37] MSVC: ostream header is avaiable in GCC and MSVC --- raster/r.terraflow/common.cpp | 2 +- raster/r.terraflow/direction.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/raster/r.terraflow/common.cpp b/raster/r.terraflow/common.cpp index fe7da9e530c..03011d854d6 100644 --- a/raster/r.terraflow/common.cpp +++ b/raster/r.terraflow/common.cpp @@ -23,7 +23,7 @@ #endif #include -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (_MSC_VER) #include #else #include diff --git a/raster/r.terraflow/direction.h b/raster/r.terraflow/direction.h index 7a2f53b2555..5b293896168 100644 --- a/raster/r.terraflow/direction.h +++ b/raster/r.terraflow/direction.h @@ -22,7 +22,7 @@ #include -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined(_MSC_VER) #include #else #include From 5696858187febb6c201dce451117f371f66aa15c Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 13:44:00 +0100 Subject: [PATCH 19/37] missing include --- raster/r.viewshed/statusstructure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raster/r.viewshed/statusstructure.cpp b/raster/r.viewshed/statusstructure.cpp index 88415a5c8a8..668ed291495 100644 --- a/raster/r.viewshed/statusstructure.cpp +++ b/raster/r.viewshed/statusstructure.cpp @@ -40,7 +40,7 @@ #include #include #include - +#include extern "C" { #include From bfb3f12f8bf30254c3eab3ed1c2b9ea9223bc030 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 13:49:00 +0100 Subject: [PATCH 20/37] MSVC: disable warning for function without return type Below is a code from filldepr.cpp which throws error on msvc compiler function has G_fatal_error() so it is 'normal' to have no return type. But MSVC complains that function's return type is elevation_type* and does not return anything. elevation_type* ext_fill_depression(AMI_STREAM *boundaryStr, cclabel_type maxWatersheds) { G_fatal_error(_("Fill_depressions do not fit in memory. Not implemented yet")); } --- raster/r.terraflow/filldepr.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/raster/r.terraflow/filldepr.cpp b/raster/r.terraflow/filldepr.cpp index 15767c2b2d4..928b0017a30 100644 --- a/raster/r.terraflow/filldepr.cpp +++ b/raster/r.terraflow/filldepr.cpp @@ -22,6 +22,9 @@ #include "unionFind.h" #include "common.h" +#ifdef _MSC_VER +#pragma warning(default:4716) +#endif #define FLOOD_DEBUG if(0) /************************************************************/ From 63574150c107f5af3b3e4c6b57d34cf6fcd4bf98 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 13:55:00 +0100 Subject: [PATCH 21/37] MSVC: chmod is unix only --- lib/db/dbmi_base/login.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/db/dbmi_base/login.c b/lib/db/dbmi_base/login.c index ac650d73a4e..ffd5a8544f5 100644 --- a/lib/db/dbmi_base/login.c +++ b/lib/db/dbmi_base/login.c @@ -167,8 +167,9 @@ static int write_file(LOGIN * login) /* fchmod is not available on Windows */ /* fchmod ( fileno(fd), S_IRUSR | S_IWUSR ); */ + #ifndef _MSC_VER chmod(file, S_IRUSR | S_IWUSR); - + #endif for (i = 0; i < login->n; i++) { fprintf(fd, "%s|%s", login->data[i].driver, login->data[i].database); if (login->data[i].user) { From e0b717051dcaa0868f9acc5812c313d4c336d594 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 14:15:00 +0100 Subject: [PATCH 22/37] MSVC: fix struct complex --- lib/external/ccmath/ccmath.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/external/ccmath/ccmath.h b/lib/external/ccmath/ccmath.h index 3a90ce68df2..69ab5e34c46 100644 --- a/lib/external/ccmath/ccmath.h +++ b/lib/external/ccmath/ccmath.h @@ -33,10 +33,16 @@ #endif /* Complex Types */ - #ifndef CPX -struct complex {double re,im;}; -typedef struct complex Cpx; +#ifndef _MSC_VER + struct complex {double re,im;}; + typedef struct complex Cpx; +#else + /* _MSVC has complex struct and cannot be used */ + struct gcomplex {double re,im;}; + typedef struct gcomplex Cpx; +#endif /* _MSC_VER */ + #define CPX 1 #endif From af03bf1d58faeb60cccf2fb718dfa47059bb0af0 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 14:34:00 +0100 Subject: [PATCH 23/37] MSVC does not support VLAs The MSVC compiler only supports C90, it does not support C99 and variable length arrays are a feature of C99. --- imagery/i.landsat.acca/algorithm.c | 17 ++++++++--------- imagery/i.landsat.acca/local_proto.h | 2 +- imagery/i.landsat.acca/main.c | 2 +- lib/imagery/iscatt_core.c | 20 ++++++++++++-------- raster/r.mapcalc/map.c | 6 ++++-- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/imagery/i.landsat.acca/algorithm.c b/imagery/i.landsat.acca/algorithm.c index 57c76b1800b..937e1d5fd84 100644 --- a/imagery/i.landsat.acca/algorithm.c +++ b/imagery/i.landsat.acca/algorithm.c @@ -71,22 +71,21 @@ double th_6 = 2.16248; /* Band 4/2 Ratio */ double th_7 = 1.0; /* Band 4/5 Ratio */ ; double th_8 = 210.; /* Band 5/6 Composite */ -extern int hist_n; - void acca_algorithm(Gfile * out, Gfile band[], - int single_pass, int with_shadow, int cloud_signature) + int single_pass, int with_shadow, int cloud_signature, int hist_n) { - int i, count[5], hist_cold[hist_n], hist_warm[hist_n]; - double max, value[5], signa[5], idesert, review_warm, shift; + int i, count[5]; + double max, value[5], signa[5], idesert, shift; + int review_warm; + int* hist_cold, *hist_warm; + hist_cold = (int*)G_calloc(hist_n, sizeof(int)); + hist_warm = (int*)G_calloc(hist_n, sizeof(int)); /* Reset variables ... */ for (i = 0; i < 5; i++) { count[i] = 0; value[i] = 0.; } - for (i = 0; i < hist_n; i++) { - hist_cold[i] = hist_warm[i] = 0; - } /* FIRST FILTER ... */ acca_first(out, band, with_shadow, @@ -207,7 +206,7 @@ void acca_algorithm(Gfile * out, Gfile band[], /* SECOND FILTER ... */ /* By-pass two processing but it retains warm and cold clouds */ if (single_pass == TRUE) { - review_warm = -1.; + review_warm = -1; value[KUPPER] = 0.; value[KLOWER] = 0.; } diff --git a/imagery/i.landsat.acca/local_proto.h b/imagery/i.landsat.acca/local_proto.h index 90394af8b86..eaad933a743 100644 --- a/imagery/i.landsat.acca/local_proto.h +++ b/imagery/i.landsat.acca/local_proto.h @@ -28,7 +28,7 @@ typedef struct } Gfile; -void acca_algorithm(Gfile *, Gfile[], int, int, int); +void acca_algorithm(Gfile *, Gfile[], int, int, int, int); void acca_first(Gfile *, Gfile[], int, int[], int[], int[], double[]); void acca_second(Gfile *, Gfile, int, double, double); diff --git a/imagery/i.landsat.acca/main.c b/imagery/i.landsat.acca/main.c index 7432b00014a..710eb20bce8 100644 --- a/imagery/i.landsat.acca/main.c +++ b/imagery/i.landsat.acca/main.c @@ -191,7 +191,7 @@ int main(int argc, char *argv[]) th_4 = atof(b56c->answer); th_7 = atof(b45r->answer); acca_algorithm(&out, band, pass2->answer, shadow->answer, - csig->answer); + csig->answer, hist_n); if (filter->answer) filter_holes(&out); diff --git a/lib/imagery/iscatt_core.c b/lib/imagery/iscatt_core.c index 0a713404a63..1be92b9ba6d 100644 --- a/lib/imagery/iscatt_core.c +++ b/lib/imagery/iscatt_core.c @@ -700,19 +700,23 @@ int I_compute_scatts(struct Cell_head *region, struct scCats *scatt_conds, const char *mapset; char header[1024]; - int fd_cats_rasts[scatt_conds->n_a_cats]; - FILE *f_cats_rasts_conds[scatt_conds->n_a_cats]; - - struct rast_row bands_rows[n_bands]; + int *fd_cats_rasts; + FILE **f_cats_rasts_conds; + struct rast_row *bands_rows; + int *fd_bands; + int *bands_ids; + int *b_needed_bands; RASTER_MAP_TYPE data_type; - int nrows, i_band, n_a_bands, band_id; int i_row, head_nchars, i_cat, id_cat; - int fd_bands[n_bands]; - int bands_ids[n_bands]; - int b_needed_bands[n_bands]; + fd_cats_rasts = calloc(scatt_conds->n_a_cats, sizeof(*fd_cats_rasts)); + f_cats_rasts_conds = calloc(scatt_conds->n_a_cats, sizeof(*f_cats_rasts_conds)); + bands_rows = calloc(n_bands, sizeof(*bands_rows)); + fd_bands = calloc(n_bands, sizeof(*fd_bands)); + bands_ids = calloc(n_bands, sizeof(*bands_ids)); + b_needed_bands = calloc(n_bands, sizeof(*b_needed_bands)); Rast_set_window(region); diff --git a/raster/r.mapcalc/map.c b/raster/r.mapcalc/map.c index eedf19c6c5a..fe9d574916c 100644 --- a/raster/r.mapcalc/map.c +++ b/raster/r.mapcalc/map.c @@ -742,7 +742,8 @@ void create_history(const char *dst, expression * e) Rast_short_history(dst, "raster", &hist); for (i = 0; ; i++) { - char buf[RECORD_LEN]; + char *buf; + buf = (char*)G_calloc(RECORD_LEN, sizeof(char)); int n; if (!len) @@ -768,7 +769,8 @@ void create_history(const char *dst, expression * e) } if (seeded) { - char buf[RECORD_LEN]; + char* buf; + buf = (char*)G_calloc(RECORD_LEN, sizeof(char)); sprintf(buf, "random seed = %ld", seed_value); Rast_append_history(&hist, buf); } From ceb1d12753ab2b6c31bf068868c1ce7623c714b6 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 16:34:00 +0100 Subject: [PATCH 24/37] MSVC: Fix pointer arithmetic --- lib/raster3d/mask.c | 6 ++-- raster/r.in.lidar/main.c | 2 +- raster/r.in.lidar/point_binning.c | 48 +++++++++++++++---------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/raster3d/mask.c b/lib/raster3d/mask.c index c704656c429..2e6df3e4c21 100644 --- a/lib/raster3d/mask.c +++ b/lib/raster3d/mask.c @@ -306,12 +306,12 @@ void Rast3d_mask_tile(RASTER3D_Map * map, int tileIndex, void *tile, int type) for (dy = y; dy < rows; dy++) { for (dx = x; dx < cols; dx++) { RASTER3D_MASKNUM(map, dx, dy, dz, tile, type); - tile += length; + tile = (int*)tile + length; } - tile += xLength; + tile = (int*) + xLength; } - tile += yLength; + tile = (int*) + yLength; } } diff --git a/raster/r.in.lidar/main.c b/raster/r.in.lidar/main.c index 583abb6c9bf..d3797e2cc4a 100644 --- a/raster/r.in.lidar/main.c +++ b/raster/r.in.lidar/main.c @@ -629,7 +629,7 @@ int main(int argc, char *argv[]) if (base_array) { G_debug(2, "filling base raster array"); for (row = 0; row < rows; row++) { - Rast_get_row(base_raster, base_array + ((size_t) row * cols * Rast_cell_size(base_raster_data_type)), row, base_raster_data_type); + Rast_get_row(base_raster, (double*)base_array + ((size_t) row * cols * Rast_cell_size(base_raster_data_type)), row, base_raster_data_type); } } diff --git a/raster/r.in.lidar/point_binning.c b/raster/r.in.lidar/point_binning.c index be111bc97e0..1151e2b12bb 100644 --- a/raster/r.in.lidar/point_binning.c +++ b/raster/r.in.lidar/point_binning.c @@ -383,9 +383,9 @@ void write_variance(void *raster_row, void *n_array, void *sum_array, for (col = 0; col < cols; col++) { offset = ((size_t) row * cols + col) * Rast_cell_size(rtype); n_offset = ((size_t) row * cols + col) * Rast_cell_size(CELL_TYPE); - n = Rast_get_c_value(n_array + n_offset, CELL_TYPE); - sum = Rast_get_d_value(sum_array + offset, rtype); - sumsq = Rast_get_d_value(sumsq_array + offset, rtype); + n = Rast_get_c_value((CELL*) n_array + n_offset, CELL_TYPE); + sum = Rast_get_d_value((DCELL*) sum_array + offset, rtype); + sumsq = Rast_get_d_value((DCELL*)sumsq_array + offset, rtype); if (n == 0) Rast_set_null_value(ptr, 1, rtype); @@ -432,11 +432,11 @@ void write_median(struct BinIndex *bin_index, void *raster_row, for (col = 0; col < cols; col++) { n_offset = ((size_t) row * cols + col) * Rast_cell_size(CELL_TYPE); - if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */ + if (Rast_is_null_value((CELL*)index_array + n_offset, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { /* one or more points in cell */ - head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -488,10 +488,10 @@ void write_percentile(struct BinIndex *bin_index, void *raster_row, for (col = 0; col < cols; col++) { n_offset = ((size_t) row * cols + col) * Rast_cell_size(CELL_TYPE); - if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */ + if (Rast_is_null_value((CELL*)index_array + n_offset, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -543,10 +543,10 @@ void write_skewness(struct BinIndex *bin_index, void *raster_row, for (col = 0; col < cols; col++) { n_offset = ((size_t) row * cols + col) * Rast_cell_size(CELL_TYPE); - if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */ + if (Rast_is_null_value((CELL*)index_array + n_offset, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; /* count */ @@ -599,10 +599,10 @@ void write_trimmean(struct BinIndex *bin_index, void *raster_row, for (col = 0; col < cols; col++) { n_offset = ((size_t) row * cols + col) * Rast_cell_size(CELL_TYPE); - if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */ + if (Rast_is_null_value((CELL*)index_array + n_offset, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -662,26 +662,26 @@ void write_values(struct PointBinning *point_binning, switch (point_binning->method) { case METHOD_N: /* n is a straight copy */ Rast_raster_cpy(raster_row, - point_binning->n_array + + (CELL*)point_binning->n_array + ((size_t) row * cols * Rast_cell_size(CELL_TYPE)), cols, CELL_TYPE); break; case METHOD_MIN: Rast_raster_cpy(raster_row, - point_binning->min_array + + (CELL*)point_binning->min_array + ((size_t) row * cols * Rast_cell_size(rtype)), cols, rtype); break; case METHOD_MAX: Rast_raster_cpy(raster_row, - point_binning->max_array + + (CELL*)point_binning->max_array + ((size_t) row * cols * Rast_cell_size(rtype)), cols, rtype); break; case METHOD_SUM: Rast_raster_cpy(raster_row, - point_binning->sum_array + + (CELL*)point_binning->sum_array + ((size_t) row * cols * Rast_cell_size(rtype)), cols, rtype); break; @@ -690,9 +690,9 @@ void write_values(struct PointBinning *point_binning, for (col = 0; col < cols; col++) { size_t offset = ((size_t) row * cols + col) * Rast_cell_size(rtype); double min = - Rast_get_d_value(point_binning->min_array + offset, rtype); + Rast_get_d_value((DCELL*)point_binning->min_array + offset, rtype); double max = - Rast_get_d_value(point_binning->max_array + offset, rtype); + Rast_get_d_value((DCELL*)point_binning->max_array + offset, rtype); Rast_set_d_value(ptr, max - min, rtype); ptr = G_incr_void_ptr(ptr, Rast_cell_size(rtype)); } @@ -703,10 +703,10 @@ void write_values(struct PointBinning *point_binning, for (col = 0; col < cols; col++) { size_t offset = ((size_t) row * cols + col) * Rast_cell_size(rtype); size_t n_offset = ((size_t) row * cols + col) * Rast_cell_size(CELL_TYPE); - int n = Rast_get_c_value(point_binning->n_array + n_offset, + int n = Rast_get_c_value((CELL*)point_binning->n_array + n_offset, CELL_TYPE); double sum = - Rast_get_d_value(point_binning->sum_array + offset, rtype); + Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype); if (n == 0) Rast_set_null_value(ptr, 1, rtype); @@ -750,21 +750,21 @@ void write_values(struct PointBinning *point_binning, for (col = 0; col < cols; col++) { size_t offset = ((size_t) row * cols + col) * Rast_cell_size(rtype); size_t n_offset = ((size_t) row * cols + col) * Rast_cell_size(CELL_TYPE); - int n = Rast_get_c_value(point_binning->n_array + n_offset, + int n = Rast_get_c_value((CELL*)point_binning->n_array + n_offset, CELL_TYPE); if (n == 0) continue; double sum_x = - Rast_get_d_value(point_binning->x_array + offset, rtype); + Rast_get_d_value((DCELL*)point_binning->x_array + offset, rtype); double sum_y = - Rast_get_d_value(point_binning->y_array + offset, rtype); + Rast_get_d_value((DCELL*)point_binning->y_array + offset, rtype); /* TODO: we do this also in mean writing */ double sum_z = - Rast_get_d_value(point_binning->sum_array + offset, rtype); + Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype); - /* We are not writing any categories. They are not needed + /* We are not writing any categories. They are not neededsb * and potentially it is too much trouble to do it and it is * unclear what to write. Not writing them is also a little * bit faster. */ From f76f205f4ab8d1fcdf260fea0b29b1889e4deeee Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sat, 15 Feb 2020 18:34:00 +0100 Subject: [PATCH 25/37] MSVC: fix nan/inf issues on msvc and gcc --- general/g.region/printwindow.c | 5 ++++- lib/btree2/kdtree.c | 2 +- lib/vector/Vlib/box.c | 12 +++++++++--- raster/r.horizon/main.c | 2 +- raster/r.in.bin/main.c | 3 ++- raster/r.in.lidar/info.c | 4 +++- raster/r.li/r.li.padrange/padrange.c | 12 ++++++------ raster/r.out.gdal/main.c | 6 ++++-- raster/r.series.accumulate/main.c | 4 ++-- raster/r.series/main.c | 5 +++-- raster/r.univar/r.univar_main.c | 7 ++++--- raster/r.univar/r3.univar_main.c | 8 ++++---- raster/r.univar/stats.c | 28 ++++++++++++++++------------ raster3d/r3.in.lidar/info.c | 4 +++- vector/v.cluster/main.c | 4 ++-- vector/v.distance/distance.c | 4 +++- vector/v.voronoi/skeleton.c | 2 +- 17 files changed, 68 insertions(+), 44 deletions(-) diff --git a/general/g.region/printwindow.c b/general/g.region/printwindow.c index 4d167e36502..2a92fabee81 100644 --- a/general/g.region/printwindow.c +++ b/general/g.region/printwindow.c @@ -466,7 +466,10 @@ void print_window(struct Cell_head *window, int print_flag, int flat_flag) double convergence; if (G_projection() == PROJECTION_XY) - convergence = 0./0.; + // GCC 5.4.0 says 0./0. is -nan + // Clang 3.8.0 says 0./0. is nan + // I stick to -nan in msvc too. But this has to rechecked. + sscanf("-nan", "%lf", &convergence); else if (G_projection() == PROJECTION_LL) convergence = 0.0; else { diff --git a/lib/btree2/kdtree.c b/lib/btree2/kdtree.c index 509af0524ff..8d4c3c95021 100644 --- a/lib/btree2/kdtree.c +++ b/lib/btree2/kdtree.c @@ -524,7 +524,7 @@ int kdtree_knn(struct kdtree *t, double *c, int *uid, double *d, int k, int *ski if (skip) sn.uid = *skip; - maxdist = 1.0 / 0.0; + sscanf("inf", "%lf", &maxdist); found = 0; /* go down */ diff --git a/lib/vector/Vlib/box.c b/lib/vector/Vlib/box.c index f67184a77c6..48e73b87e11 100644 --- a/lib/vector/Vlib/box.c +++ b/lib/vector/Vlib/box.c @@ -252,7 +252,9 @@ int Vect_get_line_box(const struct Map_info *Map, int line, struct bound_box *Bo Line = Plus->Line[line]; if (Line == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; + double nan_val; + sscanf("-nan", "%lf", &nan_val); + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = nan_val; return 0; } @@ -317,7 +319,9 @@ int Vect_get_area_box(const struct Map_info *Map, int area, struct bound_box *Bo Area = Plus->Area[area]; if (Area == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; + double nan_val; + sscanf("-nan", "%lf", &nan_val); + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = nan_val; return 0; } @@ -363,7 +367,9 @@ int Vect_get_isle_box(const struct Map_info *Map, int isle, struct bound_box *Bo Isle = Plus->Isle[isle]; if (Isle == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; + double nan_val; + sscanf("-nan", "%lf", &nan_val); + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = nan_val; return 0; } diff --git a/raster/r.horizon/main.c b/raster/r.horizon/main.c index c9d29134e49..f49752c07e1 100644 --- a/raster/r.horizon/main.c +++ b/raster/r.horizon/main.c @@ -773,7 +773,7 @@ double horizon_height(void) { double height; - tanh0 = -1.0 / 0.0; /* -inf */ + sscanf("-inf", "%lf", &tanh0); /* -inf */ length = 0; height = searching(); diff --git a/raster/r.in.bin/main.c b/raster/r.in.bin/main.c index 6d7368075e1..96e3ceb392a 100644 --- a/raster/r.in.bin/main.c +++ b/raster/r.in.bin/main.c @@ -228,7 +228,8 @@ int main(int argc, char *argv[]) const char *outpre; char output[GNAME_MAX]; const char *title; - double null_val = 0.0/0.0; + double null_val; + sscanf("-nan", "%lf", &null_val); int is_fp; int is_signed; int bytes, hbytes; diff --git a/raster/r.in.lidar/info.c b/raster/r.in.lidar/info.c index cb9ee5bdeae..424fd714245 100644 --- a/raster/r.in.lidar/info.c +++ b/raster/r.in.lidar/info.c @@ -103,7 +103,9 @@ int scan_bounds(LASReaderH LAS_reader, int shell_style, int extents, int update, first = TRUE; /* init to nan in case no points are found */ - min_x = max_x = min_y = max_y = min_z = max_z = 0.0 / 0.0; + double nan_val; + sscanf("-nan", "%lf", &nan_val); + min_x = max_x = min_y = max_y = min_z = max_z = nan_val; G_verbose_message(_("Scanning data ...")); diff --git a/raster/r.li/r.li.padrange/padrange.c b/raster/r.li/r.li.padrange/padrange.c index 9c38c3eaa17..9c5c16955e2 100644 --- a/raster/r.li/r.li.padrange/padrange.c +++ b/raster/r.li/r.li.padrange/padrange.c @@ -315,8 +315,8 @@ int calculate(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = 1.0 / 0.0; /* inf */ - max = -1.0 / 0.0; /* -inf */ + sscanf("inf", "%lf", &min); /* inf */ + sscanf("-inf", "%lf", &max); /* -inf */ for (old_pid = 1; old_pid <= pid; old_pid++) { if (pst[old_pid].count > 0) { area_p = cell_size_m * pst[old_pid].count / 10000; @@ -551,8 +551,8 @@ int calculateD(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = 1.0 / 0.0; /* inf */ - max = -1.0 / 0.0; /* -inf */ + sscanf("inf", "%lf", &min); /* inf */ + sscanf("-inf", "%lf", &max); /* -inf */ for (old_pid = 1; old_pid <= pid; old_pid++) { if (pst[old_pid].count > 0) { area_p = cell_size_m * pst[old_pid].count / 10000; @@ -787,8 +787,8 @@ int calculateF(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = 1.0 / 0.0; /* inf */ - max = -1.0 / 0.0; /* -inf */ + sscanf("inf", "%lf", &min); /* inf */ + sscanf("-inf", "%lf", &max); /* -inf */ for (old_pid = 1; old_pid <= pid; old_pid++) { if (pst[old_pid].count > 0) { area_p = cell_size_m * pst[old_pid].count / 10000; diff --git a/raster/r.out.gdal/main.c b/raster/r.out.gdal/main.c index 5172e144a6b..a35c62157a5 100644 --- a/raster/r.out.gdal/main.c +++ b/raster/r.out.gdal/main.c @@ -895,6 +895,8 @@ int nodataval_check(double nodataval, GDALDataType datatype) double set_default_nodata_value(GDALDataType datatype, double min, double max) { + double nan_val; + sscanf("-nan", "%lf", &nan_val); switch (datatype) { case GDT_Byte: if (max < TYPE_BYTE_MAX) @@ -940,11 +942,11 @@ double set_default_nodata_value(GDALDataType datatype, double min, double max) case GDT_Float32: case GDT_CFloat32: - return 0.0 / 0.0; + return nan_val; case GDT_Float64: case GDT_CFloat64: - return 0.0 / 0.0; + return nan_val; default: return 0; diff --git a/raster/r.series.accumulate/main.c b/raster/r.series.accumulate/main.c index e73fa276533..84d212e517d 100644 --- a/raster/r.series.accumulate/main.c +++ b/raster/r.series.accumulate/main.c @@ -169,8 +169,8 @@ int main(int argc, char *argv[]) if (G_parser(argc, argv)) exit(EXIT_FAILURE); - lo = -1.0 / 0.0; /* -inf */ - hi = 1.0 / 0.0; /* inf */ + sscanf("-inf", "%lf", &lo); + sscanf("inf", "%lf", &hi); method = METHOD_GDD; if (G_strncasecmp(parm.method->answer, "gdd", 3) == 0) diff --git a/raster/r.series/main.c b/raster/r.series/main.c index d91215912a1..20d5b2d7315 100644 --- a/raster/r.series/main.c +++ b/raster/r.series/main.c @@ -194,8 +194,9 @@ int main(int argc, char *argv[]) if (G_parser(argc, argv)) exit(EXIT_FAILURE); - lo = -1.0 / 0.0; /* -inf */ - hi = 1.0 / 0.0; /* inf */ + sscanf("-inf", "%lf", &lo); + sscanf("inf", "%lf", &hi); + if (parm.range->answer) { lo = atof(parm.range->answers[0]); hi = atof(parm.range->answers[1]); diff --git a/raster/r.univar/r.univar_main.c b/raster/r.univar/r.univar_main.c index 25112a917b3..5687685f1ec 100644 --- a/raster/r.univar/r.univar_main.c +++ b/raster/r.univar/r.univar_main.c @@ -132,9 +132,10 @@ int main(int argc, char *argv[]) /* table field separator */ zone_info.sep = G_option_to_separator(param.separator); - - zone_info.min = 0.0 / 0.0; /* set to nan as default */ - zone_info.max = 0.0 / 0.0; /* set to nan as default */ + double nan_val; + sscanf("-nan", "%lf", &nan_val); + zone_info.min = nan_val; /* set to nan as default */ + zone_info.max = nan_val; /* set to nan as default */ zone_info.n_zones = 0; fdz = -1; diff --git a/raster/r.univar/r3.univar_main.c b/raster/r.univar/r3.univar_main.c index 8889694d754..acfca2c77eb 100644 --- a/raster/r.univar/r3.univar_main.c +++ b/raster/r.univar/r3.univar_main.c @@ -132,10 +132,10 @@ int main(int argc, char *argv[]) /* table field separator */ zone_info.sep = G_option_to_separator(param.separator); - dmin = 0.0 / 0.0; /* set to nan as default */ - dmax = 0.0 / 0.0; /* set to nan as default */ - zone_info.min = 0.0 / 0.0; /* set to nan as default */ - zone_info.max = 0.0 / 0.0; /* set to nan as default */ + sscanf("-nan", "%lf", &dmin); /* set to nan as default */ + sscanf("-nan", "%lf", &dmax); /* set to nan as default */ + sscanf("-nan", "%lf", &zone_info.min); /* set to nan as default */ + sscanf("-nan", "%lf", &zone_info.max); /* set to nan as default */ zone_info.n_zones = 0; /* open 3D zoning raster with default region */ diff --git a/raster/r.univar/stats.c b/raster/r.univar/stats.c index d8cd3860fdd..2bfa26d2b61 100644 --- a/raster/r.univar/stats.c +++ b/raster/r.univar/stats.c @@ -21,7 +21,8 @@ univar_stat *create_univar_stat_struct(int map_type, int n_perc) univar_stat *stats; int i; int n_zones = zone_info.n_zones; - + double nan_val; + sscanf("-nan", "%lf", &nan_val); if (n_zones == 0) n_zones = 1; @@ -30,8 +31,8 @@ univar_stat *create_univar_stat_struct(int map_type, int n_perc) for (i = 0; i < n_zones; i++) { stats[i].sum = 0.0; stats[i].sumsq = 0.0; - stats[i].min = 0.0 / 0.0; /* set to nan as default */ - stats[i].max = 0.0 / 0.0; /* set to nan as default */ + stats[i].min = nan_val; /* set to nan as default */ + stats[i].max = nan_val; /* set to nan as default */ stats[i].n_perc = n_perc; if (n_perc > 0) stats[i].perc = (double *)G_malloc(n_perc * sizeof(double)); @@ -105,7 +106,8 @@ void free_univar_stat_struct(univar_stat * stats) int print_stats(univar_stat * stats) { int z, n_zones = zone_info.n_zones; - + double nan_val; + sscanf("-nan", "%lf", &nan_val); if (n_zones == 0) n_zones = 1; @@ -127,8 +129,9 @@ int print_stats(univar_stat * stats) stdev = sqrt(variance); var_coef = (stdev / mean) * 100.; /* perhaps stdev/fabs(mean) ? */ - if (stats[z].n == 0) - stats[z].sum = stats[z].sum_abs = 0.0 / 0.0; + if (stats[z].n == 0) { + stats[z].sum = stats[z].sum_abs = nan_val; + } sprintf(sum_str, "%.15g", stats[z].sum); G_trim_decimal(sum_str); @@ -182,9 +185,9 @@ int print_stats(univar_stat * stats) quartile_perc = (double *)G_calloc(stats[z].n_perc, sizeof(double)); if (stats[z].n == 0) { - quartile_25 = median = quartile_75 = 0.0 / 0.0; + quartile_25 = median = quartile_75 = nan_val; for (i = 0; i < stats[z].n_perc; i++) - quartile_perc[i] = 0.0 / 0.0; + quartile_perc[i] = nan_val; } else { for (i = 0; i < stats[z].n_perc; i++) { @@ -308,7 +311,8 @@ int print_stats_table(univar_stat * stats) { unsigned int i; int z, n_zones = zone_info.n_zones; - + double nan_val; + sscanf("-nan", "%lf", &nan_val); if (n_zones == 0) n_zones = 1; @@ -378,7 +382,7 @@ int print_stats_table(univar_stat * stats) var_coef = (stdev / mean) * 100.; /* perhaps stdev/fabs(mean) ? */ if (stats[z].n == 0) - stats[z].sum = stats[z].sum_abs = 0.0 / 0.0; + stats[z].sum = stats[z].sum_abs = nan_val; if (zone_info.n_zones) { int z_cat = z + zone_info.min; @@ -424,9 +428,9 @@ int print_stats_table(univar_stat * stats) if (stats[z].n == 0) { - quartile_25 = median = quartile_75 = 0.0 / 0.0; + quartile_25 = median = quartile_75 = nan_val; for (i = 0; i < stats[z].n_perc; i++) - quartile_perc[i] = 0.0 / 0.0; + quartile_perc[i] = nan_val; } else { for (i = 0; i < stats[z].n_perc; i++) { diff --git a/raster3d/r3.in.lidar/info.c b/raster3d/r3.in.lidar/info.c index 1698c7cb0cc..0df79e5aa9a 100644 --- a/raster3d/r3.in.lidar/info.c +++ b/raster3d/r3.in.lidar/info.c @@ -104,7 +104,9 @@ int scan_bounds(LASReaderH LAS_reader, int shell_style, int extents, int update, first = TRUE; /* init to nan in case no points are found */ - min_x = max_x = min_y = max_y = min_z = max_z = 0.0 / 0.0; + double nan_val; + sscanf("-nan", "%lf", &nan_val); + min_x = max_x = min_y = max_y = min_z = max_z = nan_val; G_verbose_message(_("Scanning data ...")); diff --git a/vector/v.cluster/main.c b/vector/v.cluster/main.c index 91f7135522c..86a3080f23f 100644 --- a/vector/v.cluster/main.c +++ b/vector/v.cluster/main.c @@ -264,7 +264,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = 1.0 / 0.0; + sscanf("inf", "%lf", &min); max = 0; kd = G_malloc(minpnts * sizeof(double)); ki = G_malloc(minpnts * sizeof(int)); @@ -469,7 +469,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = 1.0 / 0.0; + sscanf("inf", "%lf", &min); max = 0; kd = G_malloc(minpnts * sizeof(double)); ki = G_malloc(minpnts * sizeof(int)); diff --git a/vector/v.distance/distance.c b/vector/v.distance/distance.c index 73edfa8e5a2..1febe394aac 100644 --- a/vector/v.distance/distance.c +++ b/vector/v.distance/distance.c @@ -12,7 +12,9 @@ int get_line_box(const struct line_pnts *Points, int i; if (Points->n_points == 0) { - box->E = box->W = box->N = box->S = box->T = box->B = 0.0 / 0.0; + double nan_val; + sscanf("-nan", "%lf", &nan_val); + box->E = box->W = box->N = box->S = box->T = box->B = nan_val; return 0; } diff --git a/vector/v.voronoi/skeleton.c b/vector/v.voronoi/skeleton.c index cda2113c0e4..3d083d7ac8d 100644 --- a/vector/v.voronoi/skeleton.c +++ b/vector/v.voronoi/skeleton.c @@ -525,7 +525,7 @@ int tie_up(void) IPoints[i]); } - distmin = 1. / 0.; /* +inf */ + sscanf("inf", "%lf", &distmin); xmin = x; ymin = y; From 999f45d35671ffdb91005e95c6a25aab5ac50f3a Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:10:42 +0100 Subject: [PATCH 26/37] missing include unistd.h --- vector/v.in.pdal/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/vector/v.in.pdal/main.cpp b/vector/v.in.pdal/main.cpp index 88d381c59a0..ef56576a821 100644 --- a/vector/v.in.pdal/main.cpp +++ b/vector/v.in.pdal/main.cpp @@ -29,6 +29,7 @@ extern "C" #include #include #include +#include } extern "C" From 432160624738fc6797ca6f2e5fda91328da00271 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:11:26 +0100 Subject: [PATCH 27/37] define unistd only if unistd.h is not available --- lib/db/dbmi_base/dirent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/db/dbmi_base/dirent.c b/lib/db/dbmi_base/dirent.c index 54348b6defe..7686e7d8fe5 100644 --- a/lib/db/dbmi_base/dirent.c +++ b/lib/db/dbmi_base/dirent.c @@ -16,10 +16,12 @@ #include #include #include -/* NOTE: these should come from or from */ + +#if !defined(HAVE_UNISTD_H) #define R_OK 4 #define W_OK 2 #define X_OK 1 +#endif #include #ifdef USE_DIRECT From 0aec42d2e455a4b272d34bc57c7b45b241c6600a Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:11:44 +0100 Subject: [PATCH 28/37] fix msvc broken build (works on gcc) --- general/g.proj/main.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/general/g.proj/main.c b/general/g.proj/main.c index 08e0f93c4cb..26f0a995da4 100644 --- a/general/g.proj/main.c +++ b/general/g.proj/main.c @@ -103,12 +103,13 @@ int main(int argc, char *argv[]) dontprettify = G_define_flag(); dontprettify->key = 'f'; dontprettify->guisection = _("Print"); - dontprettify->description = - _("Print 'flat' output with no linebreaks (applies to " -#ifdef HAVE_OGR - "WKT and " -#endif - "PROJ.4 output)"); + /* Does anyone build gdal without ogr these days ?. Anyway.. */ + #ifdef HAVE_OGR + dontprettify->description = _("Print 'flat' output with no linebreaks (applies to WKT PROJ.4 output)"); + #else + dontprettify->description = _("Print 'flat' output with no linebreaks (applies to PROJ.4 output)"); + #endif + #ifdef HAVE_OGR printwkt = G_define_flag(); @@ -295,18 +296,17 @@ int main(int argc, char *argv[]) (printwkt->answer ? 1 : 0) + #endif (create->answer ? 1 : 0)); - if (formats > 1) - G_fatal_error(_("Only one of -%c, -%c, -%c, -%c" + if (formats > 1) + /* Does anyone build gdal without ogr these days ?. Anyway.. */ #ifdef HAVE_OGR - ", -%c" -#endif - " or -%c flags may be specified"), - printinfo->key, shellinfo->key, datuminfo->key, printproj4->key, -#ifdef HAVE_OGR - printwkt->key, -#endif - create->key); - + G_fatal_error(_("Only one of -%c, -%c, -%c, -%c, %c or -%c flags may be specified"), + printinfo->key, shellinfo->key, datuminfo->key, + printproj4->key, printwkt->key, create->key); + #else + G_fatal_error(_("Only one of -%c, -%c, -%c, -%c or -%c flags may be specified"), + printinfo->key, shellinfo->key, datuminfo->key, + printproj4->key, create->key); + #endif if (printinfo->answer || shellinfo->answer) print_projinfo(shellinfo->answer); else if (datuminfo->answer) From 17b6ea37857db5d1ff39be1dd2b7a3bd665c4f9e Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:12:32 +0100 Subject: [PATCH 29/37] msvc: __atribute__ is gcc only --- include/defs/glocale.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/defs/glocale.h b/include/defs/glocale.h index 0d9eee010ea..2951a53efdd 100644 --- a/include/defs/glocale.h +++ b/include/defs/glocale.h @@ -1,6 +1,12 @@ #ifndef GRASS_GLOCALEDEFS_H #define GRASS_GLOCALEDEFS_H +#if defined(_MSC_VER) +#ifndef __attribute__ +#define __attribute__(x) +#endif +#endif + extern void G_init_locale(void); extern char *G_gettext(const char *, const char *) __attribute__((format_arg (2))); extern char *G_ngettext(const char *, const char *, const char *, unsigned long int) __attribute__((format_arg (2), format_arg (3))); From bb380ca982c4d3fb0bab964a3f2257c75cd758b0 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:12:57 +0100 Subject: [PATCH 30/37] check for _WIN32 to support msvc and mingw --- lib/gis/parser_interface.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/gis/parser_interface.c b/lib/gis/parser_interface.c index bab6a794303..b2edaf48e5e 100644 --- a/lib/gis/parser_interface.c +++ b/lib/gis/parser_interface.c @@ -107,16 +107,17 @@ void G__usage_xml(void) char *type; char *s, *top; int i; - const char *encoding; + const char *encoding = ""; int new_prompt = 0; new_prompt = G__uses_new_gisprompt(); /* gettext converts strings to encoding returned by nl_langinfo(CODESET) */ +/* check if local_charset() comes from iconv. If so check for iconv library before using it */ #if defined(HAVE_LANGINFO_H) encoding = nl_langinfo(CODESET); -#elif defined(__MINGW32__) && defined(USE_NLS) +#elif defined(_WIN32) && defined(USE_NLS) encoding = locale_charset(); #endif From 93e3d0e6b967209df43557105e85114270ee1ef4 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:13:33 +0100 Subject: [PATCH 31/37] msvc: include winsock.h for struct timeval --- lib/raster3d/test/test_tools.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/raster3d/test/test_tools.c b/lib/raster3d/test/test_tools.c index e2bdef8a1d0..1b934656356 100644 --- a/lib/raster3d/test/test_tools.c +++ b/lib/raster3d/test/test_tools.c @@ -20,6 +20,9 @@ #include #include #include "test_raster3d_lib.h" +#ifdef _MSC_VER + #include +#endif /* *************************************************************** */ /* Compute the difference between two time steps ***************** */ From f6c52298101e103ca7bd081186834acecfa2a254 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:13:56 +0100 Subject: [PATCH 32/37] msvc: include sys/time.h, strings.h only if available --- lib/iostream/rtimer.cpp | 7 ++++++- lib/raster3d/test/test_raster3d_lib.h | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/iostream/rtimer.cpp b/lib/iostream/rtimer.cpp index e7041ee3d33..e59db17674e 100644 --- a/lib/iostream/rtimer.cpp +++ b/lib/iostream/rtimer.cpp @@ -33,11 +33,16 @@ * General Public License for more details. * * **************************************************************************/ - +#if !defined(_MSC_VER) #include +#endif + #include #include + +#if !defined(_MSC_VER) #include +#endif //#include #include diff --git a/lib/raster3d/test/test_raster3d_lib.h b/lib/raster3d/test/test_raster3d_lib.h index d71cd0edcfb..4c25e9526f9 100644 --- a/lib/raster3d/test/test_raster3d_lib.h +++ b/lib/raster3d/test/test_raster3d_lib.h @@ -21,8 +21,11 @@ #include #include #include +#ifdef HAVE_SYS_TIME_H #include - +#else +#include +#endif double compute_time_difference(struct timeval, struct timeval); int unit_test_coordinate_transform(void); int unit_test_put_get_value(void); From 3503533e62a262b35356a23a306d5719b621cc62 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:15:33 +0100 Subject: [PATCH 33/37] msvc: undef min max and use math.h for math constants --- include/gis.h | 9 ++++++++- raster/r.sim/simlib/waterglobs.h | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/gis.h b/include/gis.h index 4a74567de16..fea824cc434 100644 --- a/include/gis.h +++ b/include/gis.h @@ -111,13 +111,19 @@ static const char *GRASS_copyright __attribute__ ((unused)) #define UNIT_FILE "PROJ_UNITS" #define EPSG_FILE "PROJ_EPSG" -#ifdef __MINGW32__ +#ifdef _WIN32 #define CONFIG_DIR "GRASS7" #else #define CONFIG_DIR ".grass7" #endif /* define PI and friends */ +#if defined(_MSC_VER) +#define _USE_MATH_DEFINES 1 +#include +#undef min +#undef max +#else #undef M_PI #define M_PI 3.14159265358979323846 /* pi */ @@ -126,6 +132,7 @@ static const char *GRASS_copyright __attribute__ ((unused)) #undef M_PI_4 #define M_PI_4 0.78539816339744830962 /* pi/4 */ +#endif #undef M_R2D #define M_R2D 57.295779513082320877 /* 180/pi */ diff --git a/raster/r.sim/simlib/waterglobs.h b/raster/r.sim/simlib/waterglobs.h index aece1fa582e..87107c9691f 100644 --- a/raster/r.sim/simlib/waterglobs.h +++ b/raster/r.sim/simlib/waterglobs.h @@ -6,6 +6,10 @@ #define UNDEF -9999 #include +#ifdef _MSC_VER +#undef min +#undef max +#endif extern char *elevin; extern char *dxin; From 20ca623e4f8ac2d741e349a56dfc8563d5023e26 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:16:15 +0100 Subject: [PATCH 34/37] msvc: missing headers for windows build --- tools/timer/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/timer/main.c b/tools/timer/main.c index c8dc720439b..7f03cddde0f 100644 --- a/tools/timer/main.c +++ b/tools/timer/main.c @@ -12,8 +12,13 @@ * for details. * *****************************************************************************/ - +#ifdef _MSC_VER +#include +#include +#else #include +#endif + #include #include From 9714a9071aed297bed9e6f55bd41fdf81528d924 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:17:43 +0100 Subject: [PATCH 35/37] msvc: fix warning POINT2D_C already defined --- lib/rst/interp_float/point2d.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rst/interp_float/point2d.c b/lib/rst/interp_float/point2d.c index e6472caf303..e1e9fd44e9e 100644 --- a/lib/rst/interp_float/point2d.c +++ b/lib/rst/interp_float/point2d.c @@ -31,7 +31,9 @@ #include #include -#define POINT2D_C +#ifndef POINT2D_C +#define POINT2D_C 1 +#endif #include /* needed for AIX */ From 88da1048cabaea3e9d38ff5c601e6d896f54cd71 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:19:28 +0100 Subject: [PATCH 36/37] fix yacc.py for python3 --- lib/python/ctypes/ctypesgencore/parser/yacc.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/python/ctypes/ctypesgencore/parser/yacc.py b/lib/python/ctypes/ctypesgencore/parser/yacc.py index da0d48c6735..434f5e74f56 100644 --- a/lib/python/ctypes/ctypesgencore/parser/yacc.py +++ b/lib/python/ctypes/ctypesgencore/parser/yacc.py @@ -2276,7 +2276,8 @@ def yacc( raise YaccError("no rules of the form p_rulename are defined.") # Sort the symbols by line number - symbols.sort(lambda x, y: cmp(get_func_code(x).co_firstlineno, get_func_code(y).co_firstlineno)) + symbols.sort(key=lambda x: x.__code__.co_firstlineno) + # Add all of the symbols to the grammar for f in symbols: @@ -2288,7 +2289,7 @@ def yacc( # Make a signature of the docstrings for f in symbols: if f.__doc__: - Signature.update(f.__doc__) + Signature.update(f.__doc__.encode()) lr_init_vars() From 8690c5cf865ed3c9b7f234a0ead3b457d00bba28 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Tue, 18 Feb 2020 01:24:35 +0100 Subject: [PATCH 37/37] MSVC: fix g.list g.list uses regex.h which is not available on MSVC. This PR fixes g.list by using pcre library on windows and use regex.h on other platforms. This is Work in progress. Need to test the functionality of pcre v. regex --- include/defs/gis.h | 2 +- lib/gis/ls_filter.c | 84 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 77 insertions(+), 9 deletions(-) diff --git a/include/defs/gis.h b/include/defs/gis.h index 1110a1397ee..911fc9b2a64 100644 --- a/include/defs/gis.h +++ b/include/defs/gis.h @@ -501,7 +501,7 @@ void G_ls(const char *, FILE *); void G_ls_format(char **, int, int, FILE *); /* ls_filter.c */ -#ifdef HAVE_REGEX_H +#if defined(HAVE_REGEX_H) || defined(HAVE_PCRE_H) void *G_ls_regex_filter(const char *, int, int, int); void *G_ls_glob_filter(const char *, int, int); void G_free_ls_filter(void *); diff --git a/lib/gis/ls_filter.c b/lib/gis/ls_filter.c index 44d3d803d38..5d7d0921fd2 100644 --- a/lib/gis/ls_filter.c +++ b/lib/gis/ls_filter.c @@ -13,10 +13,13 @@ #include #include - #ifdef HAVE_REGEX_H - #include +#endif + +#ifdef HAVE_PCRE_H +#include +#endif struct buffer { @@ -144,14 +147,36 @@ static int wc2regex(struct buffer *buf, const char *pat) static int re_filter(const char *filename, void *closure) { +#ifdef HAVE_REGEX_H regex_t *regex = closure; + return filename[0] != '.' && regexec(regex, filename, 0, NULL, 0) == 0; +#endif +#ifdef HAVE_PCRE_H + const char* pcreErrorStr; + pcre_extra* pcreExtra; + int pcreExecRet; + pcre* pcre_regex = closure; + // Optimize the regex + pcreExtra = pcre_study(pcre_regex, 0, &pcreErrorStr); + pcreExecRet = pcre_exec(pcre_regex, + pcreExtra, + filename, + strlen(filename), // length of string + 0, // Start looking at this point + 0, // OPTIONS + NULL, + 0); // Length of subStrVec + + return filename[0] != '.' && pcreExecRet == 0; +#endif - return filename[0] != '.' && regexec(regex, filename, 0, NULL, 0) == 0; + } void *G_ls_regex_filter(const char *pat, int exclude, int extended, int ignorecase) { +#ifdef HAVE_REGEX_H regex_t *regex = G_malloc(sizeof(regex_t)); if (regcomp(regex, pat, REG_NOSUB | @@ -167,12 +192,41 @@ void *G_ls_regex_filter(const char *pat, int exclude, int extended, G_set_ls_filter(re_filter, regex); return regex; +#endif + +#ifdef HAVE_PCRE_H + pcre* pcre_regex; + const char* pcreErrorStr; + int pcreErrorOffset; + // First, the regex string must be compiled. + pcre_regex = pcre_compile(pat, 0, &pcreErrorStr, &pcreErrorOffset, NULL); + /* + if (regcomp(regex, pat, REG_NOSUB | + (extended ? REG_EXTENDED : 0) | + (ignorecase ? REG_ICASE : 0)) != 0) { + pcre_free(pcre_regex); + return NULL; + } + */ + if (exclude) + G_set_ls_exclude_filter(re_filter, pcre_regex); + else + G_set_ls_filter(re_filter, pcre_regex); + + return pcre_regex; +#endif + } void *G_ls_glob_filter(const char *pat, int exclude, int ignorecase) { struct buffer buf; +#ifdef HAVE_REGEX_H regex_t *regex; +#endif +#ifdef HAVE_PCRE_H + pcre* pcre_regex; +#endif init(&buf); @@ -180,22 +234,36 @@ void *G_ls_glob_filter(const char *pat, int exclude, int ignorecase) fini(&buf); return NULL; } - +#ifdef HAVE_REGEX_H regex = G_ls_regex_filter(buf.buf, exclude, 1, ignorecase); +#endif +#ifdef HAVE_PCRE_H + pcre_regex = G_ls_regex_filter(buf.buf, exclude, 1, ignorecase); +#endif fini(&buf); - return regex; +#ifdef HAVE_REGEX_H + return regex; +#endif +#ifdef HAVE_PCRE_H + return pcre_regex; +#endif + } void G_free_ls_filter(void *regex) { if (!regex) return; - +#ifdef HAVE_REGEX_H regfree(regex); +#endif +#ifdef HAVE_PCRE_H + pcre_free(regex); +#endif + G_free(regex); -} -#endif +}