From 43daba2bc4285eec990a50e5b4e837ba6ccd03ef Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sun, 11 Jun 2017 21:52:19 +0200 Subject: [PATCH 01/60] parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669989265 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669989193 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669989189 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669989180 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669988019 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669987997 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669987899 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669986420 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669986410 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669985337 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669984062 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669984050 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669984037 +0100 parent 464ffca1e1fbb98107593ee60c43a8449e567eed author Rashad Kanavath 1497210739 +0200 committer Markus Neteler 1669984013 +0100 inital work on grass cmake build wip: cmake fixes add find iconv script fix blas error wrong target added link with dl lib on linux disable some modules (wip) search whatever is fftw's inlcude dir driver lib depends on iconv fftw in required package build fftw modules add python libs test with py3 install sqlfiles to etc/sql install lock, clean_temp, echo to ./etc/ install libs link with dl lib cleanup cmake code fix python script & lib install dirs fixed gisbase for grass startup script install modules to bin add PNG as dependency to r.out.png install __init__.py wrong install dir for python api install with rpath to avoid LD_LIBRARY_PATH whitespace fixes MSVC: check for _WIN32 to use msvc and mingw32 MSVC: disable some programs temporarily update cmake scripts to manage thirdparty libs disable X11 on windows update generation of config.h fix list of cmake depends msvc compile fixes use INIFINITY rather than gcc only division by zero ignore visual studio, cmake files use INFINITY rather than divide by zero use _WIN32 for mingw32 and msvc add ssize_t for msvc msvc add _USE_MATH_DEFINES an d export dll keep check for long long int in cache include driver/init.c when building display drivers use _WIN32 to build msvc and mingw32 update cmake for lib/db link with libm only on unix msvc: skip chmod on windows msvc use INFINITY rather than diivide by zero add msvc specific headers: unistd.h, dirent.h grass moved to git... So follow that in cmake. fix check for HAVE_LONG_LONG include math.h only on msvc. To be discussed void* arithmetic (GCC extension) is not allowed in msvc disable d.mon, d.font on msvc. TBD missing O_ACCMODE on msvc Add unistd.h on windows Source copied from http://stackoverflow.com/a/826027 dbmi_base: add dirent.h and dirent.c for msvc use macro INFINITY rather than GCC divide by zero MSVC: fix missing strings.h use math defines on msvc update find package of fftw added required defines into parent scope update setting of HAVE_* defines. 1/n use cmake target check if possible add odbc target on windows update values in generated config.h reorganize cmake option defaults, cmake flags, macros cmake c and cxx flags include _CRT_SECURE_NO_WARNINGS to avoid a lot msdn warnings check_target macro is a helper to reduce number of lines in include/CMakeLists.txt simlib: min, max are already available Find which C standard library does not provide them And if there is one, see if grass support that compiler/platform combination To be discussed CMake: reorganize cmake functions, macros, find_scripts (Like a Pro) make_script_in_dir is renamed to build_script_in_subdir I still don't the naming of macro is clear. One without knowledge of CMake, AutoMake or any other build scripting experience must be able to deduct what is the macro/functions. Even if there will be a header comment with 'PURPOSE' field. fix define used in lib/rst/interp_float fix tools/timer build add gettimeofday windowss implemenation from postgresql CMake: reorganize cmake functions (2) MSVC: copy UINT64CONST(x) from postgresql WIP: disable pyc generation with g.parser on msvc fix ccmath complex struct for msvc take out GCC'sim and stick to C standard copy external/ccmath/ccmath.h to include/grass/ccmath_grass.h CMake: enable cmake export all symbols on for shared libs CMake: build lib/python on MSVC fix ctypesgen.cmake reorg cmake functions used by python add new cmake function to copy_python_files and compile MSVC: include sys/time.h if available or time.h CMake: remove debug trace CMake: minor cleanup CMake: make gui/images CMake: fix run_grass of locale_strings and ctypesgen CMake: link with postgres is optional gid_t, uid_t, pid_t exists on *nix use find_library_suffix to switch between debug and rest avoid touch .stamp files and depend on generated pyc file CMake: update definiition of HAVE_PROJ_H include winsock.h only on msvc CMake: remove annoying logs for fix TODO for g.version CMake: depend on pyc file not on a new .stamp file CMake: fix syntax error CMake: fix sqlite include dir variable CMake: detect version of proj4 before activating defines MSVC: avoid pulling min max on windows CMake: update list of enabled modules TODO r.watershed, fix cmake proj4 library varname Revert "simlib: min, max are already available" This reverts commit ab2b96127e66198f32b6799342b1fae6365f9fc3. CMake: update proj library variables (remove suffix 4) use macro INFINITY MSVC: fix gisinit initialized flag export initialized using dllexport when building. export macros has been generated by CMake's GenerateExportHeader. cmake calls this for all libraries in build_module function. There is a change in initialized variable decl on msvc and rest of compilers. This point has to be discussed with other devs MSVC: fix min, max macro stuff update TODO, list of modules not built by cmake CMake: update find scripts to find debug then release update list of options. WITH_PYTHON addded to build python bindings (default is OFF) CMake: zlib is check with cmake target demolocation is configured in lib/init/CMakeLists.txt CMake: generate grass.py and grass.sh scripts (build tree) CMake: fix startup script generation (install tree) fix generation of startup scripts fix g.list building 1/2 MSVC: missing regex, use PCRE (wip) lib/init: fix startup script on linux fix input configure_file activate building g.remove on msvc add cmake messages for lib/init/ include sys/time.h if not on msvc. As we don't include grass/config.h we cannot simply check against HAVE_SYS_TIME_H install proj data files geotiff_csv only required in windows check this with devs wip: add compile defs via interface library fix g.version, grass_gproj with proj6 create startup shell scripts in bin fix startup script MSVC: configure run_grass.bat, run_python.bat generate html docs fix copy_python_file (used in gui/wxpython, lib/python) build all gui/wxpython modules wrapper scripts to build html docs skip html-description for g.parser update msvc target properties fix install directory for running from binary tree install tools for buildtree and installtree fix build docs using cmake POST_BUILD update mkhtml.py for cmake copy header to binary directory using add_custom_command install extra files in lib/gis using post_build add copy_header as depdendency to grass_datetime first install tools directory find cairo debug and then release libs add POST_BUILD target for documentation only if WITH_DOCS build gui/wxpython, fix html description generation MSVC: uninitialized variable CMake: update to work with autoconf and cmake CMake: install et copy gui/images gui/icons CMake: fix grass version date CMake: fix building gui (python files, docs, html) fix dist include dir name build docs only if requested fix typo fix cmake syntax errors cmake linux fixes check for _WIN32 define to work with msvc fix newline at end of file WIP: update helper cmake scripts update copy_header target use gisbase as dist directory for build tree cmake: fix build for db/drivers ignore __pycache__ directory when scanning for .py files wip: use a gisbase as dist directory WIP: temporary fix for find_library output variable CMake: move wxpython cmake codes to gui/wxpython raise ScriptError wip wip build docs minor cleanup install html docs for driver db update building html docs (wip) add missing dependencies for v.lrs update building python modules (wip) use target property to check if running python script (docs) cleanup cmake helper functions (exe, libs, python, docs) copy strings.h and unistd.h on msvc python files (target) depend only grass.script if building docs fix build docs for windows and linux (wip) seperate list of g.gui.* modules try to make generic build docs (wip) build docs html for not win32 (wip) fix cmake syntax error update pgm extension for running html description remove temp files after docs are finished CMake: fix IN_LIST syntax ficx cmake syntax error fix again linux html description for python with a main script wip: include from config build is breaking msvc msvc: disable db drivers (wip) add test.raster3d.lib into NO_HTML_DESCR_TARGETS CMake: missing endif() x extension on running html descr copy r.in.wms directory to etc/ fix building py modules add grass dll directory to path windows grass.bat debug linux build failures cmake missing endif set main script file only for those selected modules cmake: fix python docs for linux and windows create scripts directory in gisbase cmake debug message add missing include add cmake find scripts for liblas, netcdf, postgresql update proj4 detection to support 4.x, 5.x , 6.x versions update cmake functions to build grass modules add proj4 version defines (support 5.x+) add options for v.in.dwg and liblas modules activate build of modules deactivated detecting of new 3rdd party libraries fix i.landsat.acca on msvc add dll export macro for iostream, dspf, calc fix r.terraflow on msvc use _WIN32 rather than __MINGW32__ for msvc use infinity macro to build on msvc missing include on msvc copy VERSIONUMBER and license to gisbase/etc support for multiple proj4 version update building lib/python (except ctypes) use INFINITY macro to work with msvc fix building gui/wxpython/xml use approach with cmake env command for cross platform build void* arithmetic is not allowed in msvc To be discussed copy __init__.py for python/grass/ fix wrong cmake varible used copy init py to etc/python/grass/ db/drviers: odbc, sqlite, dbf, ogr, postgresql check for PQCmdTuples in postgresql add defines to be posix conformat on msvc bring in testing using ctest (wip) improve proj4 detection Signed-off-by: Rashad Kanavath keep proj4 version string in cache (very useful later) find optional packages quietly use PRIMARY_DEPENDS option in build_module generate wxpython menu xml stuff after building all executables ogsf and nviz depends on grass_raster update gui/wxpython build add missing modules to build missing v.clip install html file is exists cmake cleanup reorder dependencies of gui/wxpython modules avoid breakage in autconf build missing file copy fix mkhtml doc building, exe, lib, python, gui fix find scripts on windows fix always out of date for custom targets fix missing optional dependds to grass gis library fix missing math.h include wrong path used under cmake binary directory keep autoconf build conflict with cmake .bat files must be in scripts/ fix installation of gui/images, gui/icons Revert "install html file is exists" This reverts commit 9e83f6f4a9ae4e164ceaf8b23cfb207081c14763. Apply suggestions from code review trivial changes (comment style) applied moved tools/ -> utils/ sync to main sync to main fix indentation remove trailing white space remove trailing white space revert C related INFINITY/NAN changes (taken care of in #2681) --- .gitignore | 2 + 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 | 57 ++ 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 +++ db/drivers/odbc/odbc.h | 2 +- demolocation/grassrc.cmake.in | 4 + display/CMakeLists.txt | 27 + doc/CMakeLists.txt | 0 general/CMakeLists.txt | 44 ++ general/g.region/printwindow.c | 2 +- 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 +++++++++++ include/grass/calc.h | 12 +- include/grass/defs/gis.h | 4 +- include/grass/iostream/mm.h | 11 +- include/grass/iostream/rtimer.h | 5 +- lib/CMakeLists.txt | 163 ++++++ lib/cairodriver/graph.c | 4 +- lib/cairodriver/text.c | 3 + lib/calc/calc.c | 4 +- lib/db/CMakeLists.txt | 28 + lib/db/dbmi_base/dbmscap.c | 10 +- lib/db/dbmi_base/dirent.c | 2 + lib/db/dbmi_base/login.c | 3 +- lib/db/dbmi_base/msvc/dirent.c | 113 ++++ lib/db/dbmi_base/msvc/dirent.h | 50 ++ lib/db/dbmi_client/start.c | 6 +- lib/db/sqlp/CMakeLists.txt | 17 + lib/dspf/viz.h | 8 +- lib/external/ccmath/ccmath.h | 15 +- lib/fonts/CMakeLists.txt | 1 + lib/gis/CMakeLists.txt | 68 +++ lib/gis/gisinit.c | 18 +- lib/gis/ls_filter.c | 103 +++- lib/gis/mapset_msc.c | 2 +- lib/gis/parser_interface.c | 5 +- lib/gis/paths.c | 10 +- lib/gis/popen.c | 2 +- lib/gis/sleep.c | 6 +- lib/gis/spawn.c | 18 +- lib/gis/user_config.c | 6 +- lib/gis/whoami.c | 7 +- lib/imagery/iscatt_core.c | 1 - lib/init/CMakeLists.txt | 171 ++++++ lib/init/clean_temp.c | 5 +- lib/init/env.sh | 10 + lib/init/grass.bat.in | 29 + lib/init/grass.sh.in | 6 + lib/init/license.txt.in | 11 + lib/init/lock.c | 4 +- lib/init/run.c | 2 +- lib/iostream/rtimer.cpp | 6 + lib/manage/sighold.c | 2 +- lib/pngdriver/graph_close.c | 4 +- lib/pngdriver/graph_set.c | 8 +- lib/pngdriver/pngdriver.h | 4 +- lib/proj/CMakeLists.txt | 14 + lib/raster/close.c | 4 +- lib/raster3d/close.c | 4 +- lib/raster3d/mask.c | 6 +- lib/raster3d/test/test_raster3d_lib.h | 5 +- lib/raster3d/test/test_tools.c | 3 + lib/rst/CMakeLists.txt | 21 + lib/rst/interp_float/point2d.c | 4 +- lib/temporal/CMakeLists.txt | 5 + lib/vector/CMakeLists.txt | 23 + lib/vector/Vlib/box.c | 12 +- 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 + msvc/strings.h | 5 + msvc/unistd.h | 58 ++ python/grass/CMakeLists.txt | 42 ++ python/grass/pygrass/CMakeLists.txt | 24 + .../CMakeLists.txt | 85 +++ raster/CMakeLists.txt | 514 ++++++++++++++++++ raster/r.colors.out/CMakeLists.txt | 16 + raster/r.colors/CMakeLists.txt | 12 + raster/r.horizon/main.c | 2 +- raster/r.in.bin/main.c | 2 +- raster/r.in.lidar/info.c | 5 +- raster/r.in.lidar/point_binning.c | 20 +- raster/r.li/CMakeLists.txt | 27 + raster/r.li/r.li.daemon/daemon.c | 2 +- raster/r.li/r.li.daemon/worker.c | 2 +- raster/r.li/r.li.padrange/padrange.c | 78 +-- raster/r.mapcalc/CMakeLists.txt | 22 + raster/r.out.gdal/main.c | 4 +- raster/r.series.accumulate/main.c | 3 +- raster/r.sim/CMakeLists.txt | 15 + raster/r.sim/simlib/waterglobs.h | 4 + raster/r.spread/CMakeLists.txt | 8 + raster/r.terraflow/common.cpp | 2 +- raster/r.terraflow/direction.h | 2 +- raster/r.terraflow/filldepr.cpp | 5 +- raster/r.terraflow/flow.cpp | 22 +- raster/r.terraflow/main.cpp | 4 +- raster/r.terraflow/stats.cpp | 4 +- raster/r.to.vect/lines_io.c | 2 +- raster/r.to.vect/util.c | 2 +- raster/r.univar/CMakeLists.txt | 15 + raster/r.univar/r.univar_main.c | 4 +- raster/r.univar/r3.univar_main.c | 4 +- raster/r.viewshed/statusstructure.cpp | 4 +- raster/r.watershed/CMakeLists.txt | 11 + raster3d/CMakeLists.txt | 97 ++++ raster3d/r3.flow/CMakeLists.txt | 14 + raster3d/r3.in.lidar/info.c | 2 +- scripts/CMakeLists.txt | 102 ++++ temporal/CMakeLists.txt | 56 ++ thirdparty/CMakeLists.txt | 180 ++++++ utils/CMakeLists.txt | 24 + utils/timer/main.c | 7 +- vector/CMakeLists.txt | 212 ++++++++ vector/v.cluster/main.c | 4 +- vector/v.distance/distance.c | 2 +- vector/v.lrs/CMakeLists.txt | 19 + 159 files changed, 5624 insertions(+), 174 deletions(-) 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/dbmi_base/msvc/dirent.c create mode 100644 lib/db/dbmi_base/msvc/dirent.h 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/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 create mode 100644 lib/proj/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 msvc/strings.h create mode 100644 msvc/unistd.h create mode 100644 python/grass/CMakeLists.txt create mode 100644 python/grass/pygrass/CMakeLists.txt create mode 100644 python/libgrass_interface_generator/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 utils/CMakeLists.txt create mode 100644 vector/CMakeLists.txt create mode 100644 vector/v.lrs/CMakeLists.txt diff --git a/.gitignore b/.gitignore index bc8ac301e89..78d4aafe1e3 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ OBJ.* locale/scriptstrings/* bin.*/* dist.*/* +.vs/* +CMakeSettings.json config.log config.status* error.log diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000000..41b17b44ca8 --- /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..af9c06aef2a --- /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..33fe91dcd30 --- /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..698f4916819 --- /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..6b7544b612e --- /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..4da368207e4 --- /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..ccf40b6552b --- /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..794726c96a7 --- /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..0c63cf8cbcc --- /dev/null +++ b/cmake/find_scripts/FindPROJ.cmake @@ -0,0 +1,57 @@ +############################################################################### +# 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 +# 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..3c048cd6c72 --- /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..0a7a767cd57 --- /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..0110a94b471 --- /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..3da2baa6ac1 --- /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..07c85897e61 --- /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..52a1fe21c6b --- /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/db/drivers/odbc/odbc.h b/db/drivers/odbc/odbc.h index 4cd376ee64e..1e14184c2b2 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/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..1905254fd26 --- /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/g.region/printwindow.c b/general/g.region/printwindow.c index 6c065cc297b..3a64b07a738 100644 --- a/general/g.region/printwindow.c +++ b/general/g.region/printwindow.c @@ -469,7 +469,7 @@ void print_window(struct Cell_head *window, int print_flag, int flat_flag) double convergence; if (G_projection() == PROJECTION_XY) - convergence = NAN; + convergence = INFINITY; else if (G_projection() == PROJECTION_LL) convergence = 0.0; else { diff --git a/general/manage/lister/CMakeLists.txt b/general/manage/lister/CMakeLists.txt new file mode 100644 index 00000000000..38f31daf1e9 --- /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..8e2050fd238 --- /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..b9d398a81d9 --- /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/include/grass/calc.h b/include/grass/calc.h index 9b22a847160..ab89ef3155c 100644 --- a/include/grass/calc.h +++ b/include/grass/calc.h @@ -31,12 +31,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/grass/defs/gis.h b/include/grass/defs/gis.h index 341a4f9a1a7..c14d6fa1708 100644 --- a/include/grass/defs/gis.h +++ b/include/grass/defs/gis.h @@ -79,6 +79,7 @@ * if GDAL is compiled with Visual Studio and GRASS is compiled with * MinGW. This patch must be applied before other GDAL/OGR headers are * included, as done by gprojects.h and vector.h */ +#ifndef _MSC_VER #if defined(__MINGW32__) && HAVE_GDAL #include #if GDAL_VERSION_NUM < 2030000 @@ -90,6 +91,7 @@ #endif #endif #endif +#endif /* _MSC_VER */ /* adj_cellhd.c */ void G_adjust_Cell_head(struct Cell_head *, int, int); @@ -498,7 +500,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/include/grass/iostream/mm.h b/include/grass/iostream/mm.h index 38b1feb9377..dfe0fd9f68c 100644 --- a/include/grass/iostream/mm.h +++ b/include/grass/iostream/mm.h @@ -79,9 +79,16 @@ enum MM_stream_usage { MM_STREAM_USAGE_MAXIMUM }; + +#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; @@ -155,6 +162,6 @@ class mm_register_init { 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; #endif // _MM_H diff --git a/include/grass/iostream/rtimer.h b/include/grass/iostream/rtimer.h index d4107c92543..9a47308f1ec 100644 --- a/include/grass/iostream/rtimer.h +++ b/include/grass/iostream/rtimer.h @@ -36,13 +36,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/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 00000000000..841cb55b549 --- /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/cairodriver/graph.c b/lib/cairodriver/graph.c index 529cc65d347..db2fa62e45f 100644 --- a/lib/cairodriver/graph.c +++ b/lib/cairodriver/graph.c @@ -29,7 +29,7 @@ #endif #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #include #include @@ -389,7 +389,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/cairodriver/text.c b/lib/cairodriver/text.c index 49c8e80cd93..12f22172071 100644 --- a/lib/cairodriver/text.c +++ b/lib/cairodriver/text.c @@ -11,6 +11,9 @@ \author Lars Ahlzen (original contributor) \author Glynn Clements */ +#if defined(_MSC_VER) +#include +#endif #include #include "cairodriver.h" diff --git a/lib/calc/calc.c b/lib/calc/calc.c index 4894d4e14da..031a97150e5 100644 --- a/lib/calc/calc.c +++ b/lib/calc/calc.c @@ -20,7 +20,7 @@ static void handle_fpe(int n UNUSED) void pre_exec(void) { -#ifndef __MINGW32__ +#ifndef _WIN32 #ifdef SIGFPE struct sigaction act; @@ -37,7 +37,7 @@ void pre_exec(void) void post_exec(void) { -#ifndef __MINGW32__ +#ifndef _WIN32 #ifdef SIGFPE struct sigaction act; 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/dbmi_base/dbmscap.c b/lib/db/dbmi_base/dbmscap.c index 25f1e0a1eec..51aa438c653 100644 --- a/lib/db/dbmi_base/dbmscap.c +++ b/lib/db/dbmi_base/dbmscap.c @@ -156,7 +156,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); @@ -179,7 +179,7 @@ dbDbmscap *db_read_dbmscap(void) if ((strcmp(ent->d_name, ".") == 0) || (strcmp(ent->d_name, "..") == 0)) continue; -#ifdef __MINGW32__ +#ifdef _WIN32 /* skip manifest files on Windows */ if (strstr(ent->d_name, ".manifest")) continue; @@ -188,9 +188,9 @@ dbDbmscap *db_read_dbmscap(void) /* Remove '.exe' from name (windows extension) */ name = G_str_replace(ent->d_name, ".exe", ""); -#ifdef __MINGW32__ - dirpath = G_malloc(strlen("\\driver\\db\\") + strlen(G_gisbase()) + - strlen(ent->d_name) + 1); +#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); G_convert_dirseps_to_host(dirpath); #else diff --git a/lib/db/dbmi_base/dirent.c b/lib/db/dbmi_base/dirent.c index 1823ba64726..708795bd4da 100644 --- a/lib/db/dbmi_base/dirent.c +++ b/lib/db/dbmi_base/dirent.c @@ -22,6 +22,7 @@ /* NOTE: these should come from or from */ #ifndef R_OK +#if !defined(HAVE_UNISTD_H) #define R_OK 4 #endif #ifndef W_OK @@ -30,6 +31,7 @@ #ifndef X_OK #define X_OK 1 #endif +#endif static int cmp_dirent(const void *, const void *); static int get_perm(char *); diff --git a/lib/db/dbmi_base/login.c b/lib/db/dbmi_base/login.c index d79fc84e6cf..523e7629eb0 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) { 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 diff --git a/lib/db/dbmi_client/start.c b/lib/db/dbmi_client/start.c index bc801685593..9017f31d4cc 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); @@ -136,7 +136,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/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/dspf/viz.h b/lib/dspf/viz.h index 92abb658908..8fc8b6cf819 100644 --- a/lib/dspf/viz.h +++ b/lib/dspf/viz.h @@ -90,5 +90,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[]; diff --git a/lib/external/ccmath/ccmath.h b/lib/external/ccmath/ccmath.h index 5774271c2d9..74aac8634f3 100644 --- a/lib/external/ccmath/ccmath.h +++ b/lib/external/ccmath/ccmath.h @@ -32,13 +32,22 @@ #define NULL ((void *)0 #endif -/* Complex Types */ - + /* Complex Types */ #ifndef CPX -struct complex { +#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 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..22ae1df8fb9 --- /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/gis/gisinit.c b/lib/gis/gisinit.c index d6d0f700270..1c900bc544f 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); /*! diff --git a/lib/gis/ls_filter.c b/lib/gis/ls_filter.c index 30d98490567..98ff19437cf 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 { char *buf; @@ -143,14 +146,41 @@ 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 */ + + /* 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 + + } 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, @@ -166,12 +196,58 @@ 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); + + /* 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); @@ -179,21 +255,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); +#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 +} diff --git a/lib/gis/mapset_msc.c b/lib/gis/mapset_msc.c index 957a03f4c3e..89604c15f23 100644 --- a/lib/gis/mapset_msc.c +++ b/lib/gis/mapset_msc.c @@ -263,7 +263,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/parser_interface.c b/lib/gis/parser_interface.c index 3e68e6a0522..6b072c5c254 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 diff --git a/lib/gis/paths.c b/lib/gis/paths.c index a2573762529..047b8d960e9 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 f3e4a2629cf..6b5c9fd07b6 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 8fed1f59ac5..9aad0a973ae 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 d6b5ec72896..2642f4020ab 100644 --- a/lib/gis/spawn.c +++ b/lib/gis/spawn.c @@ -23,7 +23,7 @@ #include #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #else #include @@ -68,7 +68,7 @@ struct signal { int action; int signum; int valid; -#ifndef __MINGW32__ +#ifndef _WIN32 struct sigaction old_act; sigset_t old_mask; #endif @@ -95,7 +95,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; @@ -935,11 +935,11 @@ int G_spawn(const char *command, ...) va_end(va); - status = - G_spawn_ex(command, -#ifndef __MINGW32__ - SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGINT, SF_SIGNAL, SST_PRE, - SSA_IGNORE, SIGQUIT, SF_SIGNAL, SST_PRE, SSA_BLOCK, SIGCHLD, + status = G_spawn_ex(command, +#ifndef _WIN32 + SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGINT, + SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGQUIT, + SF_SIGNAL, SST_PRE, SSA_BLOCK, SIGCHLD, #endif SF_ARGVEC, args, NULL); @@ -948,7 +948,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 3cebea00934..c1a840de3fd 100644 --- a/lib/gis/user_config.c +++ b/lib/gis/user_config.c @@ -30,9 +30,7 @@ #include #include #include -#include -#include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #endif #include @@ -46,7 +44,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 d978326b588..4daa35115cc 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()); diff --git a/lib/imagery/iscatt_core.c b/lib/imagery/iscatt_core.c index 7b0ee80169b..c41e0e47ef3 100644 --- a/lib/imagery/iscatt_core.c +++ b/lib/imagery/iscatt_core.c @@ -693,7 +693,6 @@ int I_compute_scatts(struct Cell_head *region, struct scCats *scatt_conds, struct rast_row bands_rows[n_bands]; RASTER_MAP_TYPE data_type; - int nrows, i_band, n_a_bands, band_id; int i_row, head_nchars, i_cat, id_cat; diff --git a/lib/init/CMakeLists.txt b/lib/init/CMakeLists.txt new file mode 100644 index 00000000000..70b38b62d4b --- /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/init/clean_temp.c b/lib/init/clean_temp.c index aa6301c531e..eeb340b1879 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) { @@ -139,7 +138,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 @@ -171,7 +170,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/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. diff --git a/lib/init/lock.c b/lib/init/lock.c index a1dc8ca93e5..7d435c0878a 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 4c048efdcec..6dae2af309e 100644 --- a/lib/init/run.c +++ b/lib/init/run.c @@ -22,7 +22,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/iostream/rtimer.cpp b/lib/iostream/rtimer.cpp index 83ed7e44879..c0d8a4fd9fc 100644 --- a/lib/iostream/rtimer.cpp +++ b/lib/iostream/rtimer.cpp @@ -33,10 +33,16 @@ * General Public License for more details. * * **************************************************************************/ +#if !defined(_MSC_VER) #include +#endif + #include #include + +#if !defined(_MSC_VER) #include +#endif #include diff --git a/lib/manage/sighold.c b/lib/manage/sighold.c index 7961f62f3dc..8fdbea604c4 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 3496bdf1fa1..e6dba3f6166 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 1fcf02bac8a..8376e421b12 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,9 +41,9 @@ static void map_file(void) if (fd < 0) return; -#ifdef __MINGW32__ - png.handle = CreateFileMapping((HANDLE)_get_osfhandle(fd), NULL, - PAGE_READWRITE, 0, size, NULL); +#ifdef _WIN32 + png.handle = CreateFileMapping((HANDLE) _get_osfhandle(fd), + NULL, PAGE_READWRITE, 0, size, NULL); if (!png.handle) return; ptr = MapViewOfFile(png.handle, FILE_MAP_WRITE, 0, 0, size); diff --git a/lib/pngdriver/pngdriver.h b/lib/pngdriver/pngdriver.h index 62b61aa700e..d86de42816b 100644 --- a/lib/pngdriver/pngdriver.h +++ b/lib/pngdriver/pngdriver.h @@ -16,7 +16,7 @@ #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #endif @@ -34,7 +34,7 @@ struct png_state { int true_color; int has_alpha; int mapped; -#ifdef __MINGW32__ +#ifdef _WIN32 HANDLE handle; #endif 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/raster/close.c b/lib/raster/close.c index 7a0370285fc..a4ba0db5080 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 2622eb48d40..8af9ed1ac1a 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 @@ -54,7 +54,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/lib/raster3d/mask.c b/lib/raster3d/mask.c index 69e7a498774..5d9e4014b47 100644 --- a/lib/raster3d/mask.c +++ b/lib/raster3d/mask.c @@ -304,12 +304,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 = (char *)tile + length; + tile = (int*)tile + length; } - tile = (char *)tile + xLength; + tile = (int*) + xLength; } - tile = (char *)tile + yLength; + tile = (int*) + yLength; } } diff --git a/lib/raster3d/test/test_raster3d_lib.h b/lib/raster3d/test/test_raster3d_lib.h index 4bcb53f5f59..5a1c57dd3ef 100644 --- a/lib/raster3d/test/test_raster3d_lib.h +++ b/lib/raster3d/test/test_raster3d_lib.h @@ -20,8 +20,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); diff --git a/lib/raster3d/test/test_tools.c b/lib/raster3d/test/test_tools.c index bb4ff23a7bd..a36f09dec63 100644 --- a/lib/raster3d/test/test_tools.c +++ b/lib/raster3d/test/test_tools.c @@ -19,6 +19,9 @@ #include #include #include "test_raster3d_lib.h" +#ifdef _MSC_VER + #include +#endif /* *************************************************************** */ /* Compute the difference between two time steps ***************** */ diff --git a/lib/rst/CMakeLists.txt b/lib/rst/CMakeLists.txt new file mode 100644 index 00000000000..4250dd94dcf --- /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/rst/interp_float/point2d.c b/lib/rst/interp_float/point2d.c index 3d1140a5889..1c03c78953b 100644 --- a/lib/rst/interp_float/point2d.c +++ b/lib/rst/interp_float/point2d.c @@ -30,7 +30,9 @@ #include #include -#define POINT2D_C +#ifndef POINT2D_C +#define POINT2D_C 1 +#endif #include /* needed for AIX */ 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/Vlib/box.c b/lib/vector/Vlib/box.c index 49d90ea2cc2..497e624498b 100644 --- a/lib/vector/Vlib/box.c +++ b/lib/vector/Vlib/box.c @@ -247,8 +247,8 @@ int Vect_get_line_box(const struct Map_info *Map, int line, } Line = Plus->Line[line]; - if (Line == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = NAN; + if (Line == NULL) { /* dead */ + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; return 0; } @@ -312,8 +312,8 @@ int Vect_get_area_box(const struct Map_info *Map, int area, Area = Plus->Area[area]; - if (Area == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = NAN; + if (Area == NULL) { /* dead */ + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; return 0; } @@ -359,8 +359,8 @@ int Vect_get_isle_box(const struct Map_info *Map, int isle, Isle = Plus->Isle[isle]; - if (Isle == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = NAN; + if (Isle == NULL) { /* dead */ + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; return 0; } 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..683df73557c --- /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..4d97bf911f7 --- /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/msvc/strings.h b/msvc/strings.h new file mode 100644 index 00000000000..dcf9ed87b7f --- /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 \ No newline at end of file diff --git a/msvc/unistd.h b/msvc/unistd.h new file mode 100644 index 00000000000..a09e1d92e09 --- /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 */ \ No newline at end of file diff --git a/python/grass/CMakeLists.txt b/python/grass/CMakeLists.txt new file mode 100644 index 00000000000..78a229ece5b --- /dev/null +++ b/python/grass/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/python/grass/pygrass/CMakeLists.txt b/python/grass/pygrass/CMakeLists.txt new file mode 100644 index 00000000000..2606bd39571 --- /dev/null +++ b/python/grass/pygrass/CMakeLists.txt @@ -0,0 +1,24 @@ +execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory etc/python/grass/pygrass/) + copy_python_file(${CMAKE_CURRENT_SOURCE_DIR}/errors.py etc/python/grass/pygrass) + copy_python_file(${CMAKE_CURRENT_SOURCE_DIR}/utils.py etc/python/grass/pygrass) + copy_python_file(${CMAKE_CURRENT_SOURCE_DIR}/orderdict.py etc/python/grass/pygrass) + + build_pymodule_in_subdir(messages etc/python/grass/pygrass) + + build_pymodule_in_subdir(modules etc/python/grass/pygrass) + + build_pymodule_in_subdir(modules/interface etc/python/grass/pygrass/modules) + + build_pymodule_in_subdir(modules/grid etc/python/grass/pygrass/modules) + + build_pymodule_in_subdir(raster etc/python/grass/pygrass) + + build_pymodule_in_subdir(vector etc/python/grass/pygrass) + + build_pymodule_in_subdir(gis etc/python/grass/pygrass) + + build_pymodule_in_subdir(shell etc/python/grass/pygrass) + + build_pymodule_in_subdir(tests etc/python/grass/pygrass) + + build_pymodule_in_subdir(rpc etc/python/grass/pygrass) diff --git a/python/libgrass_interface_generator/CMakeLists.txt b/python/libgrass_interface_generator/CMakeLists.txt new file mode 100644 index 00000000000..b243f459da4 --- /dev/null +++ b/python/libgrass_interface_generator/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/raster/CMakeLists.txt b/raster/CMakeLists.txt new file mode 100644 index 00000000000..b3216cbcda2 --- /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.horizon/main.c b/raster/r.horizon/main.c index c58ec836d97..3e1834bfd91 100644 --- a/raster/r.horizon/main.c +++ b/raster/r.horizon/main.c @@ -746,7 +746,7 @@ double horizon_height(void) { double height; - tanh0 = 0.; + tanh0 = -INFINITY; length = 0; height = searching(); diff --git a/raster/r.in.bin/main.c b/raster/r.in.bin/main.c index 08b657746e5..56bf05249b2 100644 --- a/raster/r.in.bin/main.c +++ b/raster/r.in.bin/main.c @@ -255,7 +255,7 @@ int main(int argc, char *argv[]) const char *outpre; char output[GNAME_MAX]; const char *title; - double null_val = NAN; + double null_val = INFINITY; 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 344a4d73c5d..24ea3223805 100644 --- a/raster/r.in.lidar/info.c +++ b/raster/r.in.lidar/info.c @@ -12,7 +12,8 @@ */ #include -#include +#include /* For INIFINITY */ + #include #include #include "local_proto.h" @@ -97,7 +98,7 @@ 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 = NAN; + min_x = max_x = min_y = max_y = min_z = max_z = INFINITY; G_verbose_message(_("Scanning data ...")); diff --git a/raster/r.in.lidar/point_binning.c b/raster/r.in.lidar/point_binning.c index 97e942d19b7..1148deaf5ae 100644 --- a/raster/r.in.lidar/point_binning.c +++ b/raster/r.in.lidar/point_binning.c @@ -434,7 +434,7 @@ void write_median(struct BinIndex *bin_index, void *raster_row, 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; @@ -493,7 +493,7 @@ void write_percentile(struct BinIndex *bin_index, void *raster_row, 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; @@ -548,7 +548,7 @@ void write_skewness(struct BinIndex *bin_index, void *raster_row, 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 */ @@ -605,7 +605,7 @@ void write_trimmean(struct BinIndex *bin_index, void *raster_row, 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; @@ -697,9 +697,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)); } @@ -714,7 +714,7 @@ void write_values(struct PointBinning *point_binning, int n = Rast_get_c_value(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); @@ -765,12 +765,12 @@ void write_values(struct PointBinning *point_binning, 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 * and potentially it is too much trouble to do it and it is diff --git a/raster/r.li/CMakeLists.txt b/raster/r.li/CMakeLists.txt new file mode 100644 index 00000000000..50dd4140aa7 --- /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.li/r.li.daemon/daemon.c b/raster/r.li/r.li.daemon/daemon.c index 2ddee5a5c43..d1f31d9b8a5 100644 --- a/raster/r.li/r.li.daemon/daemon.c +++ b/raster/r.li/r.li.daemon/daemon.c @@ -23,7 +23,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 83bfa62cc67..c272334595e 100644 --- a/raster/r.li/r.li.daemon/worker.c +++ b/raster/r.li/r.li.daemon/worker.c @@ -22,7 +22,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include diff --git a/raster/r.li/r.li.padrange/padrange.c b/raster/r.li/r.li.padrange/padrange.c index 39e4e8e79e9..cda1465853e 100644 --- a/raster/r.li/r.li.padrange/padrange.c +++ b/raster/r.li/r.li.padrange/padrange.c @@ -308,19 +308,19 @@ int calculate(int fd, struct area_entry *ad, double *result) cell_size_m = (((EW_DIST1 + EW_DIST2) / 2) / hd.cols) * (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); - /* get min and max patch size */ - min = INFINITY; - max = -INFINITY; - 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; - if (min > area_p) - min = area_p; - if (max < area_p) - max = area_p; - } - } - *result = max - min; + /* get min and max patch size */ + min = INFINITY; + max = -INFINITY; + 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; + if (min > area_p) + min = area_p; + if (max < area_p) + max = area_p; + } + } + *result = max - min; } else Rast_set_d_null_value(result, 1); @@ -542,19 +542,19 @@ int calculateD(int fd, struct area_entry *ad, double *result) cell_size_m = (((EW_DIST1 + EW_DIST2) / 2) / hd.cols) * (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); - /* get min and max patch size */ - min = INFINITY; - max = -INFINITY; - 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; - if (min > area_p) - min = area_p; - if (max < area_p) - max = area_p; - } - } - *result = max - min; + /* get min and max patch size */ + min = INFINITY; + max = -INFINITY; + 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; + if (min > area_p) + min = area_p; + if (max < area_p) + max = area_p; + } + } + *result = max - min; } else Rast_set_d_null_value(result, 1); @@ -776,19 +776,19 @@ int calculateF(int fd, struct area_entry *ad, double *result) cell_size_m = (((EW_DIST1 + EW_DIST2) / 2) / hd.cols) * (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); - /* get min and max patch size */ - min = INFINITY; - max = -INFINITY; - 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; - if (min > area_p) - min = area_p; - if (max < area_p) - max = area_p; - } - } - *result = max - min; + /* get min and max patch size */ + min = INFINITY; + max = -INFINITY; + 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; + if (min > area_p) + min = area_p; + if (max < area_p) + max = area_p; + } + } + *result = max - min; } else Rast_set_d_null_value(result, 1); 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.out.gdal/main.c b/raster/r.out.gdal/main.c index 5021c26e9e1..b4b5a8de127 100644 --- a/raster/r.out.gdal/main.c +++ b/raster/r.out.gdal/main.c @@ -1047,11 +1047,11 @@ double set_default_nodata_value(GDALDataType datatype, double min, double max) case GDT_Float32: case GDT_CFloat32: - return NAN; + return INFINITY; case GDT_Float64: case GDT_CFloat64: - return NAN; + return INFINITY; default: return 0; diff --git a/raster/r.series.accumulate/main.c b/raster/r.series.accumulate/main.c index 2c526c30257..f4a531f6632 100644 --- a/raster/r.series.accumulate/main.c +++ b/raster/r.series.accumulate/main.c @@ -171,8 +171,9 @@ int main(int argc, char *argv[]) if (G_parser(argc, argv)) exit(EXIT_FAILURE); - lo = -INFINITY; + lo = INFINITY; hi = INFINITY; + method = METHOD_GDD; if (G_strncasecmp(parm.method->answer, "gdd", 3) == 0) method = METHOD_GDD; 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.sim/simlib/waterglobs.h b/raster/r.sim/simlib/waterglobs.h index 7bf9fab74f2..30261ba3d42 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; 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.terraflow/common.cpp b/raster/r.terraflow/common.cpp index 854193476e0..aae8f681e41 100644 --- a/raster/r.terraflow/common.cpp +++ b/raster/r.terraflow/common.cpp @@ -22,7 +22,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 d98d463f7af..609b8d5c734 100644 --- a/raster/r.terraflow/direction.h +++ b/raster/r.terraflow/direction.h @@ -21,7 +21,7 @@ #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/filldepr.cpp b/raster/r.terraflow/filldepr.cpp index 82390d374b4..66b006d4116 100644 --- a/raster/r.terraflow/filldepr.cpp +++ b/raster/r.terraflow/filldepr.cpp @@ -22,7 +22,10 @@ #include "unionFind.h" #include "common.h" -#define FLOOD_DEBUG if (0) +#ifdef _MSC_VER +#pragma warning(default:4716) +#endif +#define FLOOD_DEBUG if(0) /************************************************************/ /* INPUT: stream containing the edgelist of watershed adjacency graph diff --git a/raster/r.terraflow/flow.cpp b/raster/r.terraflow/flow.cpp index e48847052e5..4d9bd0b5d41 100644 --- a/raster/r.terraflow/flow.cpp +++ b/raster/r.terraflow/flow.cpp @@ -48,8 +48,26 @@ void computeFlowAccumulation(AMI_STREAM *fillStream, Rtimer rt, rtTotal; AMI_STREAM *sweepstr; - rt_start(rtTotal); - assert(fillStream && outstr == NULL); + rt_start(rtTotal); + assert(fillStream && outstr == NULL); + if (stats) { + stats->comment("------------------------------"); + stats->comment("COMPUTING FLOW ACCUMULATION"); + } + + { /* timestamp stats file and print memory */ + time_t t = time(NULL); + char buf[BUFSIZ]; + if(t == (time_t)-1) { + perror("time"); + exit(1); + } +#ifdef _WIN32 + strcpy(buf, ctime(&t)); +#else + ctime_r(&t, buf); + buf[24] = '\0'; +#endif if (stats) { stats->comment("------------------------------"); stats->comment("COMPUTING FLOW ACCUMULATION"); diff --git a/raster/r.terraflow/main.cpp b/raster/r.terraflow/main.cpp index a831de23f6b..fa80134e6c6 100644 --- a/raster/r.terraflow/main.cpp +++ b/raster/r.terraflow/main.cpp @@ -297,8 +297,8 @@ void record_args(int argc, char **argv) exit(1); } -#ifdef __MINGW32__ - strcpy(buf, ctime(&t)); +#ifdef _WIN32 + strcpy(buf, ctime(&t)); #else ctime_r(&t, buf); buf[24] = '\0'; diff --git a/raster/r.terraflow/stats.cpp b/raster/r.terraflow/stats.cpp index 5325d72e466..ba804679bba 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 diff --git a/raster/r.to.vect/lines_io.c b/raster/r.to.vect/lines_io.c index 31dad0b903d..a8120da67b5 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 2a1498d88ec..93b629853b5 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 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.univar/r.univar_main.c b/raster/r.univar/r.univar_main.c index 8cb26b5d9ca..9ecf74f615f 100644 --- a/raster/r.univar/r.univar_main.c +++ b/raster/r.univar/r.univar_main.c @@ -170,8 +170,8 @@ int main(int argc, char *argv[]) /* table field separator */ zone_info.sep = G_option_to_separator(param.separator); - zone_info.min = 0; - zone_info.max = 0; + zone_info.min = NAN; + zone_info.max = NAN; zone_info.n_zones = 0; fdz = NULL; diff --git a/raster/r.univar/r3.univar_main.c b/raster/r.univar/r3.univar_main.c index 5ad71240bbd..41591bfec6b 100644 --- a/raster/r.univar/r3.univar_main.c +++ b/raster/r.univar/r3.univar_main.c @@ -134,8 +134,8 @@ int main(int argc, char *argv[]) dmin = NAN; dmax = NAN; - zone_info.min = 0; - zone_info.max = 0; + zone_info.min = NAN; + zone_info.max = NAN; zone_info.n_zones = 0; /* open 3D zoning raster with default region */ diff --git a/raster/r.viewshed/statusstructure.cpp b/raster/r.viewshed/statusstructure.cpp index 921b7bbecae..dd4e733cb81 100644 --- a/raster/r.viewshed/statusstructure.cpp +++ b/raster/r.viewshed/statusstructure.cpp @@ -38,8 +38,8 @@ #include #include #include - -extern "C" { +extern "C" +{ #include #include } diff --git a/raster/r.watershed/CMakeLists.txt b/raster/r.watershed/CMakeLists.txt new file mode 100644 index 00000000000..2a69c6d10b6 --- /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..266e0e9861c --- /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/raster3d/r3.in.lidar/info.c b/raster3d/r3.in.lidar/info.c index 00511aad217..ce3fba3ba08 100644 --- a/raster3d/r3.in.lidar/info.c +++ b/raster3d/r3.in.lidar/info.c @@ -101,7 +101,7 @@ 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 = NAN; + min_x = max_x = min_y = max_y = min_z = max_z = INFINITY; G_verbose_message(_("Scanning data ...")); diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt new file mode 100644 index 00000000000..37106770768 --- /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..e60264360f7 --- /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/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 00000000000..af18a2a4f1f --- /dev/null +++ b/utils/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/utils/timer/main.c b/utils/timer/main.c index 72a1f9c3813..38fe0926b0b 100644 --- a/utils/timer/main.c +++ b/utils/timer/main.c @@ -12,8 +12,13 @@ * for details. * *****************************************************************************/ - +#ifdef _MSC_VER +#include +#include +#else #include +#endif + #include #include diff --git a/vector/CMakeLists.txt b/vector/CMakeLists.txt new file mode 100644 index 00000000000..52f2c5715f3 --- /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.cluster/main.c b/vector/v.cluster/main.c index 470ecb2f942..c0d4325b798 100644 --- a/vector/v.cluster/main.c +++ b/vector/v.cluster/main.c @@ -256,7 +256,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = INFINITY; + min = NAN; max = 0; kd = G_malloc(minpnts * sizeof(double)); ki = G_malloc(minpnts * sizeof(int)); @@ -463,7 +463,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = INFINITY; + min = NAN; 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 18479f2f0bf..8537faaf691 100644 --- a/vector/v.distance/distance.c +++ b/vector/v.distance/distance.c @@ -11,7 +11,7 @@ int get_line_box(const struct line_pnts *Points, struct bound_box *box) int i; if (Points->n_points == 0) { - box->E = box->W = box->N = box->S = box->T = box->B = NAN; + box->E = box->W = box->N = box->S = box->T = box->B = INFINITY; return 0; } 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 f9c5cf0757f6f4f5a598cc69a5b38b966957cfe5 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 13:50:36 +0100 Subject: [PATCH 02/60] revert C related INFINITY/NAN changes (this is taken care of in #2681) --- general/g.region/printwindow.c | 2 +- lib/btree2/kdtree.c | 2 +- lib/raster3d/mask.c | 6 +++--- lib/vector/Vlib/box.c | 6 +++--- raster/r.horizon/main.c | 2 +- raster/r.in.bin/main.c | 2 +- raster/r.in.lidar/info.c | 3 +-- raster/r.in.lidar/point_binning.c | 20 ++++++++++---------- raster/r.li/r.li.padrange/padrange.c | 12 ++++++------ raster/r.out.gdal/main.c | 4 ++-- raster/r.series.accumulate/main.c | 4 ++-- raster/r.univar/r.univar_main.c | 4 ++-- raster/r.univar/r3.univar_main.c | 8 ++++---- raster/r.univar/stats.c | 16 ++++++++-------- raster3d/r3.in.lidar/info.c | 3 +-- vector/v.cluster/main.c | 4 ++-- vector/v.distance/distance.c | 2 +- vector/v.voronoi/skeleton.c | 2 +- 18 files changed, 50 insertions(+), 52 deletions(-) diff --git a/general/g.region/printwindow.c b/general/g.region/printwindow.c index 3a64b07a738..407855d9bb5 100644 --- a/general/g.region/printwindow.c +++ b/general/g.region/printwindow.c @@ -469,7 +469,7 @@ void print_window(struct Cell_head *window, int print_flag, int flat_flag) double convergence; if (G_projection() == PROJECTION_XY) - convergence = INFINITY; + convergence = 0. / 0.; else if (G_projection() == PROJECTION_LL) convergence = 0.0; else { diff --git a/lib/btree2/kdtree.c b/lib/btree2/kdtree.c index ec0d19e0abc..54a122033dc 100644 --- a/lib/btree2/kdtree.c +++ b/lib/btree2/kdtree.c @@ -531,7 +531,7 @@ int kdtree_knn(struct kdtree *t, double *c, int *uid, double *d, int k, if (skip) sn.uid = *skip; - maxdist = INFINITY; + maxdist = 1.0 / 0.0; found = 0; /* go down */ diff --git a/lib/raster3d/mask.c b/lib/raster3d/mask.c index 5d9e4014b47..33e5c3c44ee 100644 --- a/lib/raster3d/mask.c +++ b/lib/raster3d/mask.c @@ -304,12 +304,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 = (int*)tile + length; + tile += length; } - tile = (int*) + xLength; + tile += xLength; } - tile = (int*) + yLength; + tile += yLength; } } diff --git a/lib/vector/Vlib/box.c b/lib/vector/Vlib/box.c index 497e624498b..b68e00cdd8f 100644 --- a/lib/vector/Vlib/box.c +++ b/lib/vector/Vlib/box.c @@ -248,7 +248,7 @@ int Vect_get_line_box(const struct Map_info *Map, int line, Line = Plus->Line[line]; if (Line == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; return 0; } @@ -313,7 +313,7 @@ int Vect_get_area_box(const struct Map_info *Map, int area, Area = Plus->Area[area]; if (Area == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; return 0; } @@ -360,7 +360,7 @@ int Vect_get_isle_box(const struct Map_info *Map, int isle, Isle = Plus->Isle[isle]; if (Isle == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; return 0; } diff --git a/raster/r.horizon/main.c b/raster/r.horizon/main.c index 3e1834bfd91..806dc51068a 100644 --- a/raster/r.horizon/main.c +++ b/raster/r.horizon/main.c @@ -746,7 +746,7 @@ double horizon_height(void) { double height; - tanh0 = -INFINITY; + tanh0 = -1.0 / 0.0; /* -inf */ length = 0; height = searching(); diff --git a/raster/r.in.bin/main.c b/raster/r.in.bin/main.c index 56bf05249b2..e5d457b8dc3 100644 --- a/raster/r.in.bin/main.c +++ b/raster/r.in.bin/main.c @@ -255,7 +255,7 @@ int main(int argc, char *argv[]) const char *outpre; char output[GNAME_MAX]; const char *title; - double null_val = INFINITY; + double null_val = 0.0 / 0.0; 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 24ea3223805..e201774b716 100644 --- a/raster/r.in.lidar/info.c +++ b/raster/r.in.lidar/info.c @@ -12,7 +12,6 @@ */ #include -#include /* For INIFINITY */ #include #include @@ -98,7 +97,7 @@ 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 = INFINITY; + min_x = max_x = min_y = max_y = min_z = max_z = 0.0 / 0.0; G_verbose_message(_("Scanning data ...")); diff --git a/raster/r.in.lidar/point_binning.c b/raster/r.in.lidar/point_binning.c index 1148deaf5ae..97e942d19b7 100644 --- a/raster/r.in.lidar/point_binning.c +++ b/raster/r.in.lidar/point_binning.c @@ -434,7 +434,7 @@ void write_median(struct BinIndex *bin_index, void *raster_row, Rast_set_null_value(ptr, 1, rtype); else { /* one or more points in cell */ - head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -493,7 +493,7 @@ void write_percentile(struct BinIndex *bin_index, void *raster_row, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -548,7 +548,7 @@ void write_skewness(struct BinIndex *bin_index, void *raster_row, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; /* count */ @@ -605,7 +605,7 @@ void write_trimmean(struct BinIndex *bin_index, void *raster_row, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -697,9 +697,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((DCELL*)point_binning->min_array + offset, rtype); + Rast_get_d_value(point_binning->min_array + offset, rtype); double max = - Rast_get_d_value((DCELL*)point_binning->max_array + offset, rtype); + Rast_get_d_value(point_binning->max_array + offset, rtype); Rast_set_d_value(ptr, max - min, rtype); ptr = G_incr_void_ptr(ptr, Rast_cell_size(rtype)); } @@ -714,7 +714,7 @@ void write_values(struct PointBinning *point_binning, int n = Rast_get_c_value(point_binning->n_array + n_offset, CELL_TYPE); double sum = - Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype); + Rast_get_d_value(point_binning->sum_array + offset, rtype); if (n == 0) Rast_set_null_value(ptr, 1, rtype); @@ -765,12 +765,12 @@ void write_values(struct PointBinning *point_binning, continue; double sum_x = - Rast_get_d_value((DCELL*)point_binning->x_array + offset, rtype); + Rast_get_d_value(point_binning->x_array + offset, rtype); double sum_y = - Rast_get_d_value((DCELL*)point_binning->y_array + offset, rtype); + Rast_get_d_value(point_binning->y_array + offset, rtype); /* TODO: we do this also in mean writing */ double sum_z = - Rast_get_d_value((DCELL*)point_binning->sum_array + offset, rtype); + Rast_get_d_value(point_binning->sum_array + offset, rtype); /* We are not writing any categories. They are not needed * and potentially it is too much trouble to do it and it is diff --git a/raster/r.li/r.li.padrange/padrange.c b/raster/r.li/r.li.padrange/padrange.c index cda1465853e..9bd255ddd43 100644 --- a/raster/r.li/r.li.padrange/padrange.c +++ b/raster/r.li/r.li.padrange/padrange.c @@ -309,8 +309,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 = INFINITY; - max = -INFINITY; + min = 1.0 / 0.0; /* inf */ + max = -1.0 / 0.0; /* -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; @@ -543,8 +543,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 = INFINITY; - max = -INFINITY; + min = 1.0 / 0.0; /* inf */ + max = -1.0 / 0.0; /* -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; @@ -777,8 +777,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 = INFINITY; - max = -INFINITY; + min = 1.0 / 0.0; /* inf */ + max = -1.0 / 0.0; /* -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 b4b5a8de127..f647881b0cf 100644 --- a/raster/r.out.gdal/main.c +++ b/raster/r.out.gdal/main.c @@ -1047,11 +1047,11 @@ double set_default_nodata_value(GDALDataType datatype, double min, double max) case GDT_Float32: case GDT_CFloat32: - return INFINITY; + return 0.0 / 0.0; case GDT_Float64: case GDT_CFloat64: - return INFINITY; + return 0.0 / 0.0; default: return 0; diff --git a/raster/r.series.accumulate/main.c b/raster/r.series.accumulate/main.c index f4a531f6632..0cc6c38958a 100644 --- a/raster/r.series.accumulate/main.c +++ b/raster/r.series.accumulate/main.c @@ -171,8 +171,8 @@ int main(int argc, char *argv[]) if (G_parser(argc, argv)) exit(EXIT_FAILURE); - lo = INFINITY; - hi = INFINITY; + lo = -1.0 / 0.0; /* -inf */ + hi = 1.0 / 0.0; /* inf */ method = METHOD_GDD; if (G_strncasecmp(parm.method->answer, "gdd", 3) == 0) diff --git a/raster/r.univar/r.univar_main.c b/raster/r.univar/r.univar_main.c index 9ecf74f615f..3e351ad0a56 100644 --- a/raster/r.univar/r.univar_main.c +++ b/raster/r.univar/r.univar_main.c @@ -170,8 +170,8 @@ int main(int argc, char *argv[]) /* table field separator */ zone_info.sep = G_option_to_separator(param.separator); - zone_info.min = NAN; - zone_info.max = NAN; + zone_info.min = 0.0 / 0.0; /* set to nan as default */ + zone_info.max = 0.0 / 0.0; /* set to nan as default */ zone_info.n_zones = 0; fdz = NULL; diff --git a/raster/r.univar/r3.univar_main.c b/raster/r.univar/r3.univar_main.c index 41591bfec6b..b3efa170dd0 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 = NAN; - dmax = NAN; - zone_info.min = NAN; - zone_info.max = NAN; + 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 */ 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 01126ad022c..0451e370e2c 100644 --- a/raster/r.univar/stats.c +++ b/raster/r.univar/stats.c @@ -30,8 +30,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 = NAN; - stats[i].max = NAN; + 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].n_perc = n_perc; if (n_perc > 0) stats[i].perc = (double *)G_malloc(n_perc * sizeof(double)); @@ -131,7 +131,7 @@ int print_stats(univar_stat *stats) var_coef = (stdev / mean) * 100.; /* perhaps stdev/fabs(mean) ? */ if (stats[z].n == 0) - stats[z].sum = stats[z].sum_abs = NAN; + stats[z].sum = stats[z].sum_abs = 0.0 / 0.0; sprintf(sum_str, "%.15g", stats[z].sum); G_trim_decimal(sum_str); @@ -190,9 +190,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 = NAN; + quartile_25 = median = quartile_75 = 0.0 / 0.0; for (i = 0; i < stats[z].n_perc; i++) - quartile_perc[i] = NAN; + quartile_perc[i] = 0.0 / 0.0; } else { for (i = 0; i < stats[z].n_perc; i++) { @@ -402,7 +402,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 = NAN; + stats[z].sum = stats[z].sum_abs = 0.0 / 0.0; if (zone_info.n_zones) { int z_cat = z + zone_info.min; @@ -450,9 +450,9 @@ int print_stats_table(univar_stat *stats) quartile_perc = (double *)G_calloc(stats[z].n_perc, sizeof(double)); if (stats[z].n == 0) { - quartile_25 = median = quartile_75 = NAN; + quartile_25 = median = quartile_75 = 0.0 / 0.0; for (i = 0; i < stats[z].n_perc; i++) - quartile_perc[i] = NAN; + quartile_perc[i] = 0.0 / 0.0; } 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 ce3fba3ba08..49912030655 100644 --- a/raster3d/r3.in.lidar/info.c +++ b/raster3d/r3.in.lidar/info.c @@ -13,7 +13,6 @@ */ #include -#include #include @@ -101,7 +100,7 @@ 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 = INFINITY; + min_x = max_x = min_y = max_y = min_z = max_z = 0.0 / 0.0; G_verbose_message(_("Scanning data ...")); diff --git a/vector/v.cluster/main.c b/vector/v.cluster/main.c index c0d4325b798..a2b4e37b6e0 100644 --- a/vector/v.cluster/main.c +++ b/vector/v.cluster/main.c @@ -256,7 +256,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = NAN; + min = 1.0 / 0.0; max = 0; kd = G_malloc(minpnts * sizeof(double)); ki = G_malloc(minpnts * sizeof(int)); @@ -463,7 +463,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = NAN; + min = 1.0 / 0.0; 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 8537faaf691..3ceff4f9b05 100644 --- a/vector/v.distance/distance.c +++ b/vector/v.distance/distance.c @@ -11,7 +11,7 @@ int get_line_box(const struct line_pnts *Points, struct bound_box *box) int i; if (Points->n_points == 0) { - box->E = box->W = box->N = box->S = box->T = box->B = INFINITY; + box->E = box->W = box->N = box->S = box->T = box->B = 0.0 / 0.0; return 0; } diff --git a/vector/v.voronoi/skeleton.c b/vector/v.voronoi/skeleton.c index 96b19bdc709..ada3d356a8d 100644 --- a/vector/v.voronoi/skeleton.c +++ b/vector/v.voronoi/skeleton.c @@ -528,7 +528,7 @@ int tie_up(void) IPoints[i]); } - distmin = INFINITY; + distmin = 1. / 0.; /* +inf */ xmin = x; ymin = y; From f9b1ba704ee883123890fabd5164daf4cb399b6d Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 14:20:55 +0100 Subject: [PATCH 03/60] Sync to PR Cmake build2 #348 (replaces #348) --- cmake/ctypesgen.cmake | 2 +- cmake/modules/build_library_in_subdir.cmake | 2 +- cmake/modules/build_program.cmake | 2 +- cmake/modules/get_versions.cmake | 2 +- cmake/modules/repo_status.cmake | 2 +- cmake/modules/set_compiler_flags.cmake | 2 +- gui/icons/CMakeLists.txt | 7 +++++-- gui/images/CMakeLists.txt | 12 ++++++------ lib/CMakeLists.txt | 4 ++-- lib/init/license.txt.in | 2 +- python/libgrass_interface_generator/CMakeLists.txt | 1 + vector/CMakeLists.txt | 2 +- 12 files changed, 22 insertions(+), 18 deletions(-) diff --git a/cmake/ctypesgen.cmake b/cmake/ctypesgen.cmake index af9c06aef2a..945e74950b3 100644 --- a/cmake/ctypesgen.cmake +++ b/cmake/ctypesgen.cmake @@ -16,7 +16,7 @@ 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}.dll") elseif(APPLE) list(APPEND LIBRARIES "--library=${BIN_DIR}/lib/lib${LIB}.so") else() diff --git a/cmake/modules/build_library_in_subdir.cmake b/cmake/modules/build_library_in_subdir.cmake index 44415bea900..e49db0e8044 100644 --- a/cmake/modules/build_library_in_subdir.cmake +++ b/cmake/modules/build_library_in_subdir.cmake @@ -13,4 +13,4 @@ macro(build_library_in_subdir dir_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 +endmacro() diff --git a/cmake/modules/build_program.cmake b/cmake/modules/build_program.cmake index 31c381ab55f..cdd25a03549 100644 --- a/cmake/modules/build_program.cmake +++ b/cmake/modules/build_program.cmake @@ -5,4 +5,4 @@ # Read the file COPYING that comes with GRASS for details. macro(build_program) build_module(${ARGN} EXE) -endmacro() \ No newline at end of file +endmacro() diff --git a/cmake/modules/get_versions.cmake b/cmake/modules/get_versions.cmake index 5578440c2ed..2bc7563ec3b 100644 --- a/cmake/modules/get_versions.cmake +++ b/cmake/modules/get_versions.cmake @@ -31,4 +31,4 @@ 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 +endfunction() diff --git a/cmake/modules/repo_status.cmake b/cmake/modules/repo_status.cmake index ca13362fe45..7937f688860 100644 --- a/cmake/modules/repo_status.cmake +++ b/cmake/modules/repo_status.cmake @@ -33,4 +33,4 @@ execute_process( set(${version_git_var} "${GRASS_VERSION_GIT}" PARENT_SCOPE) -endfunction() #repo_status \ No newline at end of file +endfunction() #repo_status diff --git a/cmake/modules/set_compiler_flags.cmake b/cmake/modules/set_compiler_flags.cmake index 871f9f6bb2e..3f40238f325 100644 --- a/cmake/modules/set_compiler_flags.cmake +++ b/cmake/modules/set_compiler_flags.cmake @@ -10,4 +10,4 @@ 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 +endmacro() 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} 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/) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 841cb55b549..131f7ccb971 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -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) diff --git a/lib/init/license.txt.in b/lib/init/license.txt.in index c40844420c5..c65922aa07e 100644 --- a/lib/init/license.txt.in +++ b/lib/init/license.txt.in @@ -1,7 +1,7 @@ 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. diff --git a/python/libgrass_interface_generator/CMakeLists.txt b/python/libgrass_interface_generator/CMakeLists.txt index b243f459da4..698da806f6a 100644 --- a/python/libgrass_interface_generator/CMakeLists.txt +++ b/python/libgrass_interface_generator/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) diff --git a/vector/CMakeLists.txt b/vector/CMakeLists.txt index 52f2c5715f3..b5e3b7b440f 100644 --- a/vector/CMakeLists.txt +++ b/vector/CMakeLists.txt @@ -209,4 +209,4 @@ build_program_in_subdir(v.out.postgis DEPENDS grass_gis grass_vector PRIMARY_DEP if(WITH_OPENDWG) build_program_in_subdir(v.in.dwg DEPENDS grass_gis grass_vector) -endif() \ No newline at end of file +endif() From 4889de7441b8b997eb26d41eb2955a8aeeb4d532 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 14:37:28 +0100 Subject: [PATCH 04/60] CI fix for pylint in gui/wxpython called with wildcard --- .github/workflows/python-code-quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-code-quality.yml b/.github/workflows/python-code-quality.yml index 7ad02b39960..9d21925543e 100644 --- a/.github/workflows/python-code-quality.yml +++ b/.github/workflows/python-code-quality.yml @@ -109,7 +109,7 @@ jobs: export PYTHONPATH=`grass --config python_path`:$PYTHONPATH export LD_LIBRARY_PATH=$HOME/install/grass84/lib:$LD_LIBRARY_PATH cd gui/wxpython - pylint --persistent=no --py-version=${{ matrix.min-python-version }} --jobs=$(nproc) * + pylint --persistent=no --py-version=${{ matrix.min-python-version }} --jobs=$(nproc) --disable=CMakeLists.txt * - name: Run Pylint on other files using pytest run: | From 9eed8bceaffd84684468fd182d990029774daea0 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 15:41:08 +0100 Subject: [PATCH 05/60] cmake/find_scripts/FindPROJ.cmake: update to PROJ > 4 --- cmake/find_scripts/FindPROJ.cmake | 62 +++++++------------------------ 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/cmake/find_scripts/FindPROJ.cmake b/cmake/find_scripts/FindPROJ.cmake index 0c63cf8cbcc..8f7c1da251f 100644 --- a/cmake/find_scripts/FindPROJ.cmake +++ b/cmake/find_scripts/FindPROJ.cmake @@ -1,57 +1,23 @@ -############################################################################### -# 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 -# 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.h PATH_SUFFIXES proj) -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") +find_library(PROJ_LIBRARY_RELEASE NAMES proj_i proj) +find_library(PROJ_LIBRARY_DEBUG NAMES projd) +set(PROJ_FOUND FALSE) set(PROJ_LIBRARY) if(PROJ_LIBRARY_DEBUG) - set( PROJ_LIBRARY ${PROJ_LIBRARY_DEBUG}) + set( PROJ_LIBRARY ${PROJ_LIBRARY_DEBUG} CACHE FILEPATH "doc" ) elseif(PROJ_LIBRARY_RELEASE) - set( PROJ_LIBRARY ${PROJ_LIBRARY_RELEASE}) + set( PROJ_LIBRARY ${PROJ_LIBRARY_RELEASE} CACHE FILEPATH "doc" ) endif() -if(PROJ_INCLUDE_DIR AND PROJ_LIBRARY) -set(PROJ_FOUND TRUE) -endif() +mark_as_advanced(PROJ_LIBRARY_RELEASE) +mark_as_advanced(PROJ_LIBRARY_DEBUG) +mark_as_advanced(PROJ_LIBRARY) +mark_as_advanced(PROJ_INCLUDE_DIR) -MARK_AS_ADVANCED( - PROJ_INCLUDE_DIR - PROJ_LIBRARY - PROJ_LIBRARY_DEBUG - PROJ_LIBRARY_RELEASE -) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( PROJ DEFAULT_MSG + PROJ_LIBRARY + PROJ_INCLUDE_DIR ) -# 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) From 67cdeee7f20bc636daf5afb577d18c4a7d3ce0ca Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 15:44:30 +0100 Subject: [PATCH 06/60] cmake/find_scripts/FindPostgreSQL.cmake: update to https://github.com/OSGeo/gdal/blob/master/cmake/modules/3.20/FindPostgreSQL.cmake --- cmake/find_scripts/FindPostgreSQL.cmake | 218 ++++++++++++++++++++++-- 1 file changed, 202 insertions(+), 16 deletions(-) diff --git a/cmake/find_scripts/FindPostgreSQL.cmake b/cmake/find_scripts/FindPostgreSQL.cmake index 3c048cd6c72..e5c6ce0a088 100644 --- a/cmake/find_scripts/FindPostgreSQL.cmake +++ b/cmake/find_scripts/FindPostgreSQL.cmake @@ -1,3 +1,45 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindPostgreSQL +-------------- + +Find the PostgreSQL installation. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.14 + +This module defines :prop_tgt:`IMPORTED` target ``PostgreSQL::PostgreSQL`` +if PostgreSQL has been found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``PostgreSQL_FOUND`` + True if PostgreSQL is found. +``PostgreSQL_LIBRARIES`` + the PostgreSQL libraries needed for linking +``PostgreSQL_INCLUDE_DIRS`` + the directories of the PostgreSQL headers +``PostgreSQL_LIBRARY_DIRS`` + the link directories for PostgreSQL libraries +``PostgreSQL_VERSION_STRING`` + the version of PostgreSQL found +``PostgreSQL_TYPE_INCLUDE_DIR`` + the directories of the PostgreSQL server headers + +Components +^^^^^^^^^^ + +This module contains additional ``Server`` component, that forcibly checks +for the presence of server headers. Note that ``PostgreSQL_TYPE_INCLUDE_DIR`` +is set regardless of the presence of the ``Server`` component in find_package call. + #]=======================================================================] # ---------------------------------------------------------------------------- @@ -48,36 +90,122 @@ # installed PostgreSQL, e.g. . # # ---------------------------------------------------------------------------- + +cmake_policy(PUSH) +cmake_policy(SET CMP0057 NEW) # if IN_LIST + +set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include") +set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}") +set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.") +set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}") +set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4") + + +set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS} + "13" "12" "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") + +# Define additional search paths for root directories. +set( PostgreSQL_ROOT_DIRECTORIES + ENV PostgreSQL_ROOT + ${PostgreSQL_ROOT} +) +foreach(suffix ${PostgreSQL_KNOWN_VERSIONS}) + if(WIN32) + list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES + "PostgreSQL/${suffix}/lib") + list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES + "PostgreSQL/${suffix}/include") + list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES + "PostgreSQL/${suffix}/include/server") + endif() + if(UNIX) + list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES + "postgresql${suffix}" + "pgsql-${suffix}/lib") + list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES + "postgresql${suffix}" + "postgresql/${suffix}" + "pgsql-${suffix}/include") + list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES + "postgresql${suffix}/server" + "postgresql/${suffix}/server" + "pgsql-${suffix}/include/server") + endif() +endforeach() + +# +# Look for an installation. +# find_path(PostgreSQL_INCLUDE_DIR NAMES libpq-fe.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} PATH_SUFFIXES pgsql postgresql include - + ${PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES} # Help the user find it if we cannot. - DOC "path to libpq-fe.h" + DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" ) find_path(PostgreSQL_TYPE_INCLUDE_DIR NAMES catalog/pg_type.h + PATHS + # Look in other places. + ${PostgreSQL_ROOT_DIRECTORIES} PATH_SUFFIXES postgresql pgsql/server postgresql/server - postgresql/9.5/server include/server - + ${PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES} # Help the user find it if we cannot. - DOC "path to postgresql header catalog/pg_type.h" + DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}" ) -find_library(PostgreSQL_LIBRARY - NAMES libpqd pqd libpq pq - # Help the user find it if we cannot. - DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}") +# The PostgreSQL library. +set (PostgreSQL_LIBRARY_TO_FIND pq) +# Setting some more prefixes for the library +set (PostgreSQL_LIB_PREFIX "") +if ( WIN32 ) + set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib") + set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND}) +endif() -get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH) +function(__postgresql_find_library _name) + find_library(${_name} + NAMES ${ARGN} + PATHS + ${PostgreSQL_ROOT_DIRECTORIES} + PATH_SUFFIXES + lib + ${PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES} + # Help the user find it if we cannot. + DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}" + ) +endfunction() + +# For compatibility with versions prior to this multi-config search, honor +# any PostgreSQL_LIBRARY that is already specified and skip the search. +if(PostgreSQL_LIBRARY) + set(PostgreSQL_LIBRARIES "${PostgreSQL_LIBRARY}") + get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY}" PATH) +else() + __postgresql_find_library(PostgreSQL_LIBRARY_RELEASE ${PostgreSQL_LIBRARY_TO_FIND}) + __postgresql_find_library(PostgreSQL_LIBRARY_DEBUG ${PostgreSQL_LIBRARY_TO_FIND}d) + include(SelectLibraryConfigurations) + select_library_configurations(PostgreSQL) + mark_as_advanced(PostgreSQL_LIBRARY_RELEASE PostgreSQL_LIBRARY_DEBUG) + if(PostgreSQL_LIBRARY_RELEASE) + get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_RELEASE}" PATH) + elseif(PostgreSQL_LIBRARY_DEBUG) + get_filename_component(PostgreSQL_LIBRARY_DIR "${PostgreSQL_LIBRARY_DEBUG}" PATH) + else() + set(PostgreSQL_LIBRARY_DIR "") + endif() +endif() if (PostgreSQL_INCLUDE_DIR) # Some platforms include multiple pg_config.hs for multi-lib configurations @@ -96,11 +224,22 @@ if (PostgreSQL_INCLUDE_DIR) 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) + # 9.x and older encoding + if (_PostgreSQL_VERSION_NUM LESS 100000) + math(EXPR _PostgreSQL_major_version "${_PostgreSQL_VERSION_NUM} / 10000") + math(EXPR _PostgreSQL_minor_version "${_PostgreSQL_VERSION_NUM} % 10000 / 100") + math(EXPR _PostgreSQL_patch_version "${_PostgreSQL_VERSION_NUM} % 100") + set(PostgreSQL_VERSION_STRING "${_PostgreSQL_major_version}.${_PostgreSQL_minor_version}.${_PostgreSQL_patch_version}") + unset(_PostgreSQL_major_version) + unset(_PostgreSQL_minor_version) + unset(_PostgreSQL_patch_version) + else () + 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) + endif () else () foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS}) if(EXISTS "${_PG_CONFIG_HEADER}") @@ -118,9 +257,56 @@ if (PostgreSQL_INCLUDE_DIR) unset(pgsql_version_str) endif() +if("Server" IN_LIST PostgreSQL_FIND_COMPONENTS) + set(PostgreSQL_Server_FOUND TRUE) + if(NOT PostgreSQL_TYPE_INCLUDE_DIR) + set(PostgreSQL_Server_FOUND FALSE) + endif() +endif() + # Did we find anything? include(FindPackageHandleStandardArgs) find_package_handle_standard_args(PostgreSQL - REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR + REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR + HANDLE_COMPONENTS VERSION_VAR PostgreSQL_VERSION_STRING) set(PostgreSQL_FOUND ${POSTGRESQL_FOUND}) + +function(__postgresql_import_library _target _var _config) + if(_config) + set(_config_suffix "_${_config}") + else() + set(_config_suffix "") + endif() + + set(_lib "${${_var}${_config_suffix}}") + if(EXISTS "${_lib}") + if(_config) + set_property(TARGET ${_target} APPEND PROPERTY + IMPORTED_CONFIGURATIONS ${_config}) + endif() + set_target_properties(${_target} PROPERTIES + IMPORTED_LOCATION${_config_suffix} "${_lib}") + endif() +endfunction() + +# Now try to get the include and library path. +if(PostgreSQL_FOUND) + set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR}) + if(PostgreSQL_TYPE_INCLUDE_DIR) + list(APPEND PostgreSQL_INCLUDE_DIRS ${PostgreSQL_TYPE_INCLUDE_DIR}) + endif() + set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR}) + if (NOT TARGET PostgreSQL::PostgreSQL) + add_library(PostgreSQL::PostgreSQL UNKNOWN IMPORTED) + set_target_properties(PostgreSQL::PostgreSQL PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${PostgreSQL_INCLUDE_DIRS}") + __postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "") + __postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "RELEASE") + __postgresql_import_library(PostgreSQL::PostgreSQL PostgreSQL_LIBRARY "DEBUG") + endif () +endif() + +mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR) + +cmake_policy(POP) From faea30ba102958622c8dd21d2f79cbeb797f14c6 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 15:50:19 +0100 Subject: [PATCH 07/60] various path updates (sync to main) --- CMakeLists.txt | 7 ++++--- include/CMakeLists.txt | 2 +- lib/CMakeLists.txt | 4 ---- lib/gis/CMakeLists.txt | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41b17b44ca8..00d0d612f4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,7 @@ include(build_gui_in_subdir) include(check_target) add_subdirectory(thirdparty) -set(MKHTML_PY ${CMAKE_BINARY_DIR}/tools/mkhtml.py) +set(MKHTML_PY ${CMAKE_BINARY_DIR}/utils/mkhtml.py) set(GISBASE ${CMAKE_BINARY_DIR}/gisbase) file(TO_NATIVE_PATH "${GISBASE}" GISBASE_NATIVE) @@ -165,8 +165,9 @@ execute_process( 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}/utils/ COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/lib/ + COMMAND ${CMAKE_COMMAND} -E make_directory ${GISBASE}/python/ 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/ @@ -176,7 +177,7 @@ execute_process( ) add_subdirectory(lib) -add_subdirectory(tools) +add_subdirectory(utils) set(modules_list) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index b9d398a81d9..4df77022d3e 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -260,7 +260,7 @@ endforeach() add_custom_target(copy_header DEPENDS ${include_depends} LIB_PYTHON) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/grass/version.h.in "${CMAKE_CURRENT_BINARY_DIR}/grass/version.h") message(STATUS "Creating ${CMAKE_CURRENT_BINARY_DIR}/grass/config.h") diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 131f7ccb971..d3d39cd3105 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -149,10 +149,6 @@ 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 ) diff --git a/lib/gis/CMakeLists.txt b/lib/gis/CMakeLists.txt index 22ae1df8fb9..48499500c57 100644 --- a/lib/gis/CMakeLists.txt +++ b/lib/gis/CMakeLists.txt @@ -21,7 +21,7 @@ set(gislib_SRCS 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 + compress.c ) if(MINGW) From 7f39bb31307bed626562c81332f3e1b24c4684ee Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 18:25:07 +0100 Subject: [PATCH 08/60] grass7 -> grass8; msg cosmetics --- CMakeLists.txt | 6 +++--- lib/init/CMakeLists.txt | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00d0d612f4c..33c91e688f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # AUTHOR(S): Rashad Kanavath -# PURPOSE: Grass root that adds options to activate/deactivate 3rd party libraries -# COPYRIGHT: (C) 2020 by the GRASS Development Team +# PURPOSE: GRASS GIS root that adds options to activate/deactivate 3rd party libraries +# COPYRIGHT: (C) 2020-2022 by the GRASS Development Team # This program is free software under the GPL (>=v2) # Read the file COPYING that comes with GRASS for details. @@ -50,7 +50,7 @@ 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_LIBLAS "enable libLAS support" OFF) option(WITH_OPENDWG "enable v.in.dwg" OFF) option(WITH_PYTHON "Build python bindings" ON) diff --git a/lib/init/CMakeLists.txt b/lib/init/CMakeLists.txt index 70b38b62d4b..d452b5c4329 100644 --- a/lib/init/CMakeLists.txt +++ b/lib/init/CMakeLists.txt @@ -16,12 +16,12 @@ 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") + message(WARNING "External PROJ 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}") + message(STATUS "PROJ directory ${CONFIG_PROJSHARE}") endif() endif() file(TO_NATIVE_PATH "${PROJ_INSTALL_PREFIX}/share/proj" PROJ_LIB) @@ -68,9 +68,9 @@ if(WIN32) # 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) + file(TO_NATIVE_PATH "${app_data_dir}/GRASS8" grass_config_dir) else() - set(grass_config_dir "$ENV{HOME}/.grass7") + set(grass_config_dir "$ENV{HOME}/.grass8") endif() file(TO_NATIVE_PATH "${CMAKE_INSTALL_PREFIX}" gisbase_init_dir) From 96862bd4430d8276be69059d0ab3e37b7c954370 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Tue, 6 Dec 2022 23:05:13 +0100 Subject: [PATCH 09/60] CI: cmake compile script Attempt to add a CI workflow --- .github/workflows/cmake.yml | 91 +++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000000..53b4dd25924 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,91 @@ +# inspired by "build GDAL library and to run test with CMake" +# from https://github.com/OSGeo/gdal/blob/master/.github/workflows/cmake_builds.yml + +name: Build and test with CMake + +on: + push: + paths-ignore: + - 'doc/**' + branches-ignore: + - 'backport**' + pull_request: + paths-ignore: + - 'doc/**' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +env: + CMAKE_UNITY_BUILD: OFF + +permissions: + contents: read # to fetch code (actions/checkout) + +jobs: + + build-linux-ubuntu-focal: + runs-on: ubuntu-20.04 + env: + CMAKE_OPTIONS: -DPython_LOOKUP_VERSION=3.8 -DUSE_CCACHE=ON + cache-name: cmake-ubuntu-focal + steps: + - name: Checkout GRASS + uses: actions/checkout@v3 + - name: Setup cache + uses: actions/cache@v3 + id: cache + with: + path: ${{ github.workspace }}/.ccache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ github.base_ref }}${{ github.ref_name }}-${{ github.run_id }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}-${{ github.base_ref }} + ${{ runner.os }}-${{ env.cache-name }} + - name: Install CMake 3.9.1 + run: | + cd ${GITHUB_WORKSPACE} + wget https://github.com/Kitware/CMake/releases/download/v3.9.1/cmake-3.9.1-Linux-x86_64.tar.gz + tar xzf cmake-3.9.1-Linux-x86_64.tar.gz + echo "CMAKE_DIR=$GITHUB_WORKSPACE/cmake-3.9.1-Linux-x86_64/bin" >> $GITHUB_ENV + echo "$GITHUB_WORKSPACE/cmake-3.9.1-Linux-x86_64/bin" >> $GITHUB_PATH + - run: | + cmake --version + - name: Install dependency + run: | + sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable + sudo apt-get update + sudo apt-get install -y -q apt-get install build-essential \ + flex make bison gcc libgcc1 g++ ccache \ + python3 python3-dev \ + python3-opengl python3-wxgtk4.0 \ + python3-dateutil libgsl-dev python3-numpy \ + wx3.0-headers wx-common libwxgtk3.0-gtk3-dev \ + libwxbase3.0-dev libbz2-dev zlib1g-dev gettext \ + libtiff5-dev libpnglite-dev libcairo2 libcairo2-dev \ + sqlite3 libsqlite3-dev \ + libpq-dev libreadline6-dev libfreetype6-dev \ + libfftw3-3 libfftw3-dev \ + libboost-thread-dev libboost-program-options-dev libpdal-dev\ + subversion libzstd-dev checkinstall \ + libglu1-mesa-dev libxmu-dev \ + ghostscript wget -y make ccache g++ + sudo apt-get update -y + - name: Configure ccache + run: | + echo CCACHE_BASEDIR=$PWD >> ${GITHUB_ENV} + echo CCACHE_DIR=$PWD/.ccache >> ${GITHUB_ENV} + echo CCACHE_MAXSIZE=250M >> ${GITHUB_ENV} + ccache -z + working-directory: ${{ github.workspace }} + - name: Configure + run: | + mkdir -p $GITHUB_WORKSPACE/build + cd $GITHUB_WORKSPACE/build + cmake ${CMAKE_OPTIONS} .. + - name: Build + run: | + make -j$(nproc) + - name: ccache statistics + run: ccache -s + From d9f674e5856be6194a79b16bb6c216c3b695336c Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Sat, 10 Dec 2022 17:32:39 +0100 Subject: [PATCH 10/60] fix syntax --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 53b4dd25924..eae3da7da88 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -55,7 +55,7 @@ jobs: run: | sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable sudo apt-get update - sudo apt-get install -y -q apt-get install build-essential \ + sudo apt-get install -y -q build-essential \ flex make bison gcc libgcc1 g++ ccache \ python3 python3-dev \ python3-opengl python3-wxgtk4.0 \ From 49c5d5b2721bc62f040ec42f2b2656605abdaa4b Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Sat, 10 Dec 2022 17:39:25 +0100 Subject: [PATCH 11/60] fix Build step --- .github/workflows/cmake.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index eae3da7da88..2d6ea8f80e3 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -82,9 +82,10 @@ jobs: run: | mkdir -p $GITHUB_WORKSPACE/build cd $GITHUB_WORKSPACE/build - cmake ${CMAKE_OPTIONS} .. + cmake ${CMAKE_OPTIONS} .. - name: Build run: | + cd $GITHUB_WORKSPACE/build make -j$(nproc) - name: ccache statistics run: ccache -s From b2669e5c16f9e536f70b7d73515e7870f94b8108 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Sun, 11 Dec 2022 15:54:28 +0100 Subject: [PATCH 12/60] Build step debugging --- .github/workflows/cmake.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 2d6ea8f80e3..f76d33b1335 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -51,7 +51,7 @@ jobs: echo "$GITHUB_WORKSPACE/cmake-3.9.1-Linux-x86_64/bin" >> $GITHUB_PATH - run: | cmake --version - - name: Install dependency + - name: Install dependencies run: | sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable sudo apt-get update @@ -83,6 +83,9 @@ jobs: mkdir -p $GITHUB_WORKSPACE/build cd $GITHUB_WORKSPACE/build cmake ${CMAKE_OPTIONS} .. + ls $GITHUB_WORKSPACE/build + sudo apt-get install -y -q mlocate ; sudo updatedb + locate include/Make/Platform.make - name: Build run: | cd $GITHUB_WORKSPACE/build From 18bf7f07550bfa7223e77cfdd8bb1fafbceeaac7 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 09:47:49 +0100 Subject: [PATCH 13/60] Simplify cmake command call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- .github/workflows/cmake.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index f76d33b1335..205da83dafd 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -80,9 +80,7 @@ jobs: working-directory: ${{ github.workspace }} - name: Configure run: | - mkdir -p $GITHUB_WORKSPACE/build - cd $GITHUB_WORKSPACE/build - cmake ${CMAKE_OPTIONS} .. + cmake ${CMAKE_OPTIONS} -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build ls $GITHUB_WORKSPACE/build sudo apt-get install -y -q mlocate ; sudo updatedb locate include/Make/Platform.make From f76f68f16513767283c83f67320e81bcfb74e74c Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 09:48:48 +0100 Subject: [PATCH 14/60] Remove debugging leftover. --- .github/workflows/cmake.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 205da83dafd..849d9d6bdb7 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -81,9 +81,6 @@ jobs: - name: Configure run: | cmake ${CMAKE_OPTIONS} -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build - ls $GITHUB_WORKSPACE/build - sudo apt-get install -y -q mlocate ; sudo updatedb - locate include/Make/Platform.make - name: Build run: | cd $GITHUB_WORKSPACE/build From ba6c07dc53ddc167ad03e1f833285c94d3a28c4a Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 09:49:34 +0100 Subject: [PATCH 15/60] make -> cmake MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- .github/workflows/cmake.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 849d9d6bdb7..928a16b0af0 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -84,7 +84,7 @@ jobs: - name: Build run: | cd $GITHUB_WORKSPACE/build - make -j$(nproc) + cmake --build . -j$(nproc) - name: ccache statistics run: ccache -s From 76576db761233915b05ae974acbba146dd94b823 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 11:45:54 +0100 Subject: [PATCH 16/60] update year MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- cmake/modules/build_program_in_subdir.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/build_program_in_subdir.cmake b/cmake/modules/build_program_in_subdir.cmake index 3da2baa6ac1..e8197e56b8b 100644 --- a/cmake/modules/build_program_in_subdir.cmake +++ b/cmake/modules/build_program_in_subdir.cmake @@ -1,7 +1,7 @@ # 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 +# 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. From 2be2b75760d1e44974eb0715049192b42a4e0bdb Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:26:35 +0100 Subject: [PATCH 17/60] python_bandref -> python_semantic_label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- python/grass/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/grass/CMakeLists.txt b/python/grass/CMakeLists.txt index 78a229ece5b..858ad71fd58 100644 --- a/python/grass/CMakeLists.txt +++ b/python/grass/CMakeLists.txt @@ -27,7 +27,7 @@ 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 + DEPENDS python_exceptions python_imaging python_pydispatch python_script python_semantic_label 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 From e8126e7c4f1534e391bd863f887fa4076dbfd75a Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:27:29 +0100 Subject: [PATCH 18/60] remove outdated bandref MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- python/grass/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/python/grass/CMakeLists.txt b/python/grass/CMakeLists.txt index 858ad71fd58..eb1e69f9694 100644 --- a/python/grass/CMakeLists.txt +++ b/python/grass/CMakeLists.txt @@ -1,5 +1,4 @@ -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) From 52123fe7523e39fa78bfcb2d8797ed271c88e05c Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:27:55 +0100 Subject: [PATCH 19/60] bandref -> semantic_label MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- python/grass/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/python/grass/CMakeLists.txt b/python/grass/CMakeLists.txt index eb1e69f9694..75b9b171f29 100644 --- a/python/grass/CMakeLists.txt +++ b/python/grass/CMakeLists.txt @@ -4,6 +4,7 @@ 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(semantic_label 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) From 91461d5994e98f68b5bcd613e352992f97bb6166 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:34:48 +0100 Subject: [PATCH 20/60] added python/CMakeLists.txt (from https://github.com/OSGeo/grass/pull/289/files#diff-28d5606d950172ebb1e15f25bf4c4b23e489abc29dceda5dd3df606a2a3a6d01) --- python/CMakeLists.txt | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 python/CMakeLists.txt diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 00000000000..d27e5854986 --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,42 @@ + +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(semantic_label 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_exceptions python_imaging python_pydispatch python_script python_semantic_label 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/) From 87ef0aa321f2f2e3149077c74cebe9510174d03f Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:36:26 +0100 Subject: [PATCH 21/60] add_subdirectory(python) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33c91e688f4..7a9dea54748 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,8 @@ if(WITH_PYTHON) add_subdirectory(gui) endif() +add_subdirectory(python) + if(WITH_DOCS) add_subdirectory(doc) add_subdirectory(man) From aecd006bc7ef0b19cd9741c701e6fda486182d6f Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 15:41:31 +0100 Subject: [PATCH 22/60] fix path to grass/script/setup.py --- python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index d27e5854986..976c4046b17 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -19,7 +19,7 @@ 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 +configure_file(grass/script/setup.py ${CMAKE_BINARY_DIR}/etc/python/grass/script/setup.py COPYONLY) From 4b23a6ce107b98782355432fc3ba4ea6e47895ee Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 20:13:30 +0100 Subject: [PATCH 23/60] remove files deleted in PR #1400 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- gui/wxpython/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/gui/wxpython/CMakeLists.txt b/gui/wxpython/CMakeLists.txt index ef69efa6076..0f8944d97a5 100644 --- a/gui/wxpython/CMakeLists.txt +++ b/gui/wxpython/CMakeLists.txt @@ -12,8 +12,6 @@ foreach(gui_lib_DIR ${gui_lib_DIRS}) 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}) From 0a43a1c4a35cdb0f3ce86d6c83475b95da8993da Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 20:18:14 +0100 Subject: [PATCH 24/60] Fix missing EOL --- raster/r.watershed/CMakeLists.txt | 2 +- raster3d/CMakeLists.txt | 2 +- scripts/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/raster/r.watershed/CMakeLists.txt b/raster/r.watershed/CMakeLists.txt index 2a69c6d10b6..eede612ccf9 100644 --- a/raster/r.watershed/CMakeLists.txt +++ b/raster/r.watershed/CMakeLists.txt @@ -8,4 +8,4 @@ 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 +DEPENDS grass_gis grass_raster) diff --git a/raster3d/CMakeLists.txt b/raster3d/CMakeLists.txt index 266e0e9861c..881d35e1778 100644 --- a/raster3d/CMakeLists.txt +++ b/raster3d/CMakeLists.txt @@ -94,4 +94,4 @@ if(NOT MSVC) build_program_in_subdir( r3.in.v5d DEPENDS grass_gis grass_raster3d) -endif() \ No newline at end of file +endif() diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 37106770768..c45cb51f41e 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -99,4 +99,4 @@ add_custom_target(r.in.wms_files ) 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 + set_target_properties (r.in.wms_files PROPERTIES FOLDER scripts) From e5becb71dd69eaa512f20e40466e35f2ad71076a Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Tue, 3 Jan 2023 08:28:59 +0100 Subject: [PATCH 25/60] just peek in the folder (by @echoix) --- python/CMakeLists.txt | 44 ++----------------------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 976c4046b17..f3f28a0c1d0 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,42 +1,2 @@ - -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(semantic_label 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(grass/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_exceptions python_imaging python_pydispatch python_script python_semantic_label 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/) +add_subdirectory(grass) +add_subdirectory(libgrass_interface_generator) From fd5500d5947134c0833a0cec2f561e950186ca57 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 12:35:27 +0100 Subject: [PATCH 26/60] sync clang-format changes from main --- include/grass/iostream/mm.h | 1 - lib/db/dbmi_base/dbmscap.c | 4 ++-- lib/external/ccmath/ccmath.h | 12 +++++++----- lib/gis/spawn.c | 8 ++++---- lib/gis/user_config.c | 3 ++- lib/iostream/rtimer.cpp | 23 +++++++++++------------ lib/pngdriver/graph_set.c | 4 ++-- lib/rst/interp_float/point2d.c | 3 ++- raster/r.viewshed/statusstructure.cpp | 11 +++-------- 9 files changed, 33 insertions(+), 36 deletions(-) diff --git a/include/grass/iostream/mm.h b/include/grass/iostream/mm.h index dfe0fd9f68c..5b5cfa1e2d9 100644 --- a/include/grass/iostream/mm.h +++ b/include/grass/iostream/mm.h @@ -79,7 +79,6 @@ enum MM_stream_usage { MM_STREAM_USAGE_MAXIMUM }; - #ifdef GRASS_CMAKE_BUILD #include #else diff --git a/lib/db/dbmi_base/dbmscap.c b/lib/db/dbmi_base/dbmscap.c index 51aa438c653..c6ce8f755de 100644 --- a/lib/db/dbmi_base/dbmscap.c +++ b/lib/db/dbmi_base/dbmscap.c @@ -189,8 +189,8 @@ dbDbmscap *db_read_dbmscap(void) name = G_str_replace(ent->d_name, ".exe", ""); #ifdef _WIN32 - dirpath = G_malloc(strlen("\\driver\\db\\") - + strlen(G_gisbase()) + strlen(ent->d_name) + 1); + 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); G_convert_dirseps_to_host(dirpath); #else diff --git a/lib/external/ccmath/ccmath.h b/lib/external/ccmath/ccmath.h index 74aac8634f3..44fb1e5acb3 100644 --- a/lib/external/ccmath/ccmath.h +++ b/lib/external/ccmath/ccmath.h @@ -32,18 +32,16 @@ #define NULL ((void *)0 #endif - /* Complex Types */ +/* Complex Types */ #ifndef CPX #ifndef _MSC_VER -struct complex -{ +struct complex { double re, im; }; typedef struct complex Cpx; #else /* _MSVC has complex struct and cannot be used */ -struct gcomplex -{ +struct gcomplex { double re, im; }; typedef struct gcomplex Cpx; @@ -54,8 +52,10 @@ typedef struct gcomplex Cpx; /* Linear Algebra */ + /* Real Linear Systems */ + int minv(double *a, int n); int psinv(double *v, int n); @@ -178,6 +178,8 @@ void unitary(Cpx *u, int n); void hmgen(Cpx *h, double *eval, Cpx *u, int n); +int csolv(Cpx *a, Cpx *b, int n); + /* utility routines for hermitian eigen problems */ void chouse(Cpx *a, double *d, double *ud, int n); diff --git a/lib/gis/spawn.c b/lib/gis/spawn.c index 2642f4020ab..1b1630ebc78 100644 --- a/lib/gis/spawn.c +++ b/lib/gis/spawn.c @@ -935,11 +935,11 @@ int G_spawn(const char *command, ...) va_end(va); - status = G_spawn_ex(command, + status = + G_spawn_ex(command, #ifndef _WIN32 - SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGINT, - SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGQUIT, - SF_SIGNAL, SST_PRE, SSA_BLOCK, SIGCHLD, + SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGINT, SF_SIGNAL, SST_PRE, + SSA_IGNORE, SIGQUIT, SF_SIGNAL, SST_PRE, SSA_BLOCK, SIGCHLD, #endif SF_ARGVEC, args, NULL); diff --git a/lib/gis/user_config.c b/lib/gis/user_config.c index c1a840de3fd..4fb23226dcc 100644 --- a/lib/gis/user_config.c +++ b/lib/gis/user_config.c @@ -44,7 +44,7 @@ * path [caller must G_free ()] on success, or NULL on failure *************************************************************************/ -#ifndef _WIN32 /* TODO */ +#ifndef _WIN32 /* TODO */ static char *_make_toplevel(void) { size_t len; @@ -315,5 +315,6 @@ char *G_rc_path(const char *element, const char *item) return path; } /* G_rc_path */ + /* vim: set softtabstop=4 shiftwidth=4 expandtab: */ #endif diff --git a/lib/iostream/rtimer.cpp b/lib/iostream/rtimer.cpp index c0d8a4fd9fc..b241a531d3e 100644 --- a/lib/iostream/rtimer.cpp +++ b/lib/iostream/rtimer.cpp @@ -44,25 +44,24 @@ #include #endif +// #include #include -#define BUFMAX 256 - char *rt_sprint_safe(char *buf, Rtimer rt) { if (rt_w_useconds(rt) == 0) { - snprintf(buf, BUFMAX, "[%4.2fu (%.0f%%) %4.2fs (%.0f%%) %4.2f %.1f%%]", - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + sprintf(buf, "[%4.2fu (%.0f%%) %4.2fs (%.0f%%) %4.2f %.1f%%]", 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0); } else { - snprintf(buf, BUFMAX, "[%4.2fu (%.0f%%) %4.2fs (%.0f%%) %4.2f %.1f%%]", - rt_u_useconds(rt) / 1000000, - 100.0 * rt_u_useconds(rt) / rt_w_useconds(rt), - rt_s_useconds(rt) / 1000000, - 100.0 * rt_s_useconds(rt) / rt_w_useconds(rt), - rt_w_useconds(rt) / 1000000, - 100.0 * (rt_u_useconds(rt) + rt_s_useconds(rt)) / - rt_w_useconds(rt)); + sprintf(buf, "[%4.2fu (%.0f%%) %4.2fs (%.0f%%) %4.2f %.1f%%]", + rt_u_useconds(rt) / 1000000, + 100.0 * rt_u_useconds(rt) / rt_w_useconds(rt), + rt_s_useconds(rt) / 1000000, + 100.0 * rt_s_useconds(rt) / rt_w_useconds(rt), + rt_w_useconds(rt) / 1000000, + 100.0 * (rt_u_useconds(rt) + rt_s_useconds(rt)) / + rt_w_useconds(rt)); } return buf; } diff --git a/lib/pngdriver/graph_set.c b/lib/pngdriver/graph_set.c index 8376e421b12..03c65ebbb8d 100644 --- a/lib/pngdriver/graph_set.c +++ b/lib/pngdriver/graph_set.c @@ -42,8 +42,8 @@ static void map_file(void) return; #ifdef _WIN32 - png.handle = CreateFileMapping((HANDLE) _get_osfhandle(fd), - NULL, PAGE_READWRITE, 0, size, NULL); + png.handle = CreateFileMapping((HANDLE)_get_osfhandle(fd), NULL, + PAGE_READWRITE, 0, size, NULL); if (!png.handle) return; ptr = MapViewOfFile(png.handle, FILE_MAP_WRITE, 0, 0, size); diff --git a/lib/rst/interp_float/point2d.c b/lib/rst/interp_float/point2d.c index 1c03c78953b..db180748d7a 100644 --- a/lib/rst/interp_float/point2d.c +++ b/lib/rst/interp_float/point2d.c @@ -31,7 +31,7 @@ #include #ifndef POINT2D_C -#define POINT2D_C 1 +#define POINT2D_C #endif #include @@ -193,5 +193,6 @@ int IL_check_at_points_2d(struct interp_params *params, } } /* cv */ + return 1; } diff --git a/raster/r.viewshed/statusstructure.cpp b/raster/r.viewshed/statusstructure.cpp index dd4e733cb81..05ef41b85d6 100644 --- a/raster/r.viewshed/statusstructure.cpp +++ b/raster/r.viewshed/statusstructure.cpp @@ -17,7 +17,7 @@ * considered visible to each other if the cells where they belong are * visible to each other. Two cells are visible to each other if the * line-of-sight that connects their centers does not intersect the - * terrain. The terrain is NOT viewed as a tessellation of flat cells, + * terrain. The terrain is NOT viewed as a tesselation of flat cells, * i.e. if the line-of-sight does not pass through the cell center, * elevation is determined using bilinear interpolation. * The viewshed algorithm is efficient both in @@ -38,8 +38,7 @@ #include #include #include -extern "C" -{ +extern "C" { #include #include } @@ -58,7 +57,7 @@ extern "C" If doCurv is set we need to consider the curvature of the earth */ float get_vertical_angle(Viewpoint vp, StatusNode sn, surface_type elev, - int doCurv UNUSED) + int doCurv) { /*determine the difference in elevation, based on the curvature */ @@ -107,9 +106,7 @@ void calculate_dist_n_gradient(StatusNode *sn, double elev, Viewpoint *vp, //sn->dist2vp = sqrt((float) ( pow(sn->row - vp->row,2.0) + // pow(sn->col - vp->col,2.0))); //sn->gradient = (sn->elev - vp->elev)/(sn->dist2vp); */ - double diffElev = elev - vp->elev; - if (G_projection() == PROJECTION_LL) { double dist = G_distance(Rast_col_to_easting(sn->col + 0.5, &(hd.window)), @@ -149,7 +146,6 @@ void calculate_dist_n_gradient(StatusNode *sn, double elev, Viewpoint *vp, /*maintain sign */ if (elev < vp->elev) sn->gradient[1] = -sn->gradient[1]; - return; } @@ -163,7 +159,6 @@ void calculate_event_gradient(StatusNode *sn, int e_idx, double row, double col, //sn->dist2vp = sqrt((float) ( pow(sn->row - vp->row,2.0) + // pow(sn->col - vp->col,2.0))); //sn->gradient = (sn->elev - vp->elev)/(sn->dist2vp); */ - double diffElev = elev - vp->elev; double dist2vp; From 9565839dbd25c5e1257f518c3e66dddb50dc1bf8 Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Wed, 4 Jan 2023 14:38:28 +0100 Subject: [PATCH 27/60] apply clang-format --- cmake/tests/have_pbuffer.c | 14 +-- cmake/tests/have_pixmaps.c | 13 ++- cmake/tests/have_pqcmdtuples.c | 13 +-- lib/db/dbmi_base/login.c | 4 +- lib/db/dbmi_base/msvc/dirent.c | 166 +++++++++++++++----------------- lib/db/dbmi_base/msvc/dirent.h | 16 ++- lib/gis/gisinit.c | 4 +- lib/gis/ls_filter.c | 24 ++--- lib/gis/parser_interface.c | 3 +- lib/raster3d/test/test_tools.c | 2 +- msvc/unistd.h | 55 +++++------ raster/r.terraflow/common.cpp | 2 +- raster/r.terraflow/filldepr.cpp | 2 +- 13 files changed, 154 insertions(+), 164 deletions(-) diff --git a/cmake/tests/have_pbuffer.c b/cmake/tests/have_pbuffer.c index ebc7244acb9..595d07f92a0 100644 --- a/cmake/tests/have_pbuffer.c +++ b/cmake/tests/have_pbuffer.c @@ -4,15 +4,17 @@ builtin and then its argument prototype would still apply. */ char glXCreatePbuffer(); -int main() { +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 +#if defined(__stub_glXCreatePbuffer) || defined(__stub___glXCreatePbuffer) + choke me #else -glXCreatePbuffer(); + glXCreatePbuffer(); #endif -; return 0; } - + ; + return 0; +} diff --git a/cmake/tests/have_pixmaps.c b/cmake/tests/have_pixmaps.c index 88b501bde46..ad46df8c350 100644 --- a/cmake/tests/have_pixmaps.c +++ b/cmake/tests/have_pixmaps.c @@ -6,15 +6,18 @@ builtin and then its argument prototype would still apply. */ char glXCreateGLXPixmap(); -int main() { +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 +#if defined(__stub_glXCreateGLXPixmap) || defined(__stub___glXCreateGLXPixmap) + choke me #else -glXCreateGLXPixmap(); + glXCreateGLXPixmap(); #endif -; return 0; } + ; + return 0; +} diff --git a/cmake/tests/have_pqcmdtuples.c b/cmake/tests/have_pqcmdtuples.c index fcd05fe8d22..ad4ae92571d 100644 --- a/cmake/tests/have_pqcmdtuples.c +++ b/cmake/tests/have_pqcmdtuples.c @@ -1,8 +1,9 @@ #include -int main() { - PGresult* res = NULL; - PGconn* conn = PQconnectdb(NULL); - res = PQexec(conn, NULL); - PQcmdTuples(res); - return 0; +int main() +{ + PGresult *res = NULL; + PGconn *conn = PQconnectdb(NULL); + res = PQexec(conn, NULL); + PQcmdTuples(res); + return 0; } diff --git a/lib/db/dbmi_base/login.c b/lib/db/dbmi_base/login.c index 523e7629eb0..755aa9e24d5 100644 --- a/lib/db/dbmi_base/login.c +++ b/lib/db/dbmi_base/login.c @@ -167,9 +167,9 @@ static int write_file(LOGIN *login) /* fchmod is not available on Windows */ /* fchmod ( fileno(fd), S_IRUSR | S_IWUSR ); */ - #ifndef _MSC_VER +#ifndef _MSC_VER chmod(file, S_IRUSR | S_IWUSR); - #endif +#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) { diff --git a/lib/db/dbmi_base/msvc/dirent.c b/lib/db/dbmi_base/msvc/dirent.c index a5466566ecc..44f7a6a7d29 100644 --- a/lib/db/dbmi_base/msvc/dirent.c +++ b/lib/db/dbmi_base/msvc/dirent.c @@ -5,109 +5,97 @@ 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 */ +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 *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; + 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 closedir(DIR *dir) { - int result = -1; + int result = -1; - if (dir) - { - if (dir->handle != -1) - { - result = _findclose(dir->handle); - } + if (dir) { + if (dir->handle != -1) { + result = _findclose(dir->handle); + } - free(dir->name); - free(dir); - } + free(dir->name); + free(dir); + } - if (result == -1) /* map all errors to EBADF */ - { - errno = EBADF; - } + if (result == -1) /* map all errors to EBADF */ + { + errno = EBADF; + } - return result; + return result; } -struct dirent* readdir(DIR* dir) +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; + 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) +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; - } + 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 index a02a0d828a7..8cd2229e21f 100644 --- a/lib/db/dbmi_base/msvc/dirent.h +++ b/lib/db/dbmi_base/msvc/dirent.h @@ -8,25 +8,23 @@ 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" -{ +extern "C" { #endif typedef struct DIR DIR; -struct dirent -{ +struct dirent { char *d_name; }; -DIR *opendir(const char *); -int closedir(DIR *); +DIR *opendir(const char *); +int closedir(DIR *); struct dirent *readdir(DIR *); -void rewinddir(DIR *); +void rewinddir(DIR *); /* @@ -36,7 +34,7 @@ void rewinddir(DIR *); 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. diff --git a/lib/gis/gisinit.c b/lib/gis/gisinit.c index 1c900bc544f..194a847b641 100644 --- a/lib/gis/gisinit.c +++ b/lib/gis/gisinit.c @@ -35,7 +35,8 @@ struct G__ G__; /** 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" +"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 @@ -44,7 +45,6 @@ static int initialized = 0; GRASS_GIS_EXPORT int initialized; #endif - static int gisinit(void); /*! diff --git a/lib/gis/ls_filter.c b/lib/gis/ls_filter.c index 98ff19437cf..f6dba0319e0 100644 --- a/lib/gis/ls_filter.c +++ b/lib/gis/ls_filter.c @@ -159,22 +159,22 @@ static int re_filter(const char *filename, void *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 */ + 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 */ /* 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 */ + 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 - - } void *G_ls_regex_filter(const char *pat, int exclude, int extended, @@ -235,7 +235,6 @@ void *G_ls_regex_filter(const char *pat, int exclude, int extended, return pcre_regex; #endif - } void *G_ls_glob_filter(const char *pat, int exclude, int ignorecase) @@ -270,8 +269,6 @@ void *G_ls_glob_filter(const char *pat, int exclude, int ignorecase) #ifdef HAVE_PCRE_H return pcre_regex; #endif - - } void G_free_ls_filter(void *regex) @@ -286,5 +283,4 @@ void G_free_ls_filter(void *regex) #endif G_free(regex); - } diff --git a/lib/gis/parser_interface.c b/lib/gis/parser_interface.c index 6b072c5c254..1f6092aec34 100644 --- a/lib/gis/parser_interface.c +++ b/lib/gis/parser_interface.c @@ -114,7 +114,8 @@ void G__usage_xml(void) /* 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 */ +/* 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(_WIN32) && defined(USE_NLS) diff --git a/lib/raster3d/test/test_tools.c b/lib/raster3d/test/test_tools.c index a36f09dec63..97af63a7f7e 100644 --- a/lib/raster3d/test/test_tools.c +++ b/lib/raster3d/test/test_tools.c @@ -20,7 +20,7 @@ #include #include "test_raster3d_lib.h" #ifdef _MSC_VER - #include +#include #endif /* *************************************************************** */ diff --git a/msvc/unistd.h b/msvc/unistd.h index a09e1d92e09..a3370ffaa67 100644 --- a/msvc/unistd.h +++ b/msvc/unistd.h @@ -1,5 +1,5 @@ #ifndef _UNISTD_H -#define _UNISTD_H 1 +#define _UNISTD_H 1 /* This file intended to serve as a drop-in replacement for * unistd.h on Windows. @@ -10,29 +10,30 @@ #include #include #include /* for getpid() and the exec..() family */ -#include /* for _getcwd() and _chdir() */ +#include /* for _getcwd() and _chdir() */ #define srandom srand -#define random rand +#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, +#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 +#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. @@ -40,19 +41,19 @@ * to call e.g. closesocket(). */ -//#define ssize_t int +// #define ssize_t int -#define STDIN_FILENO 0 +#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; +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 */ \ No newline at end of file diff --git a/raster/r.terraflow/common.cpp b/raster/r.terraflow/common.cpp index aae8f681e41..964d6760585 100644 --- a/raster/r.terraflow/common.cpp +++ b/raster/r.terraflow/common.cpp @@ -22,7 +22,7 @@ #endif #include -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (_MSC_VER) +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined(_MSC_VER) #include #else #include diff --git a/raster/r.terraflow/filldepr.cpp b/raster/r.terraflow/filldepr.cpp index 66b006d4116..c64ae600c94 100644 --- a/raster/r.terraflow/filldepr.cpp +++ b/raster/r.terraflow/filldepr.cpp @@ -23,7 +23,7 @@ #include "common.h" #ifdef _MSC_VER -#pragma warning(default:4716) +#pragma warning(default : 4716) #endif #define FLOOD_DEBUG if(0) From 0afe71f70733f928059d53bfac4df6d12105e790 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 19:57:28 +0100 Subject: [PATCH 28/60] cmake_minimum_required version 3.11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a9dea54748..d571732b37e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ # 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) +cmake_minimum_required(VERSION 3.11) set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) #if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) From 617f58da0695d81c3a44c1f76013ccca1d57ced4 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 20:05:46 +0100 Subject: [PATCH 29/60] update to CMake 3.11.4 --- .github/workflows/cmake.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 928a16b0af0..b48da8e0352 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -42,13 +42,13 @@ jobs: restore-keys: | ${{ runner.os }}-${{ env.cache-name }}-${{ github.base_ref }} ${{ runner.os }}-${{ env.cache-name }} - - name: Install CMake 3.9.1 + - name: Install CMake 3.11.4 run: | cd ${GITHUB_WORKSPACE} - wget https://github.com/Kitware/CMake/releases/download/v3.9.1/cmake-3.9.1-Linux-x86_64.tar.gz - tar xzf cmake-3.9.1-Linux-x86_64.tar.gz - echo "CMAKE_DIR=$GITHUB_WORKSPACE/cmake-3.9.1-Linux-x86_64/bin" >> $GITHUB_ENV - echo "$GITHUB_WORKSPACE/cmake-3.9.1-Linux-x86_64/bin" >> $GITHUB_PATH + wget https://github.com/Kitware/CMake/releases/download/v3.11.4/cmake-3.11.4-Linux-x86_64.tar.gz + tar xzf cmake-3.11.4-Linux-x86_64.tar.gz + echo "CMAKE_DIR=$GITHUB_WORKSPACE/cmake-3.11.4-Linux-x86_64/bin" >> $GITHUB_ENV + echo "$GITHUB_WORKSPACE/cmake-3.11.4-Linux-x86_64/bin" >> $GITHUB_PATH - run: | cmake --version - name: Install dependencies @@ -80,6 +80,7 @@ jobs: working-directory: ${{ github.workspace }} - name: Configure run: | + mkdir build cmake ${CMAKE_OPTIONS} -S $GITHUB_WORKSPACE -B $GITHUB_WORKSPACE/build - name: Build run: | From a9c23d75debb041cd64d911552bd3114856cbc76 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 21:42:20 +0100 Subject: [PATCH 30/60] add VERBATIM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com> --- python/grass/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/python/grass/CMakeLists.txt b/python/grass/CMakeLists.txt index 75b9b171f29..ce721e1ce1b 100644 --- a/python/grass/CMakeLists.txt +++ b/python/grass/CMakeLists.txt @@ -27,6 +27,7 @@ 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/ + VERBATIM DEPENDS python_exceptions python_imaging python_pydispatch python_script python_semantic_label 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 From 3f1f5a155f0dfec24afeb7f2370e9eb467425be4 Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Thu, 5 Jan 2023 01:24:26 +0100 Subject: [PATCH 31/60] pylint: ignore cmakelists.txt --- .github/workflows/python-code-quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-code-quality.yml b/.github/workflows/python-code-quality.yml index 9d21925543e..eb996bf3ae6 100644 --- a/.github/workflows/python-code-quality.yml +++ b/.github/workflows/python-code-quality.yml @@ -109,7 +109,7 @@ jobs: export PYTHONPATH=`grass --config python_path`:$PYTHONPATH export LD_LIBRARY_PATH=$HOME/install/grass84/lib:$LD_LIBRARY_PATH cd gui/wxpython - pylint --persistent=no --py-version=${{ matrix.min-python-version }} --jobs=$(nproc) --disable=CMakeLists.txt * + pylint --persistent=no --py-version=${{ matrix.min-python-version }} --jobs=$(nproc) --ignore=CMakeLists.txt * - name: Run Pylint on other files using pytest run: | From 6301f3ed8fe5d91487b2f859a8f44f6b8e1e94c7 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 20:20:18 +0100 Subject: [PATCH 32/60] homogenize ubuntu image name --- .github/workflows/cmake.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b48da8e0352..6b1c528ff50 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -25,11 +25,11 @@ permissions: jobs: - build-linux-ubuntu-focal: + build-linux-ubuntu-20.04: runs-on: ubuntu-20.04 env: CMAKE_OPTIONS: -DPython_LOOKUP_VERSION=3.8 -DUSE_CCACHE=ON - cache-name: cmake-ubuntu-focal + cache-name: cmake-ubuntu-20.04 steps: - name: Checkout GRASS uses: actions/checkout@v3 From d88134ee2ca72b9c3285091bd69fdfa19389a1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Mon, 5 Jun 2023 09:48:28 +0200 Subject: [PATCH 33/60] use of INFINITY and NAN --- general/g.region/printwindow.c | 2 +- lib/btree2/kdtree.c | 2 +- lib/gis/user_config.c | 2 + lib/iostream/rtimer.cpp | 23 ++++---- lib/raster3d/mask.c | 6 +-- lib/vector/Vlib/box.c | 12 ++--- raster/r.horizon/main.c | 2 +- raster/r.in.bin/main.c | 2 +- raster/r.in.lidar/info.c | 4 +- raster/r.li/r.li.padrange/padrange.c | 78 +++++++++++++-------------- raster/r.out.gdal/main.c | 4 +- raster/r.series.accumulate/main.c | 5 +- raster/r.terraflow/flow.cpp | 22 +------- raster/r.univar/r.univar_main.c | 4 +- raster/r.univar/r3.univar_main.c | 8 +-- raster/r.univar/stats.c | 16 +++--- raster/r.viewshed/statusstructure.cpp | 9 +++- raster3d/r3.in.lidar/info.c | 3 +- vector/v.cluster/main.c | 4 +- vector/v.distance/distance.c | 2 +- vector/v.voronoi/skeleton.c | 2 +- 21 files changed, 101 insertions(+), 111 deletions(-) diff --git a/general/g.region/printwindow.c b/general/g.region/printwindow.c index 407855d9bb5..6c065cc297b 100644 --- a/general/g.region/printwindow.c +++ b/general/g.region/printwindow.c @@ -469,7 +469,7 @@ void print_window(struct Cell_head *window, int print_flag, int flat_flag) double convergence; if (G_projection() == PROJECTION_XY) - convergence = 0. / 0.; + convergence = NAN; else if (G_projection() == PROJECTION_LL) convergence = 0.0; else { diff --git a/lib/btree2/kdtree.c b/lib/btree2/kdtree.c index 54a122033dc..ec0d19e0abc 100644 --- a/lib/btree2/kdtree.c +++ b/lib/btree2/kdtree.c @@ -531,7 +531,7 @@ int kdtree_knn(struct kdtree *t, double *c, int *uid, double *d, int k, if (skip) sn.uid = *skip; - maxdist = 1.0 / 0.0; + maxdist = INFINITY; found = 0; /* go down */ diff --git a/lib/gis/user_config.c b/lib/gis/user_config.c index 4fb23226dcc..b8ef70a90ee 100644 --- a/lib/gis/user_config.c +++ b/lib/gis/user_config.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #ifndef _WIN32 #include #endif diff --git a/lib/iostream/rtimer.cpp b/lib/iostream/rtimer.cpp index b241a531d3e..c0d8a4fd9fc 100644 --- a/lib/iostream/rtimer.cpp +++ b/lib/iostream/rtimer.cpp @@ -44,24 +44,25 @@ #include #endif -// #include #include +#define BUFMAX 256 + char *rt_sprint_safe(char *buf, Rtimer rt) { if (rt_w_useconds(rt) == 0) { - sprintf(buf, "[%4.2fu (%.0f%%) %4.2fs (%.0f%%) %4.2f %.1f%%]", 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0); + snprintf(buf, BUFMAX, "[%4.2fu (%.0f%%) %4.2fs (%.0f%%) %4.2f %.1f%%]", + 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); } else { - sprintf(buf, "[%4.2fu (%.0f%%) %4.2fs (%.0f%%) %4.2f %.1f%%]", - rt_u_useconds(rt) / 1000000, - 100.0 * rt_u_useconds(rt) / rt_w_useconds(rt), - rt_s_useconds(rt) / 1000000, - 100.0 * rt_s_useconds(rt) / rt_w_useconds(rt), - rt_w_useconds(rt) / 1000000, - 100.0 * (rt_u_useconds(rt) + rt_s_useconds(rt)) / - rt_w_useconds(rt)); + snprintf(buf, BUFMAX, "[%4.2fu (%.0f%%) %4.2fs (%.0f%%) %4.2f %.1f%%]", + rt_u_useconds(rt) / 1000000, + 100.0 * rt_u_useconds(rt) / rt_w_useconds(rt), + rt_s_useconds(rt) / 1000000, + 100.0 * rt_s_useconds(rt) / rt_w_useconds(rt), + rt_w_useconds(rt) / 1000000, + 100.0 * (rt_u_useconds(rt) + rt_s_useconds(rt)) / + rt_w_useconds(rt)); } return buf; } diff --git a/lib/raster3d/mask.c b/lib/raster3d/mask.c index 33e5c3c44ee..69e7a498774 100644 --- a/lib/raster3d/mask.c +++ b/lib/raster3d/mask.c @@ -304,12 +304,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 = (char *)tile + length; } - tile += xLength; + tile = (char *)tile + xLength; } - tile += yLength; + tile = (char *)tile + yLength; } } diff --git a/lib/vector/Vlib/box.c b/lib/vector/Vlib/box.c index b68e00cdd8f..49d90ea2cc2 100644 --- a/lib/vector/Vlib/box.c +++ b/lib/vector/Vlib/box.c @@ -247,8 +247,8 @@ int Vect_get_line_box(const struct Map_info *Map, int line, } Line = Plus->Line[line]; - if (Line == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; + if (Line == NULL) { /* dead */ + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = NAN; return 0; } @@ -312,8 +312,8 @@ int Vect_get_area_box(const struct Map_info *Map, int area, Area = Plus->Area[area]; - if (Area == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; + if (Area == NULL) { /* dead */ + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = NAN; return 0; } @@ -359,8 +359,8 @@ int Vect_get_isle_box(const struct Map_info *Map, int isle, Isle = Plus->Isle[isle]; - if (Isle == NULL) { /* dead */ - Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = 0. / 0.; + if (Isle == NULL) { /* dead */ + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = NAN; return 0; } diff --git a/raster/r.horizon/main.c b/raster/r.horizon/main.c index 806dc51068a..c58ec836d97 100644 --- a/raster/r.horizon/main.c +++ b/raster/r.horizon/main.c @@ -746,7 +746,7 @@ double horizon_height(void) { double height; - tanh0 = -1.0 / 0.0; /* -inf */ + tanh0 = 0.; length = 0; height = searching(); diff --git a/raster/r.in.bin/main.c b/raster/r.in.bin/main.c index e5d457b8dc3..08b657746e5 100644 --- a/raster/r.in.bin/main.c +++ b/raster/r.in.bin/main.c @@ -255,7 +255,7 @@ 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 = NAN; 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 e201774b716..344a4d73c5d 100644 --- a/raster/r.in.lidar/info.c +++ b/raster/r.in.lidar/info.c @@ -12,7 +12,7 @@ */ #include - +#include #include #include #include "local_proto.h" @@ -97,7 +97,7 @@ 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; + min_x = max_x = min_y = max_y = min_z = max_z = NAN; 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 9bd255ddd43..39e4e8e79e9 100644 --- a/raster/r.li/r.li.padrange/padrange.c +++ b/raster/r.li/r.li.padrange/padrange.c @@ -308,19 +308,19 @@ int calculate(int fd, struct area_entry *ad, double *result) cell_size_m = (((EW_DIST1 + EW_DIST2) / 2) / hd.cols) * (((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 */ - 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; - if (min > area_p) - min = area_p; - if (max < area_p) - max = area_p; - } - } - *result = max - min; + /* get min and max patch size */ + min = INFINITY; + max = -INFINITY; + 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; + if (min > area_p) + min = area_p; + if (max < area_p) + max = area_p; + } + } + *result = max - min; } else Rast_set_d_null_value(result, 1); @@ -542,19 +542,19 @@ int calculateD(int fd, struct area_entry *ad, double *result) cell_size_m = (((EW_DIST1 + EW_DIST2) / 2) / hd.cols) * (((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 */ - 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; - if (min > area_p) - min = area_p; - if (max < area_p) - max = area_p; - } - } - *result = max - min; + /* get min and max patch size */ + min = INFINITY; + max = -INFINITY; + 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; + if (min > area_p) + min = area_p; + if (max < area_p) + max = area_p; + } + } + *result = max - min; } else Rast_set_d_null_value(result, 1); @@ -776,19 +776,19 @@ int calculateF(int fd, struct area_entry *ad, double *result) cell_size_m = (((EW_DIST1 + EW_DIST2) / 2) / hd.cols) * (((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 */ - 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; - if (min > area_p) - min = area_p; - if (max < area_p) - max = area_p; - } - } - *result = max - min; + /* get min and max patch size */ + min = INFINITY; + max = -INFINITY; + 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; + if (min > area_p) + min = area_p; + if (max < area_p) + max = area_p; + } + } + *result = max - min; } else Rast_set_d_null_value(result, 1); diff --git a/raster/r.out.gdal/main.c b/raster/r.out.gdal/main.c index f647881b0cf..5021c26e9e1 100644 --- a/raster/r.out.gdal/main.c +++ b/raster/r.out.gdal/main.c @@ -1047,11 +1047,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; case GDT_Float64: case GDT_CFloat64: - return 0.0 / 0.0; + return NAN; default: return 0; diff --git a/raster/r.series.accumulate/main.c b/raster/r.series.accumulate/main.c index 0cc6c38958a..2c526c30257 100644 --- a/raster/r.series.accumulate/main.c +++ b/raster/r.series.accumulate/main.c @@ -171,9 +171,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 */ - + lo = -INFINITY; + hi = INFINITY; method = METHOD_GDD; if (G_strncasecmp(parm.method->answer, "gdd", 3) == 0) method = METHOD_GDD; diff --git a/raster/r.terraflow/flow.cpp b/raster/r.terraflow/flow.cpp index 4d9bd0b5d41..e48847052e5 100644 --- a/raster/r.terraflow/flow.cpp +++ b/raster/r.terraflow/flow.cpp @@ -48,26 +48,8 @@ void computeFlowAccumulation(AMI_STREAM *fillStream, Rtimer rt, rtTotal; AMI_STREAM *sweepstr; - rt_start(rtTotal); - assert(fillStream && outstr == NULL); - if (stats) { - stats->comment("------------------------------"); - stats->comment("COMPUTING FLOW ACCUMULATION"); - } - - { /* timestamp stats file and print memory */ - time_t t = time(NULL); - char buf[BUFSIZ]; - if(t == (time_t)-1) { - perror("time"); - exit(1); - } -#ifdef _WIN32 - strcpy(buf, ctime(&t)); -#else - ctime_r(&t, buf); - buf[24] = '\0'; -#endif + rt_start(rtTotal); + assert(fillStream && outstr == NULL); if (stats) { stats->comment("------------------------------"); stats->comment("COMPUTING FLOW ACCUMULATION"); diff --git a/raster/r.univar/r.univar_main.c b/raster/r.univar/r.univar_main.c index 3e351ad0a56..8cb26b5d9ca 100644 --- a/raster/r.univar/r.univar_main.c +++ b/raster/r.univar/r.univar_main.c @@ -170,8 +170,8 @@ 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 */ + zone_info.min = 0; + zone_info.max = 0; zone_info.n_zones = 0; fdz = NULL; diff --git a/raster/r.univar/r3.univar_main.c b/raster/r.univar/r3.univar_main.c index b3efa170dd0..5ad71240bbd 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 */ + dmin = NAN; + dmax = NAN; + zone_info.min = 0; + zone_info.max = 0; 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 0451e370e2c..01126ad022c 100644 --- a/raster/r.univar/stats.c +++ b/raster/r.univar/stats.c @@ -30,8 +30,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; + stats[i].max = NAN; stats[i].n_perc = n_perc; if (n_perc > 0) stats[i].perc = (double *)G_malloc(n_perc * sizeof(double)); @@ -131,7 +131,7 @@ int print_stats(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; sprintf(sum_str, "%.15g", stats[z].sum); G_trim_decimal(sum_str); @@ -190,9 +190,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; for (i = 0; i < stats[z].n_perc; i++) - quartile_perc[i] = 0.0 / 0.0; + quartile_perc[i] = NAN; } else { for (i = 0; i < stats[z].n_perc; i++) { @@ -402,7 +402,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; if (zone_info.n_zones) { int z_cat = z + zone_info.min; @@ -450,9 +450,9 @@ int print_stats_table(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; for (i = 0; i < stats[z].n_perc; i++) - quartile_perc[i] = 0.0 / 0.0; + quartile_perc[i] = NAN; } else { for (i = 0; i < stats[z].n_perc; i++) { diff --git a/raster/r.viewshed/statusstructure.cpp b/raster/r.viewshed/statusstructure.cpp index 05ef41b85d6..921b7bbecae 100644 --- a/raster/r.viewshed/statusstructure.cpp +++ b/raster/r.viewshed/statusstructure.cpp @@ -17,7 +17,7 @@ * considered visible to each other if the cells where they belong are * visible to each other. Two cells are visible to each other if the * line-of-sight that connects their centers does not intersect the - * terrain. The terrain is NOT viewed as a tesselation of flat cells, + * terrain. The terrain is NOT viewed as a tessellation of flat cells, * i.e. if the line-of-sight does not pass through the cell center, * elevation is determined using bilinear interpolation. * The viewshed algorithm is efficient both in @@ -38,6 +38,7 @@ #include #include #include + extern "C" { #include #include @@ -57,7 +58,7 @@ extern "C" { If doCurv is set we need to consider the curvature of the earth */ float get_vertical_angle(Viewpoint vp, StatusNode sn, surface_type elev, - int doCurv) + int doCurv UNUSED) { /*determine the difference in elevation, based on the curvature */ @@ -106,7 +107,9 @@ void calculate_dist_n_gradient(StatusNode *sn, double elev, Viewpoint *vp, //sn->dist2vp = sqrt((float) ( pow(sn->row - vp->row,2.0) + // pow(sn->col - vp->col,2.0))); //sn->gradient = (sn->elev - vp->elev)/(sn->dist2vp); */ + double diffElev = elev - vp->elev; + if (G_projection() == PROJECTION_LL) { double dist = G_distance(Rast_col_to_easting(sn->col + 0.5, &(hd.window)), @@ -146,6 +149,7 @@ void calculate_dist_n_gradient(StatusNode *sn, double elev, Viewpoint *vp, /*maintain sign */ if (elev < vp->elev) sn->gradient[1] = -sn->gradient[1]; + return; } @@ -159,6 +163,7 @@ void calculate_event_gradient(StatusNode *sn, int e_idx, double row, double col, //sn->dist2vp = sqrt((float) ( pow(sn->row - vp->row,2.0) + // pow(sn->col - vp->col,2.0))); //sn->gradient = (sn->elev - vp->elev)/(sn->dist2vp); */ + double diffElev = elev - vp->elev; double dist2vp; diff --git a/raster3d/r3.in.lidar/info.c b/raster3d/r3.in.lidar/info.c index 49912030655..00511aad217 100644 --- a/raster3d/r3.in.lidar/info.c +++ b/raster3d/r3.in.lidar/info.c @@ -13,6 +13,7 @@ */ #include +#include #include @@ -100,7 +101,7 @@ 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; + min_x = max_x = min_y = max_y = min_z = max_z = NAN; G_verbose_message(_("Scanning data ...")); diff --git a/vector/v.cluster/main.c b/vector/v.cluster/main.c index a2b4e37b6e0..470ecb2f942 100644 --- a/vector/v.cluster/main.c +++ b/vector/v.cluster/main.c @@ -256,7 +256,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = 1.0 / 0.0; + min = INFINITY; max = 0; kd = G_malloc(minpnts * sizeof(double)); ki = G_malloc(minpnts * sizeof(int)); @@ -463,7 +463,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = 1.0 / 0.0; + min = INFINITY; 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 3ceff4f9b05..18479f2f0bf 100644 --- a/vector/v.distance/distance.c +++ b/vector/v.distance/distance.c @@ -11,7 +11,7 @@ int get_line_box(const struct line_pnts *Points, struct bound_box *box) int i; if (Points->n_points == 0) { - box->E = box->W = box->N = box->S = box->T = box->B = 0.0 / 0.0; + box->E = box->W = box->N = box->S = box->T = box->B = NAN; return 0; } diff --git a/vector/v.voronoi/skeleton.c b/vector/v.voronoi/skeleton.c index ada3d356a8d..96b19bdc709 100644 --- a/vector/v.voronoi/skeleton.c +++ b/vector/v.voronoi/skeleton.c @@ -528,7 +528,7 @@ int tie_up(void) IPoints[i]); } - distmin = 1. / 0.; /* +inf */ + distmin = INFINITY; xmin = x; ymin = y; From 8c06b7952df50b4d6f09a5d57561137de4c2f965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Sat, 3 Jun 2023 14:05:48 +0200 Subject: [PATCH 34/60] Simplify and use PROJ_H_ --- include/CMakeLists.txt | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 4df77022d3e..381ae23c8b7 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -47,21 +47,7 @@ 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(PROJ HAVE_PROJ_H) check_target(BLAS HAVE_LIBBLAS) check_target(BLAS HAVE_CBLAS_H) From 6b54a06acbc336d34e50f7d4bc98debff0ecf48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Sat, 3 Jun 2023 14:57:10 +0200 Subject: [PATCH 35/60] CMakeLists.txt: add include_irectories to grass --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d571732b37e..617e31ba538 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,6 +154,7 @@ set(NO_HTML_DESCR_TARGETS "g.parser;ximgview;test.raster3d.lib") add_subdirectory(include) include_directories("${CMAKE_BINARY_DIR}/include") +include_directories(${CMAKE_BINARY_DIR}/include/grass) if(MSVC) include_directories("${CMAKE_SOURCE_DIR}/msvc") endif() From 1852e08a7fcf4bf1641423acb34102c3d2fad07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Sat, 3 Jun 2023 15:11:50 +0200 Subject: [PATCH 36/60] raster/CMakeLists.txt: fix GDAL_VERSION --- raster/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raster/CMakeLists.txt b/raster/CMakeLists.txt index b3216cbcda2..dba9b71e3fd 100644 --- a/raster/CMakeLists.txt +++ b/raster/CMakeLists.txt @@ -180,7 +180,7 @@ build_program_in_subdir( 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\"" + "GRASS_VERSION_NUMBER=\"${GRASS_VERSION_NUMBER}\"" ) build_program_in_subdir( From dccaac01300bfa4e0c50e42c984b391e4b22f93b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Sun, 4 Jun 2023 09:37:14 +0200 Subject: [PATCH 37/60] add aprintf.c --- lib/gis/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gis/CMakeLists.txt b/lib/gis/CMakeLists.txt index 48499500c57..2ebd88d8647 100644 --- a/lib/gis/CMakeLists.txt +++ b/lib/gis/CMakeLists.txt @@ -1,5 +1,5 @@ set(gislib_SRCS - adj_cellhd.c + adj_cellhd.c aprintf.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 From c02053fb734ca9b52ba981723d952170952a587d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Sun, 4 Jun 2023 09:37:29 +0200 Subject: [PATCH 38/60] v.neighbors requires grass_stats --- vector/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/CMakeLists.txt b/vector/CMakeLists.txt index b5e3b7b440f..0804fc0b68b 100644 --- a/vector/CMakeLists.txt +++ b/vector/CMakeLists.txt @@ -72,7 +72,7 @@ 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.neighbors DEPENDS grass_gis grass_vector grass_stats) build_program_in_subdir(v.net DEPENDS grass_gis grass_vector) From b2229133402a142456de8bff15e66daf7daa1807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Sun, 4 Jun 2023 10:09:37 +0200 Subject: [PATCH 39/60] ctypesgen.py: main module is not ctypesgen.py but run.py. fix it. --- python/libgrass_interface_generator/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/libgrass_interface_generator/CMakeLists.txt b/python/libgrass_interface_generator/CMakeLists.txt index 698da806f6a..5a78cf3f4b2 100644 --- a/python/libgrass_interface_generator/CMakeLists.txt +++ b/python/libgrass_interface_generator/CMakeLists.txt @@ -67,7 +67,7 @@ foreach(module ${MODULES}) add_custom_command(OUTPUT ${output_file} DEPENDS ${${module}_LIBS} COMMAND ${CMAKE_COMMAND} - -DCTYPESGEN_PY=${CMAKE_CURRENT_SOURCE_DIR}/ctypesgen.py + -DCTYPESGEN_PY=${CMAKE_CURRENT_SOURCE_DIR}/run.py -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} -DCOMPILER=${CMAKE_C_COMPILER} -DBIN_DIR=${GISBASE} From 062b8528632a5643936b20c2242a19154cc9b72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Mon, 5 Jun 2023 10:21:22 +0200 Subject: [PATCH 40/60] lib/rst: fix build. Remove DEFS POINT2D_C --- lib/rst/CMakeLists.txt | 1 - lib/rst/interp_float/point2d.c | 3 --- 2 files changed, 4 deletions(-) diff --git a/lib/rst/CMakeLists.txt b/lib/rst/CMakeLists.txt index 4250dd94dcf..c99042b3917 100644 --- a/lib/rst/CMakeLists.txt +++ b/lib/rst/CMakeLists.txt @@ -15,7 +15,6 @@ build_library_in_subdir(qtree 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/rst/interp_float/point2d.c b/lib/rst/interp_float/point2d.c index db180748d7a..3d1140a5889 100644 --- a/lib/rst/interp_float/point2d.c +++ b/lib/rst/interp_float/point2d.c @@ -30,9 +30,7 @@ #include #include -#ifndef POINT2D_C #define POINT2D_C -#endif #include /* needed for AIX */ @@ -193,6 +191,5 @@ int IL_check_at_points_2d(struct interp_params *params, } } /* cv */ - return 1; } From 075e42ee239be162f82fb174a8eeb8532831d064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Mon, 5 Jun 2023 15:43:56 +0200 Subject: [PATCH 41/60] python: copy grassdb --- python/grass/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/grass/CMakeLists.txt b/python/grass/CMakeLists.txt index ce721e1ce1b..0f159fcfb3c 100644 --- a/python/grass/CMakeLists.txt +++ b/python/grass/CMakeLists.txt @@ -1,6 +1,7 @@ copy_python_files_in_subdir(exceptions etc/python/grass) copy_python_files_in_subdir(gunittest etc/python/grass) +copy_python_files_in_subdir(grassdb 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) @@ -28,7 +29,7 @@ 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/ VERBATIM - DEPENDS python_exceptions python_imaging python_pydispatch python_script python_semantic_label python_temporal + DEPENDS python_exceptions python_grassdb python_imaging python_pydispatch python_script python_semantic_label 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 From 555cdb292a1a57910b28a6cb3a0170ec43d41b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Mon, 5 Jun 2023 15:44:13 +0200 Subject: [PATCH 42/60] propose ccache to speedup build --- CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 617e31ba538..cd1418a98ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,19 @@ if(WIN32) set(default_option_enabled OFF) endif() +# Configure CCache if available +if(NOT MSVC) + option(USE_CCACHE "Use ccache" ON) + if (USE_CCACHE) + find_program(CCACHE_FOUND ccache) + if(CCACHE_FOUND) + set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) + set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) + message(STATUS "ccache found") + endif(CCACHE_FOUND) + endif(USE_CCACHE) +endif(NOT MSVC) + if(CMAKE_BUILD_TYPE) set( grass_build_type "${CMAKE_BUILD_TYPE}" ) string( TOLOWER "${grass_build_type}" grass_build_type_lc ) From 754872d993526354d3b4ff7c11a01856b1943850 Mon Sep 17 00:00:00 2001 From: Aaron Saw Date: Mon, 5 Jun 2023 16:39:14 +0200 Subject: [PATCH 43/60] mkhtml.py depends on a sibling python script This is just a temporary fix. I don't think all of these manual copying is pretty. All instances of resource copying we can probably do better with structuring it in a directory. --- utils/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index af18a2a4f1f..c9834362fd4 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,4 +1,5 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/mkhtml.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/generate_last_commit_file.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) set(current_time_s_ms_SRCS "timer/main.c") if(MSVC) From 9ef6a2bdfed02edea2b02d263957d8a2fe7107dd Mon Sep 17 00:00:00 2001 From: Aaron Saw Date: Mon, 5 Jun 2023 16:39:29 +0200 Subject: [PATCH 44/60] make libraster libvector link with lapack when it is available --- lib/CMakeLists.txt | 4 ++++ lib/vector/CMakeLists.txt | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d3d39cd3105..e844e962096 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -21,6 +21,10 @@ build_library_in_subdir(raster SOURCES ${raster_SRCS} DEPENDS GDAL PROJ grass_gproj) +if(TARGET LAPACK) + target_link_libraries(grass_raster LAPACK) +endif() + if(CMAKE_SYSTEM_NAME MATCHES "Linux") find_library(DL_LIBRARY dl) mark_as_advanced(DL_LIBRARY) diff --git a/lib/vector/CMakeLists.txt b/lib/vector/CMakeLists.txt index 9e17ce093b8..8dd910f8ab5 100644 --- a/lib/vector/CMakeLists.txt +++ b/lib/vector/CMakeLists.txt @@ -18,6 +18,10 @@ if(TARGET POSTGRES) target_link_libraries(grass_vector POSTGRES) endif() +if(TARGET LAPACK) + target_link_libraries(grass_vector LAPACK) +endif() + add_subdirectory(vedit) add_subdirectory(neta) From 161f1f929071f54e5979bc1e5ec810b7ae1ac5b6 Mon Sep 17 00:00:00 2001 From: Aaron Saw Date: Mon, 5 Jun 2023 16:39:41 +0200 Subject: [PATCH 45/60] add the 3 missing raster modules --- .gitignore | 3 +++ raster/CMakeLists.txt | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index 78d4aafe1e3..3f61cb4457b 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,6 @@ test_keyvalue_result.txt # ignore paths generated by helper tools node_modules + +# ignore cmake build directory +build diff --git a/raster/CMakeLists.txt b/raster/CMakeLists.txt index dba9b71e3fd..3b4fdf3e9d2 100644 --- a/raster/CMakeLists.txt +++ b/raster/CMakeLists.txt @@ -2,6 +2,10 @@ build_program_in_subdir( r.basins.fill DEPENDS grass_gis grass_raster ) +build_program_in_subdir( + r.buildvrt + DEPENDS grass_gis grass_raster grass_gmath) + build_program_in_subdir( r.buffer DEPENDS grass_gis grass_raster ) @@ -78,6 +82,10 @@ build_program_in_subdir( r.fill.dir DEPENDS grass_gis grass_raster ) + build_program_in_subdir( + r.fill.stats + DEPENDS grass_gis grass_raster ) + build_program_in_subdir( r.flow DEPENDS grass_gis grass_raster grass_segment grass_vector grass_bitmap) @@ -120,6 +128,13 @@ build_program_in_subdir( r.in.mat DEPENDS grass_gis grass_raster) +file(GLOB r_in_pdal_SOURCES "r.in.pdal/*.c" "r.in.pdal/*.cpp") +build_program_in_subdir( + r.in.pdal + SOURCES "${r_in_pdal_SOURCES}" + DEPENDS grass_gis grass_raster grass_vector grass_gmath grass_segment grass_gproj + PRIMARY_DEPENDS PDAL) + build_program_in_subdir( r.in.png DEPENDS grass_gis grass_raster LIBPNG) From ce13ea129693af54b9344a1d0de943ba9bf0dfab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Mon, 5 Jun 2023 20:23:08 +0200 Subject: [PATCH 46/60] display: add d.rgb, d.rhumbline, d.text, d.title, d.vect.* --- display/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/display/CMakeLists.txt b/display/CMakeLists.txt index fd16882eb2c..5263be47ec6 100644 --- a/display/CMakeLists.txt +++ b/display/CMakeLists.txt @@ -24,4 +24,11 @@ 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.rgb DEPENDS grass_gis grass_display grass_raster) +build_program_in_subdir(d.rhumbline DEPENDS grass_gis grass_display) +build_program_in_subdir(d.text DEPENDS grass_gis grass_display) +build_program_in_subdir(d.title DEPENDS grass_gis grass_display) +build_program_in_subdir(d.vect DEPENDS grass_gis grass_display grass_vector grass_sym) +build_program_in_subdir(d.vect.chart DEPENDS grass_gis grass_display grass_vector grass_sym) +build_program_in_subdir(d.vect.thematic DEPENDS grass_gis grass_display grass_vector grass_sym grass_arraystats) build_program_in_subdir(d.where DEPENDS grass_gis grass_display grass_gproj) From 15418755542b70df08891fb48f22d3a1fa754417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Mon, 5 Jun 2023 21:20:16 +0200 Subject: [PATCH 47/60] raster: enable r3.mapcalc --- raster/r.mapcalc/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/raster/r.mapcalc/CMakeLists.txt b/raster/r.mapcalc/CMakeLists.txt index f360fa3abe4..b5cb74b91b0 100644 --- a/raster/r.mapcalc/CMakeLists.txt +++ b/raster/r.mapcalc/CMakeLists.txt @@ -17,6 +17,6 @@ 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) +build_program(NAME r3.mapcalc + SOURCES "${r3_mapcalc_SRCS}" + DEPENDS grass_gis grass_btree grass_calc grass_raster3d) From 2af6d2e03bc84de763adf0c376270fc69b7a25e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Tue, 6 Jun 2023 07:55:14 +0200 Subject: [PATCH 48/60] raster: enable r.object.geometry --- raster/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/raster/CMakeLists.txt b/raster/CMakeLists.txt index 3b4fdf3e9d2..905104d86aa 100644 --- a/raster/CMakeLists.txt +++ b/raster/CMakeLists.txt @@ -181,6 +181,10 @@ build_program_in_subdir( r.null DEPENDS grass_gis grass_raster) +build_program_in_subdir( + r.object.geometry + DEPENDS grass_gis grass_raster) + build_program_in_subdir( r.out.ascii DEPENDS grass_gis grass_raster) From 1c2b3dda7484d39de08a8f623bfc2f879678ea98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Tue, 6 Jun 2023 07:55:31 +0200 Subject: [PATCH 49/60] ps: enable ps.map --- CMakeLists.txt | 2 +- ps/CMakeLists.txt | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 ps/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index cd1418a98ed..adcf75040cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,7 +206,7 @@ set(ALL_SUBDIRS scripts vector temporal - # ps + ps ) foreach(d ${ALL_SUBDIRS}) diff --git a/ps/CMakeLists.txt b/ps/CMakeLists.txt new file mode 100644 index 00000000000..8b2c821da55 --- /dev/null +++ b/ps/CMakeLists.txt @@ -0,0 +1,4 @@ +build_program_in_subdir( + ps.map + DEPENDS grass_gis grass_raster grass_gmath grass_gproj grass_imagery grass_vector grass_dbmibase grass_sym) + From 028a3235e38518e777a72904c4582f76b64ccafc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Tue, 6 Jun 2023 08:41:45 +0200 Subject: [PATCH 50/60] python/grass: add utils (will be used by g.download.location scripts) --- python/grass/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/grass/CMakeLists.txt b/python/grass/CMakeLists.txt index 0f159fcfb3c..9e17736cae3 100644 --- a/python/grass/CMakeLists.txt +++ b/python/grass/CMakeLists.txt @@ -5,6 +5,7 @@ copy_python_files_in_subdir(grassdb 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(utils etc/python/grass) copy_python_files_in_subdir(semantic_label etc/python/grass) copy_python_files_in_subdir(temporal etc/python/grass) copy_python_files_in_subdir(pygrass etc/python/grass) @@ -30,6 +31,7 @@ add_custom_target(LIB_PYTHON COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/etc/python/grass/script/setup.py ${GISBASE}/etc/python/grass/script/ VERBATIM DEPENDS python_exceptions python_grassdb python_imaging python_pydispatch python_script python_semantic_label python_temporal + python_utils 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 From 1edfee80f4cf0aa11ebb472d326a43c3ce1efc6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Tue, 6 Jun 2023 08:42:11 +0200 Subject: [PATCH 51/60] scripts: add d.background, g.download.location, i.band.library, r.semantic.label --- scripts/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index c45cb51f41e..b1947c6b568 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1,5 +1,6 @@ set(script_DIRS r.shade + d.background d.correlate d.frame d.out.file @@ -17,10 +18,12 @@ set(script_DIRS db.out.ogr db.test db.univar + g.download.location g.extension g.extension.all g.manual g.search.modules + i.band.library i.colors.enhance i.image.mosaic i.in.spotvgt @@ -43,6 +46,7 @@ set(script_DIRS r.plane r.reclass.area r.rgb + r.semantic.label r.tileset r.unpack r3.in.xyz From 6a12d3a54be93575a1c877c11c02adcbfa63d433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Tue, 6 Jun 2023 09:15:59 +0200 Subject: [PATCH 52/60] temporal: add t.copy and t.upgrade --- temporal/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/temporal/CMakeLists.txt b/temporal/CMakeLists.txt index 22f03ce97c7..891c9fce1dc 100644 --- a/temporal/CMakeLists.txt +++ b/temporal/CMakeLists.txt @@ -1,10 +1,12 @@ set(temporal_DIRS t.create + t.copy t.support t.topology t.list t.info t.merge + t.upgrade t.remove t.sample t.register From 0f90e778bd95d8558cb52938a8aa3506675888f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Tue, 6 Jun 2023 11:10:29 +0200 Subject: [PATCH 53/60] add an optional cmake to use alternate linker --- CMakeLists.txt | 4 ++++ cmake/modules/linker.cmake | 42 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 cmake/modules/linker.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index adcf75040cf..e0a74abcde9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,10 @@ if(NOT MSVC) endif(USE_CCACHE) endif(NOT MSVC) +if(USE_ALTERNATE_LINKER) + include("cmake/modules/linker.cmake") +endif() + if(CMAKE_BUILD_TYPE) set( grass_build_type "${CMAKE_BUILD_TYPE}" ) string( TOLOWER "${grass_build_type}" grass_build_type_lc ) diff --git a/cmake/modules/linker.cmake b/cmake/modules/linker.cmake new file mode 100644 index 00000000000..7e093ae241a --- /dev/null +++ b/cmake/modules/linker.cmake @@ -0,0 +1,42 @@ +macro(set_alternate_linker linker) + if( NOT "${USE_ALTERNATE_LINKER}" STREQUAL "${USE_ALTERNATE_LINKER_OLD_CACHED}" ) + unset(LINKER_EXECUTABLE CACHE) + endif() + find_program(LINKER_EXECUTABLE ld.${USE_ALTERNATE_LINKER} ${USE_ALTERNATE_LINKER}) + if(LINKER_EXECUTABLE) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if( "${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER_EQUAL 12.0.0) + add_link_options("--ld-path=${LINKER_EXECUTABLE}") + else() + add_link_options("-fuse-ld=${LINKER_EXECUTABLE}") + endif() + elseif( "${linker}" STREQUAL "mold" AND + "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND + "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 12.1.0) + # GCC before 12.1.0: -fuse-ld does not accept mold as a valid argument, + # so you need to use -B option instead. + get_filename_component(_dir ${LINKER_EXECUTABLE} DIRECTORY) + get_filename_component(_dir ${_dir} DIRECTORY) + if( EXISTS "${_dir}/libexec/mold/ld" ) + add_link_options(-B "${_dir}/libexec/mold") + else() + message(FATAL_ERROR "Cannot find ${_dir}/libexec/mold/ld") + endif() + else() + add_link_options("-fuse-ld=${USE_ALTERNATE_LINKER}") + endif() + message(STATUS "Using alternative linker: ${LINKER_EXECUTABLE}") + else() + message(FATAL_ERROR "Cannot find alternative linker ${USE_ALTERNATE_LINKER}") + endif() +endmacro() + +if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) + set(USE_ALTERNATE_LINKER "" CACHE STRING "Use alternate linker. Leave empty for system default; potential alternatives are 'gold', 'lld', 'bfd', 'mold'") + if(NOT "${USE_ALTERNATE_LINKER}" STREQUAL "") + set_alternate_linker(${USE_ALTERNATE_LINKER}) + endif() + set(USE_ALTERNATE_LINKER_OLD_CACHED + ${USE_ALTERNATE_LINKER} + CACHE INTERNAL "Previous value of USE_ALTERNATE_LINKER") +endif() From ce7424865bd3fbe3575f98123849bade8bd42699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Tue, 6 Jun 2023 12:17:54 +0200 Subject: [PATCH 54/60] gui/wxpython: copy main_window dir --- gui/wxpython/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gui/wxpython/CMakeLists.txt b/gui/wxpython/CMakeLists.txt index 0f8944d97a5..54339b70b61 100644 --- a/gui/wxpython/CMakeLists.txt +++ b/gui/wxpython/CMakeLists.txt @@ -3,7 +3,7 @@ set(WXPYTHON_DIR ${GISBASE}/gui/wxpython) -set(gui_lib_DIRS core gui_core icons iscatt lmgr location_wizard +set(gui_lib_DIRS core gui_core icons iscatt lmgr location_wizard main_window mapdisp mapwin modules nviz rdigit startup tools vnet web_services wxplot) set(gui_lib_targets) From 31b53b5bf77cf2e55fbae0b4454360012fc9ea03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Bartoletti?= Date: Tue, 6 Jun 2023 13:04:58 +0200 Subject: [PATCH 55/60] init: copy lock, echo, run, clean_temp and winlocale --- lib/init/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/init/CMakeLists.txt b/lib/init/CMakeLists.txt index d452b5c4329..8c86ff83c13 100644 --- a/lib/init/CMakeLists.txt +++ b/lib/init/CMakeLists.txt @@ -169,3 +169,10 @@ 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) +install(FILES ${CMAKE_BINARY_DIR}/gisbase/etc/lock DESTINATION etc) +install(FILES ${CMAKE_BINARY_DIR}/gisbase/etc/echo DESTINATION etc) +install(FILES ${CMAKE_BINARY_DIR}/gisbase/etc/run DESTINATION etc) +install(FILES ${CMAKE_BINARY_DIR}/gisbase/etc/clean_temp DESTINATION etc) +if(MINGW) +install(FILES ${CMAKE_BINARY_DIR}/gisbase/etc/winlocale DESTINATION etc) +endif() From 3d61178a50430cd23982ee438b4ca427f5936cc7 Mon Sep 17 00:00:00 2001 From: Huidae Cho Date: Wed, 17 Apr 2024 22:54:59 -0600 Subject: [PATCH 56/60] Fix finding Python3 package --- lib/init/CMakeLists.txt | 3 ++- thirdparty/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/init/CMakeLists.txt b/lib/init/CMakeLists.txt index 8c86ff83c13..51bb1e8f119 100644 --- a/lib/init/CMakeLists.txt +++ b/lib/init/CMakeLists.txt @@ -51,7 +51,8 @@ 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) +find_package(Python3 REQUIRED) +file(TO_NATIVE_PATH ${Python3_EXECUTABLE} GRASS_PYTHON) # For install tree (first do install tree) if(UNIX OR MINGW) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index e60264360f7..39ec2fda963 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -176,5 +176,5 @@ endif() # find_package (PythonLibs REQUIRED ) set(Python_ADDITIONAL_VERSIONS 3.5 3.6) -find_package (PythonInterp REQUIRED ) +find_package (Python3 REQUIRED ) # find_package ( Numpy ) From 0b0cebf7c6da3ba8366ad59639833d6cdc6b9e77 Mon Sep 17 00:00:00 2001 From: Huidae Cho Date: Wed, 17 Apr 2024 22:56:33 -0600 Subject: [PATCH 57/60] Fix a SQLite warning --- cmake/find_scripts/FindSQLite.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/find_scripts/FindSQLite.cmake b/cmake/find_scripts/FindSQLite.cmake index c49858c4ef7..3c00d7338ec 100644 --- a/cmake/find_scripts/FindSQLite.cmake +++ b/cmake/find_scripts/FindSQLite.cmake @@ -5,4 +5,4 @@ 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) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLite REQUIRED_VARS SQLITE_LIBRARY SQLITE_INCLUDE_DIR) From 8f2422185afe1f47eefecad38e21e53ff0a92119 Mon Sep 17 00:00:00 2001 From: Huidae Cho Date: Wed, 17 Apr 2024 23:58:43 -0600 Subject: [PATCH 58/60] Define global PYTHON_EXECUTABLE --- lib/init/CMakeLists.txt | 3 +-- thirdparty/CMakeLists.txt | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/init/CMakeLists.txt b/lib/init/CMakeLists.txt index 51bb1e8f119..8c86ff83c13 100644 --- a/lib/init/CMakeLists.txt +++ b/lib/init/CMakeLists.txt @@ -51,8 +51,7 @@ 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}) -find_package(Python3 REQUIRED) -file(TO_NATIVE_PATH ${Python3_EXECUTABLE} GRASS_PYTHON) +file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} GRASS_PYTHON) # For install tree (first do install tree) if(UNIX OR MINGW) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index 39ec2fda963..61cd98b4d22 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -176,5 +176,6 @@ endif() # find_package (PythonLibs REQUIRED ) set(Python_ADDITIONAL_VERSIONS 3.5 3.6) -find_package (Python3 REQUIRED ) +find_package (Python3 REQUIRED) +set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE} PARENT_SCOPE) # find_package ( Numpy ) From 8aec114dc1314393bd09e5fb286292236b10c674 Mon Sep 17 00:00:00 2001 From: Huidae Cho Date: Thu, 18 Apr 2024 01:54:46 -0600 Subject: [PATCH 59/60] Shared library versioning and symlinks following a common practice (version, soversion, symlink) --- cmake/modules/build_module.cmake | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmake/modules/build_module.cmake b/cmake/modules/build_module.cmake index 0110a94b471..20a29e66491 100644 --- a/cmake/modules/build_module.cmake +++ b/cmake/modules/build_module.cmake @@ -76,8 +76,7 @@ function(build_module) 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_target_properties (${G_NAME} PROPERTIES FOLDER lib VERSION ${GRASS_VERSION_NUMBER} SOVERSION ${GRASS_VERSION_MAJOR}) 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}) From f68990365bc4fb3ea591255565d3d2e5ea328e26 Mon Sep 17 00:00:00 2001 From: Huidae Cho Date: Thu, 18 Apr 2024 02:17:12 -0600 Subject: [PATCH 60/60] Rename grass.sh to grass and set 755 permissions --- lib/init/CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/init/CMakeLists.txt b/lib/init/CMakeLists.txt index 8c86ff83c13..c926dbc5075 100644 --- a/lib/init/CMakeLists.txt +++ b/lib/init/CMakeLists.txt @@ -7,8 +7,10 @@ file(GLOB init_HTMLFILES "*.html") set(START_UP "grass${GRASS_VERSION_MAJOR}${GRASS_VERSION_MINOR}.py") if(WIN32) set(script_file_name "grass.bat") +set(script_input_file_name ${script_file_name}.in) else() -set(script_file_name "grass.sh") +set(script_file_name "grass") +set(script_input_file_name ${script_file_name}.sh.in) endif() file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR}/bin BINARY_DIR) @@ -88,15 +90,18 @@ endif() 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) +#configure and install grass wrapper script (grass.bat or grass) +configure_file(${script_input_file_name} ${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) +configure_file(${script_input_file_name} ${GISBASE}/${script_file_name} @ONLY) +if(UNIX OR MINGW) + file(CHMOD ${GISBASE}/${script_file_name} FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +endif() file(COPY ${CMAKE_SOURCE_DIR}/demolocation/PERMANENT DESTINATION ${GISBASE}/demolocation/) configure_file(${CMAKE_SOURCE_DIR}/demolocation/grassrc.cmake.in