From 616be6a32abb42e15053c01190034e379a157699 Mon Sep 17 00:00:00 2001 From: Rashad Kanavath Date: Sun, 11 Jun 2017 21:52:19 +0200 Subject: [PATCH 01/32] 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 | 10 +- include/grass/iostream/rtimer.h | 5 +- lib/CMakeLists.txt | 163 ++++++ lib/btree2/kdtree.c | 2 +- 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 | 6 +- 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 | 10 +- 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 | 10 +- lib/gis/user_config.c | 4 +- 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 | 7 +- lib/manage/sighold.c | 2 +- lib/pngdriver/graph_close.c | 4 +- lib/pngdriver/graph_set.c | 4 +- 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 | 6 +- 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 | 3 +- 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 | 12 +- raster/r.mapcalc/CMakeLists.txt | 22 + raster/r.out.gdal/main.c | 4 +- raster/r.series.accumulate/main.c | 4 +- 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 | 3 + raster/r.terraflow/flow.cpp | 2 +- raster/r.terraflow/main.cpp | 2 +- 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 | 8 +- raster/r.univar/stats.c | 16 +- raster/r.viewshed/statusstructure.cpp | 1 - raster/r.watershed/CMakeLists.txt | 11 + raster3d/CMakeLists.txt | 97 ++++ raster3d/r3.flow/CMakeLists.txt | 14 + raster3d/r3.in.lidar/info.c | 3 +- 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 + vector/v.voronoi/skeleton.c | 2 +- 162 files changed, 5564 insertions(+), 136 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 312e31c498d..447ad4caa74 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 4dec5e4e458..91f46a2e3d5 100644 --- a/general/g.region/printwindow.c +++ b/general/g.region/printwindow.c @@ -468,7 +468,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 = 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 c429e83311c..8c562c1d501 100644 --- a/include/grass/calc.h +++ b/include/grass/calc.h @@ -34,12 +34,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 fb7321f051e..a695b372056 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); @@ -507,7 +509,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 c85c3ddc651..92d934ae8be 100644 --- a/include/grass/iostream/mm.h +++ b/include/grass/iostream/mm.h @@ -84,11 +84,15 @@ enum MM_stream_usage { }; - +#ifdef GRASS_CMAKE_BUILD +#include +#else +#define GRASS_IOSTREAM_EXPORT +#endif // Declarations of a very simple memory manager designed to work with // BTEs that rely on the underlying OS to manage physical memory. -class MM_register { +class GRASS_IOSTREAM_EXPORT MM_register { private: // The number of instances of this class and descendents that exist. static int instances; @@ -170,7 +174,7 @@ static mm_register_init source_file_mm_register_init; // Here is the single memory management object (defined in mm.C). -extern MM_register MM_manager; +extern GRASS_IOSTREAM_EXPORT MM_register MM_manager; diff --git a/include/grass/iostream/rtimer.h b/include/grass/iostream/rtimer.h index a65fd38650b..9104bb792d9 100644 --- a/include/grass/iostream/rtimer.h +++ b/include/grass/iostream/rtimer.h @@ -38,13 +38,14 @@ #ifndef RTIMER_H #define RTIMER_H -#ifdef __MINGW32__ +#ifdef _WIN32 #include #include #include +#ifdef __MINGW32__ #include - +#endif typedef struct { time_t tv1, tv2; } Rtimer; diff --git a/lib/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/btree2/kdtree.c b/lib/btree2/kdtree.c index 6f8c54a630a..533b11842cc 100644 --- a/lib/btree2/kdtree.c +++ b/lib/btree2/kdtree.c @@ -524,7 +524,7 @@ int kdtree_knn(struct kdtree *t, double *c, int *uid, double *d, int k, if (skip) sn.uid = *skip; - maxdist = 1.0 / 0.0; + maxdist = INFINITY; found = 0; /* go down */ diff --git a/lib/cairodriver/graph.c b/lib/cairodriver/graph.c index 4e3d0fe3bcd..256307d183e 100644 --- a/lib/cairodriver/graph.c +++ b/lib/cairodriver/graph.c @@ -29,7 +29,7 @@ #endif #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #include #include @@ -405,7 +405,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 21178d490f7..6f0551b47b3 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 f7c08547df5..ed40eb04373 100644 --- a/lib/calc/calc.c +++ b/lib/calc/calc.c @@ -21,7 +21,7 @@ static void handle_fpe(int n) void pre_exec(void) { -#ifndef __MINGW32__ +#ifndef _WIN32 #ifdef SIGFPE struct sigaction act; @@ -38,7 +38,7 @@ void pre_exec(void) void post_exec(void) { -#ifndef __MINGW32__ +#ifndef _WIN32 #ifdef SIGFPE struct sigaction act; diff --git a/lib/db/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 0fefca29b8d..84d72ecff6a 100644 --- a/lib/db/dbmi_base/dbmscap.c +++ b/lib/db/dbmi_base/dbmscap.c @@ -158,7 +158,7 @@ dbDbmscap *db_read_dbmscap(void) /* START OF NEW CODE FOR SEARCH IN $(GISBASE)/driver/db/ */ /* opend db drivers directory */ -#ifdef __MINGW32__ +#ifdef _WIN32 dirpath = G_malloc(strlen("\\driver\\db\\") + strlen(G_gisbase()) + 1); sprintf(dirpath, "%s\\driver\\db\\", G_gisbase()); G_convert_dirseps_to_host(dirpath); @@ -182,7 +182,7 @@ dbDbmscap *db_read_dbmscap(void) || (strcmp(ent->d_name, "..") == 0)) continue; -#ifdef __MINGW32__ +#ifdef _WIN32 /* skip manifest files on Windows */ if (strstr(ent->d_name, ".manifest")) continue; @@ -191,7 +191,7 @@ dbDbmscap *db_read_dbmscap(void) /* Remove '.exe' from name (windows extension) */ name = G_str_replace(ent->d_name, ".exe", ""); -#ifdef __MINGW32__ +#ifdef _WIN32 dirpath = G_malloc(strlen("\\driver\\db\\") + strlen(G_gisbase()) + strlen(ent->d_name) + 1); sprintf(dirpath, "%s\\driver\\db\\%s", G_gisbase(), ent->d_name); diff --git a/lib/db/dbmi_base/dirent.c b/lib/db/dbmi_base/dirent.c index 00ab1f7a268..a5a2937c0c5 100644 --- a/lib/db/dbmi_base/dirent.c +++ b/lib/db/dbmi_base/dirent.c @@ -18,6 +18,7 @@ #include /* NOTE: these should come from or from */ #ifndef R_OK +#if !defined(HAVE_UNISTD_H) #define R_OK 4 #endif #ifndef W_OK @@ -26,6 +27,7 @@ #ifndef X_OK #define X_OK 1 #endif +#endif #include #ifdef USE_DIRECT diff --git a/lib/db/dbmi_base/login.c b/lib/db/dbmi_base/login.c index 7e7433c8710..1fbb79bab49 100644 --- a/lib/db/dbmi_base/login.c +++ b/lib/db/dbmi_base/login.c @@ -168,8 +168,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 f1f3ca37030..e43ee226a6f 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); @@ -130,7 +130,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 6bc1263efce..0c6ffa5710a 100644 --- a/lib/dspf/viz.h +++ b/lib/dspf/viz.h @@ -97,5 +97,9 @@ int print_head_info(file_info *); /* struct_copy.c */ int struct_copy(char *, char *, int); - -extern CELL_ENTRY cell_table[]; +#ifdef GRASS_CMAKE_BUILD +#include +#else +#define GRASS_DSPF_EXPORT +#endif +extern GRASS_DSPF_EXPORT CELL_ENTRY cell_table[]; diff --git a/lib/external/ccmath/ccmath.h b/lib/external/ccmath/ccmath.h index ad2b0a1f0ef..dec8176a557 100644 --- a/lib/external/ccmath/ccmath.h +++ b/lib/external/ccmath/ccmath.h @@ -33,13 +33,21 @@ #endif /* Complex Types */ - #ifndef CPX +#ifndef _MSC_VER struct complex { double re, im; }; typedef struct complex Cpx; +#else +/* _MSVC has complex struct and cannot be used */ +struct gcomplex +{ + double re, im; +}; +typedef struct gcomplex Cpx; +#endif /* _MSC_VER */ #define CPX 1 #endif 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 202d92068b6..4418df46d9f 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 83ae902a316..d9ab99d4d0d 100644 --- a/lib/gis/ls_filter.c +++ b/lib/gis/ls_filter.c @@ -13,10 +13,13 @@ #include #include - #ifdef HAVE_REGEX_H - #include +#endif + +#ifdef HAVE_PCRE_H +#include +#endif struct buffer { @@ -144,14 +147,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, REG_NOSUB | @@ -167,12 +197,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); @@ -180,21 +256,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 c02a8d3be1f..5d6229337d9 100644 --- a/lib/gis/mapset_msc.c +++ b/lib/gis/mapset_msc.c @@ -261,7 +261,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 cf72b756d47..003da4ea5c7 100644 --- a/lib/gis/parser_interface.c +++ b/lib/gis/parser_interface.c @@ -106,16 +106,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 829bf6b98f5..a36280f3b1e 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 f3cf70a796f..08a20efe2bc 100644 --- a/lib/gis/popen.c +++ b/lib/gis/popen.c @@ -6,7 +6,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #include #define pipe(fds) _pipe(fds, 4096, O_BINARY|O_NOINHERIT) diff --git a/lib/gis/sleep.c b/lib/gis/sleep.c index 1a5e2a07ae0..2f3bdce969c 100644 --- a/lib/gis/sleep.c +++ b/lib/gis/sleep.c @@ -1,8 +1,8 @@ #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #endif -#ifdef __MINGW32__ +#ifdef _WIN32 #include #endif #include @@ -10,7 +10,7 @@ /* Sleep */ void G_sleep(unsigned int seconds) { -#ifdef __MINGW32__ +#ifdef _WIN32 /* note: Sleep() cannot be interrupted */ Sleep((seconds) * 1000); #else diff --git a/lib/gis/spawn.c b/lib/gis/spawn.c index cc3cec9e3d1..1e29f44c5c2 100644 --- a/lib/gis/spawn.c +++ b/lib/gis/spawn.c @@ -24,7 +24,7 @@ #include #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #else #include @@ -72,7 +72,7 @@ struct signal int action; int signum; int valid; -#ifndef __MINGW32__ +#ifndef _WIN32 struct sigaction old_act; sigset_t old_mask; #endif @@ -101,7 +101,7 @@ struct spawn static void parse_arglist(struct spawn *sp, va_list va); static void parse_argvec(struct spawn *sp, const char **va); -#ifdef __MINGW32__ +#ifdef _WIN32 struct buffer { @@ -955,7 +955,7 @@ int G_spawn(const char *command, ...) va_end(va); status = G_spawn_ex(command, -#ifndef __MINGW32__ +#ifndef _WIN32 SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGINT, SF_SIGNAL, SST_PRE, SSA_IGNORE, SIGQUIT, SF_SIGNAL, SST_PRE, SSA_BLOCK, SIGCHLD, @@ -967,7 +967,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 6892ea5e8ec..15ec649fe2e 100644 --- a/lib/gis/user_config.c +++ b/lib/gis/user_config.c @@ -31,7 +31,7 @@ #include #include #include -#ifndef __MINGW32__ +#ifndef _WIN32 #include #endif #include @@ -46,7 +46,7 @@ * path [caller must G_free ()] on success, or NULL on failure *************************************************************************/ -#ifndef __MINGW32__ /* TODO */ +#ifndef _WIN32 /* TODO */ static char *_make_toplevel(void) { size_t len; diff --git a/lib/gis/whoami.c b/lib/gis/whoami.c index 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 0ee51251f0e..3d3afebc254 100644 --- a/lib/imagery/iscatt_core.c +++ b/lib/imagery/iscatt_core.c @@ -699,7 +699,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 ef723b33cb6..f7d3a87546f 100644 --- a/lib/init/clean_temp.c +++ b/lib/init/clean_temp.c @@ -35,7 +35,6 @@ #define SLEEP 30 /* 30 seconds */ /* Recursively scan the directory pathname, removing directory and files */ - void clean_dir(const char *pathname, uid_t uid, pid_t pid, time_t now, int max_age) { @@ -138,7 +137,7 @@ int main(int argc, char *argv[]) G_file_name(tmppath, element, "", mapset = G_mapset()); /* get user id and current time in seconds */ -#ifdef __MINGW32__ +#ifdef _WIN32 /* TODO */ uid = -1; #else @@ -170,7 +169,7 @@ int main(int argc, char *argv[]) int find_process(int pid) { -#ifdef __MINGW32__ +#ifdef _WIN32 /* TODO */ return -1; #else diff --git a/lib/init/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 be540b341aa..79b57c35a53 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 dbc24e2f973..425fb193b68 100644 --- a/lib/init/run.c +++ b/lib/init/run.c @@ -23,7 +23,7 @@ the user's shell to re-activate interrupts in shell-ese. int main(int argc, char *argv[]) { signal(SIGINT, SIG_DFL); -#ifndef __MINGW32__ +#ifndef _WIN32 signal(SIGQUIT, SIG_DFL); #endif diff --git a/lib/iostream/rtimer.cpp b/lib/iostream/rtimer.cpp index e7041ee3d33..e59db17674e 100644 --- a/lib/iostream/rtimer.cpp +++ b/lib/iostream/rtimer.cpp @@ -33,11 +33,16 @@ * General Public License for more details. * * **************************************************************************/ - +#if !defined(_MSC_VER) #include +#endif + #include #include + +#if !defined(_MSC_VER) #include +#endif //#include #include diff --git a/lib/manage/sighold.c b/lib/manage/sighold.c index 17f9cf87265..c340aa7387e 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 7f69225ba00..75b72448011 100644 --- a/lib/pngdriver/graph_set.c +++ b/lib/pngdriver/graph_set.c @@ -18,7 +18,7 @@ #include #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include @@ -41,7 +41,7 @@ static void map_file(void) if (fd < 0) return; -#ifdef __MINGW32__ +#ifdef _WIN32 png.handle = CreateFileMapping((HANDLE) _get_osfhandle(fd), NULL, PAGE_READWRITE, 0, size, NULL); if (!png.handle) diff --git a/lib/pngdriver/pngdriver.h b/lib/pngdriver/pngdriver.h index 2d3d54f7dcf..fbc7ef08591 100644 --- a/lib/pngdriver/pngdriver.h +++ b/lib/pngdriver/pngdriver.h @@ -16,7 +16,7 @@ #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #endif @@ -35,7 +35,7 @@ struct png_state int true_color; int has_alpha; int mapped; -#ifdef __MINGW32__ +#ifdef _WIN32 HANDLE handle; #endif diff --git a/lib/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 863164e81a1..38755ffe8b3 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 37d99cd7eb8..44b2ee7cae2 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 0bbf8e57617..5bd00745d2b 100644 --- a/lib/raster3d/mask.c +++ b/lib/raster3d/mask.c @@ -311,12 +311,12 @@ void Rast3d_mask_tile(RASTER3D_Map * map, int tileIndex, void *tile, int type) for (dy = y; dy < rows; dy++) { for (dx = x; dx < cols; dx++) { RASTER3D_MASKNUM(map, dx, dy, dz, tile, type); - tile += length; + tile = (int*)tile + length; } - tile += xLength; + tile = (int*) + xLength; } - tile += yLength; + tile = (int*) + yLength; } } diff --git a/lib/raster3d/test/test_raster3d_lib.h b/lib/raster3d/test/test_raster3d_lib.h index d71cd0edcfb..4c25e9526f9 100644 --- a/lib/raster3d/test/test_raster3d_lib.h +++ b/lib/raster3d/test/test_raster3d_lib.h @@ -21,8 +21,11 @@ #include #include #include +#ifdef HAVE_SYS_TIME_H #include - +#else +#include +#endif double compute_time_difference(struct timeval, struct timeval); int unit_test_coordinate_transform(void); int unit_test_put_get_value(void); diff --git a/lib/raster3d/test/test_tools.c b/lib/raster3d/test/test_tools.c index 300ebbdca5b..6560fe2dc30 100644 --- a/lib/raster3d/test/test_tools.c +++ b/lib/raster3d/test/test_tools.c @@ -20,6 +20,9 @@ #include #include #include "test_raster3d_lib.h" +#ifdef _MSC_VER + #include +#endif /* *************************************************************** */ /* Compute the difference between two time steps ***************** */ 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 2c737115c8e..4513b49b56b 100644 --- a/lib/rst/interp_float/point2d.c +++ b/lib/rst/interp_float/point2d.c @@ -31,7 +31,9 @@ #include #include -#define POINT2D_C +#ifndef POINT2D_C +#define POINT2D_C 1 +#endif #include /* needed for AIX */ 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 ae84d4adc3b..550da1af652 100644 --- a/lib/vector/Vlib/box.c +++ b/lib/vector/Vlib/box.c @@ -253,7 +253,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 = 0. / 0.; + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; return 0; } @@ -319,7 +319,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 = 0. / 0.; + Box->N = Box->S = Box->E = Box->W = Box->T = Box->B = INFINITY; return 0; } @@ -366,7 +366,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 = 0. / 0.; + 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 fc040ef6c3a..f856ae13a01 100644 --- a/raster/r.horizon/main.c +++ b/raster/r.horizon/main.c @@ -766,7 +766,7 @@ double horizon_height(void) { double height; - tanh0 = -1.0 / 0.0; /* -inf */ + tanh0 = -INFINITY; length = 0; height = searching(); diff --git a/raster/r.in.bin/main.c b/raster/r.in.bin/main.c index 2a2d6e5ee44..d8aab3f74b3 100644 --- a/raster/r.in.bin/main.c +++ b/raster/r.in.bin/main.c @@ -259,7 +259,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 = 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 11d5dc36377..437a6129cf8 100644 --- a/raster/r.in.lidar/info.c +++ b/raster/r.in.lidar/info.c @@ -12,6 +12,7 @@ */ #include +#include /* For INIFINITY */ #include @@ -103,7 +104,7 @@ int scan_bounds(LASReaderH LAS_reader, int shell_style, int extents, 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 = 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 3a96a984ebd..b754e2ba534 100644 --- a/raster/r.in.lidar/point_binning.c +++ b/raster/r.in.lidar/point_binning.c @@ -437,7 +437,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; @@ -492,7 +492,7 @@ void write_percentile(struct BinIndex *bin_index, void *raster_row, if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -547,7 +547,7 @@ void write_skewness(struct BinIndex *bin_index, void *raster_row, if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; /* count */ @@ -603,7 +603,7 @@ void write_trimmean(struct BinIndex *bin_index, void *raster_row, if (Rast_is_null_value(index_array + n_offset, CELL_TYPE)) /* no points in cell */ Rast_set_null_value(ptr, 1, rtype); else { - head_id = Rast_get_c_value(index_array + n_offset, CELL_TYPE); + head_id = Rast_get_c_value((CELL*)index_array + n_offset, CELL_TYPE); node_id = head_id; n = 0; @@ -695,9 +695,9 @@ void write_values(struct PointBinning *point_binning, 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)); } @@ -713,7 +713,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); @@ -766,12 +766,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 688ee2ae929..ec2794fca51 100644 --- a/raster/r.li/r.li.daemon/daemon.c +++ b/raster/r.li/r.li.daemon/daemon.c @@ -24,7 +24,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include diff --git a/raster/r.li/r.li.daemon/worker.c b/raster/r.li/r.li.daemon/worker.c index eec45494452..1768b2fcfbd 100644 --- a/raster/r.li/r.li.daemon/worker.c +++ b/raster/r.li/r.li.daemon/worker.c @@ -23,7 +23,7 @@ #include #include -#ifdef __MINGW32__ +#ifdef _WIN32 #include #else #include diff --git a/raster/r.li/r.li.padrange/padrange.c b/raster/r.li/r.li.padrange/padrange.c index 9c38c3eaa17..56aa59e3909 100644 --- a/raster/r.li/r.li.padrange/padrange.c +++ b/raster/r.li/r.li.padrange/padrange.c @@ -315,8 +315,8 @@ int calculate(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = 1.0 / 0.0; /* inf */ - max = -1.0 / 0.0; /* -inf */ + 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; @@ -551,8 +551,8 @@ int calculateD(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = 1.0 / 0.0; /* inf */ - max = -1.0 / 0.0; /* -inf */ + 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; @@ -787,8 +787,8 @@ int calculateF(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = 1.0 / 0.0; /* inf */ - max = -1.0 / 0.0; /* -inf */ + 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; 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 bf8f9726a80..33c6c046fa8 100644 --- a/raster/r.out.gdal/main.c +++ b/raster/r.out.gdal/main.c @@ -1040,11 +1040,11 @@ double set_default_nodata_value(GDALDataType datatype, double min, double max) case GDT_Float32: case GDT_CFloat32: - return 0.0 / 0.0; + return INFINITY; case GDT_Float64: case GDT_CFloat64: - return 0.0 / 0.0; + return INFINITY; default: return 0; diff --git a/raster/r.series.accumulate/main.c b/raster/r.series.accumulate/main.c index e3e79257fc6..4513d764135 100644 --- a/raster/r.series.accumulate/main.c +++ b/raster/r.series.accumulate/main.c @@ -174,8 +174,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) 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 10f73319496..16b2074ad81 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 fe7da9e530c..03011d854d6 100644 --- a/raster/r.terraflow/common.cpp +++ b/raster/r.terraflow/common.cpp @@ -23,7 +23,7 @@ #endif #include -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined (_MSC_VER) #include #else #include diff --git a/raster/r.terraflow/direction.h b/raster/r.terraflow/direction.h index 7a2f53b2555..5b293896168 100644 --- a/raster/r.terraflow/direction.h +++ b/raster/r.terraflow/direction.h @@ -22,7 +22,7 @@ #include -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1) || defined(_MSC_VER) #include #else #include diff --git a/raster/r.terraflow/filldepr.cpp b/raster/r.terraflow/filldepr.cpp index 15767c2b2d4..928b0017a30 100644 --- a/raster/r.terraflow/filldepr.cpp +++ b/raster/r.terraflow/filldepr.cpp @@ -22,6 +22,9 @@ #include "unionFind.h" #include "common.h" +#ifdef _MSC_VER +#pragma warning(default:4716) +#endif #define FLOOD_DEBUG if(0) /************************************************************/ diff --git a/raster/r.terraflow/flow.cpp b/raster/r.terraflow/flow.cpp index 20cc9a9aac7..f86c4b82795 100644 --- a/raster/r.terraflow/flow.cpp +++ b/raster/r.terraflow/flow.cpp @@ -66,7 +66,7 @@ computeFlowAccumulation(AMI_STREAM* fillStream, perror("time"); exit(1); } -#ifdef __MINGW32__ +#ifdef _WIN32 strcpy(buf, ctime(&t)); #else ctime_r(&t, buf); diff --git a/raster/r.terraflow/main.cpp b/raster/r.terraflow/main.cpp index a7bb7ed7fe9..dbc20f6cce5 100644 --- a/raster/r.terraflow/main.cpp +++ b/raster/r.terraflow/main.cpp @@ -295,7 +295,7 @@ void record_args(int argc, char **argv) { exit(1); } -#ifdef __MINGW32__ +#ifdef _WIN32 strcpy(buf, ctime(&t)); #else ctime_r(&t, buf); diff --git a/raster/r.terraflow/stats.cpp b/raster/r.terraflow/stats.cpp index aabf1d744e6..402fa25423c 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 d8ef386a21f..aa9fcd9d0d0 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 bf267fb54cc..870c74fd87c 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 436e2c80c03..dcbf3b5f703 100644 --- a/raster/r.univar/r.univar_main.c +++ b/raster/r.univar/r.univar_main.c @@ -165,8 +165,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 = 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 e0f64267cfa..bd232cac459 100644 --- a/raster/r.univar/r3.univar_main.c +++ b/raster/r.univar/r3.univar_main.c @@ -133,10 +133,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 = NAN; + zone_info.max = NAN; 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 313b673e33a..0b979d6e050 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)); @@ -130,7 +130,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); @@ -193,9 +193,9 @@ int print_stats(univar_stat * stats) (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++) { @@ -408,7 +408,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; @@ -459,9 +459,9 @@ int print_stats_table(univar_stat * stats) if (stats[z].n == 0) { - quartile_25 = median = quartile_75 = 0.0 / 0.0; + quartile_25 = median = quartile_75 = NAN; 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 88415a5c8a8..e69986ca5a8 100644 --- a/raster/r.viewshed/statusstructure.cpp +++ b/raster/r.viewshed/statusstructure.cpp @@ -40,7 +40,6 @@ #include #include #include - extern "C" { #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 ed897b859cf..393f1fc5c01 100644 --- a/raster3d/r3.in.lidar/info.c +++ b/raster3d/r3.in.lidar/info.c @@ -13,6 +13,7 @@ */ #include +#include #include @@ -104,7 +105,7 @@ int scan_bounds(LASReaderH LAS_reader, int shell_style, int extents, 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 = 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 2f65d4ed450..2a5592df084 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 d347c778f50..d66cd3ff639 100644 --- a/vector/v.cluster/main.c +++ b/vector/v.cluster/main.c @@ -260,7 +260,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = 1.0 / 0.0; + min = NAN; max = 0; kd = G_malloc(minpnts * sizeof(double)); ki = G_malloc(minpnts * sizeof(int)); @@ -468,7 +468,7 @@ int main(int argc, char *argv[]) c[2] = 0.0; n = 0; sum = sumsq = 0; - min = 1.0 / 0.0; + 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 a9aabd65fd5..e8b1ecea440 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 = 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) diff --git a/vector/v.voronoi/skeleton.c b/vector/v.voronoi/skeleton.c index 96705fe909e..42dca65dcbe 100644 --- a/vector/v.voronoi/skeleton.c +++ b/vector/v.voronoi/skeleton.c @@ -535,7 +535,7 @@ int tie_up(void) IPoints[i]); } - distmin = 1. / 0.; /* +inf */ + distmin = INFINITY; xmin = x; ymin = y; From 98cb9a009955124484f2a00fcbc15ef31e457da7 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 13:50:36 +0100 Subject: [PATCH 02/32] 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 91f46a2e3d5..4dec5e4e458 100644 --- a/general/g.region/printwindow.c +++ b/general/g.region/printwindow.c @@ -468,7 +468,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 533b11842cc..6f8c54a630a 100644 --- a/lib/btree2/kdtree.c +++ b/lib/btree2/kdtree.c @@ -524,7 +524,7 @@ int kdtree_knn(struct kdtree *t, double *c, int *uid, double *d, int k, 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 5bd00745d2b..0bbf8e57617 100644 --- a/lib/raster3d/mask.c +++ b/lib/raster3d/mask.c @@ -311,12 +311,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 550da1af652..ae84d4adc3b 100644 --- a/lib/vector/Vlib/box.c +++ b/lib/vector/Vlib/box.c @@ -253,7 +253,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; } @@ -319,7 +319,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; } @@ -366,7 +366,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 f856ae13a01..fc040ef6c3a 100644 --- a/raster/r.horizon/main.c +++ b/raster/r.horizon/main.c @@ -766,7 +766,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 d8aab3f74b3..2a2d6e5ee44 100644 --- a/raster/r.in.bin/main.c +++ b/raster/r.in.bin/main.c @@ -259,7 +259,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 437a6129cf8..11d5dc36377 100644 --- a/raster/r.in.lidar/info.c +++ b/raster/r.in.lidar/info.c @@ -12,7 +12,6 @@ */ #include -#include /* For INIFINITY */ #include @@ -104,7 +103,7 @@ int scan_bounds(LASReaderH LAS_reader, int shell_style, int extents, 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 b754e2ba534..3a96a984ebd 100644 --- a/raster/r.in.lidar/point_binning.c +++ b/raster/r.in.lidar/point_binning.c @@ -437,7 +437,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; @@ -492,7 +492,7 @@ void write_percentile(struct BinIndex *bin_index, void *raster_row, if (Rast_is_null_value(index_array + n_offset, 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; @@ -547,7 +547,7 @@ void write_skewness(struct BinIndex *bin_index, void *raster_row, if (Rast_is_null_value(index_array + n_offset, 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 */ @@ -603,7 +603,7 @@ void write_trimmean(struct BinIndex *bin_index, void *raster_row, if (Rast_is_null_value(index_array + n_offset, 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; @@ -695,9 +695,9 @@ void write_values(struct PointBinning *point_binning, 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)); } @@ -713,7 +713,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); @@ -766,12 +766,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 56aa59e3909..9c38c3eaa17 100644 --- a/raster/r.li/r.li.padrange/padrange.c +++ b/raster/r.li/r.li.padrange/padrange.c @@ -315,8 +315,8 @@ int calculate(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = 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; @@ -551,8 +551,8 @@ int calculateD(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = 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; @@ -787,8 +787,8 @@ int calculateF(int fd, struct area_entry *ad, double *result) (((NS_DIST1 + NS_DIST2) / 2) / hd.rows); /* get min and max patch size */ - min = 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 33c6c046fa8..bf8f9726a80 100644 --- a/raster/r.out.gdal/main.c +++ b/raster/r.out.gdal/main.c @@ -1040,11 +1040,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 4513d764135..e3e79257fc6 100644 --- a/raster/r.series.accumulate/main.c +++ b/raster/r.series.accumulate/main.c @@ -174,8 +174,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 dcbf3b5f703..436e2c80c03 100644 --- a/raster/r.univar/r.univar_main.c +++ b/raster/r.univar/r.univar_main.c @@ -165,8 +165,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 bd232cac459..e0f64267cfa 100644 --- a/raster/r.univar/r3.univar_main.c +++ b/raster/r.univar/r3.univar_main.c @@ -133,10 +133,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 0b979d6e050..313b673e33a 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)); @@ -130,7 +130,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); @@ -193,9 +193,9 @@ int print_stats(univar_stat * stats) (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++) { @@ -408,7 +408,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; @@ -459,9 +459,9 @@ int print_stats_table(univar_stat * stats) 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 393f1fc5c01..ed897b859cf 100644 --- a/raster3d/r3.in.lidar/info.c +++ b/raster3d/r3.in.lidar/info.c @@ -13,7 +13,6 @@ */ #include -#include #include @@ -105,7 +104,7 @@ int scan_bounds(LASReaderH LAS_reader, int shell_style, int extents, 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 d66cd3ff639..d347c778f50 100644 --- a/vector/v.cluster/main.c +++ b/vector/v.cluster/main.c @@ -260,7 +260,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)); @@ -468,7 +468,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 e8b1ecea440..a9aabd65fd5 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 42dca65dcbe..96705fe909e 100644 --- a/vector/v.voronoi/skeleton.c +++ b/vector/v.voronoi/skeleton.c @@ -535,7 +535,7 @@ int tie_up(void) IPoints[i]); } - distmin = INFINITY; + distmin = 1. / 0.; /* +inf */ xmin = x; ymin = y; From a1c304b342adfa22536288315d4232b367edcd80 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 14:20:55 +0100 Subject: [PATCH 03/32] 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 2572080ac4c42c6c46a0d81b2477cc51ef8afa81 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 14:37:28 +0100 Subject: [PATCH 04/32] CI fix for pylint in gui/wxpython called with wildcard --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 1f5974b761e..486592c5f94 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -78,7 +78,7 @@ jobs: export PYTHONPATH=`grass --config python_path`:$PYTHONPATH export LD_LIBRARY_PATH=$HOME/install/grass83/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 637160dbd814cc890339402bd37318dffbafac27 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 15:41:08 +0100 Subject: [PATCH 05/32] 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 d505352da2240228b630cd96b5aa9c009d03e79b Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 15:44:30 +0100 Subject: [PATCH 06/32] 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 0099daa71d629f27a2309751e0f3c0f3f4448c4d Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 15:50:19 +0100 Subject: [PATCH 07/32] 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 297f2b311a25b2603d167b79fe2e36f48300d207 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 5 Dec 2022 18:25:07 +0100 Subject: [PATCH 08/32] 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 77c79a16da98f5aacabffd669c9329147cb565ae Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Tue, 6 Dec 2022 23:05:13 +0100 Subject: [PATCH 09/32] 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 f590798e42aafe2aa45f3e69be2bb9836d7ba7c8 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Sat, 10 Dec 2022 17:32:39 +0100 Subject: [PATCH 10/32] 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 b79ac0e0fa46ac0622fddd35369542a5d49720dd Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Sat, 10 Dec 2022 17:39:25 +0100 Subject: [PATCH 11/32] 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 a189cb74cb19b3a4a450059df68fff800f2acb5b Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Sun, 11 Dec 2022 15:54:28 +0100 Subject: [PATCH 12/32] 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 b957a81768b5983fc8f7f7fdc85002543fd49076 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 09:47:49 +0100 Subject: [PATCH 13/32] 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 0d4e0da986e39cde695eb8054d75e673d138e40e Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 09:48:48 +0100 Subject: [PATCH 14/32] 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 20c00ba7c0b1b1cf677994ada4cd934880d3177c Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 09:49:34 +0100 Subject: [PATCH 15/32] 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 c158111c2b2350a06b53c2c16c066f09d793a1a5 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 11:45:54 +0100 Subject: [PATCH 16/32] 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 44acbfa8368babbfae01eaa6843e5654af44e73c Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:26:35 +0100 Subject: [PATCH 17/32] 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 4e8ddc7dc91c6e75e89240cdc419349ae088b078 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:27:29 +0100 Subject: [PATCH 18/32] 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 ab8a0a3ea008d1f6c8cb1c38644d713313ed9185 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:27:55 +0100 Subject: [PATCH 19/32] 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 0834a87c4d21f4f5b39621ea2d05789384799fba Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:34:48 +0100 Subject: [PATCH 20/32] 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 ec65ecb7b47e50b16301b1aee96e82c5d592e481 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 13:36:26 +0100 Subject: [PATCH 21/32] 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 e09436987c8f1c7f4ff84608cb3b357654da2026 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 15:41:31 +0100 Subject: [PATCH 22/32] 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 7aeb0b6fea0950e93934a2b6dbf768afda51b303 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 20:13:30 +0100 Subject: [PATCH 23/32] 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 2838cc9215211d02a9753dcd37b786fcf2c67de1 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Mon, 2 Jan 2023 20:18:14 +0100 Subject: [PATCH 24/32] 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 74207c5c526d840c95a517a67bd54cdb526f24f8 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Tue, 3 Jan 2023 08:28:59 +0100 Subject: [PATCH 25/32] 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 ea058ff3adb5158b270380f3dc7e716318f2a3e0 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 12:35:27 +0100 Subject: [PATCH 26/32] sync clang-format changes from main --- include/grass/iostream/mm.h | 155 ++++++++++++-------------- lib/db/dbmi_base/dbmscap.c | 55 +++++---- lib/external/ccmath/ccmath.h | 74 ++++++------ lib/gis/spawn.c | 111 ++++++++---------- lib/gis/user_config.c | 60 +++++----- lib/iostream/rtimer.cpp | 48 ++++---- lib/pngdriver/graph_set.c | 11 +- lib/rst/interp_float/point2d.c | 35 +++--- raster/r.viewshed/statusstructure.cpp | 118 ++++++++++---------- 9 files changed, 311 insertions(+), 356 deletions(-) diff --git a/include/grass/iostream/mm.h b/include/grass/iostream/mm.h index 92d934ae8be..5b5cfa1e2d9 100644 --- a/include/grass/iostream/mm.h +++ b/include/grass/iostream/mm.h @@ -1,16 +1,16 @@ /**************************************************************************** - * + * * MODULE: iostream * * COPYRIGHT (C) 2007 Laura Toma - * - * + * + * * Iostream is a library that implements streams, external memory * sorting on streams, and an external memory priority queue on * streams. These are the fundamental components used in external - * memory algorithms. + * memory algorithms. * Credits: The library was developed by Laura Toma. The kernel of * class STREAM is based on the similar class existent in the GPL TPIE @@ -20,7 +20,7 @@ * porting Terraflow to GRASS in 2001. PEARL upgrades in 2003 by * Rajiv Wickremesinghe as part of the Terracost project. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -33,7 +33,6 @@ * General Public License for more details. * * **************************************************************************/ - #ifndef _MM_H #define _MM_H @@ -48,42 +47,38 @@ #define MM_REGISTER_VERSION 2 // The default amount of memory we will allow to be allocated (40MB). -#define MM_DEFAULT_MM_SIZE (40<<20) - +#define MM_DEFAULT_MM_SIZE (40 << 20) // MM accounting modes typedef enum { - MM_IGNORE_MEMORY_EXCEEDED=0, - MM_ABORT_ON_MEMORY_EXCEEDED, - MM_WARN_ON_MEMORY_EXCEEDED + MM_IGNORE_MEMORY_EXCEEDED = 0, + MM_ABORT_ON_MEMORY_EXCEEDED, + MM_WARN_ON_MEMORY_EXCEEDED } MM_mode; - // MM Error codes enum MM_err { - MM_ERROR_NO_ERROR = 0, - MM_ERROR_INSUFFICIENT_SPACE, - MM_ERROR_UNDERFLOW, - MM_ERROR_EXCESSIVE_ALLOCATION + MM_ERROR_NO_ERROR = 0, + MM_ERROR_INSUFFICIENT_SPACE, + MM_ERROR_UNDERFLOW, + MM_ERROR_EXCESSIVE_ALLOCATION }; - // types of memory usage queries we can make on streams enum MM_stream_usage { - // Overhead of the object without the buffer - MM_STREAM_USAGE_OVERHEAD = 1, + // Overhead of the object without the buffer + MM_STREAM_USAGE_OVERHEAD = 1, - // amount used by a buffer - MM_STREAM_USAGE_BUFFER, + // amount used by a buffer + MM_STREAM_USAGE_BUFFER, - // Amount currently in use. - MM_STREAM_USAGE_CURRENT, + // Amount currently in use. + MM_STREAM_USAGE_CURRENT, - // Maximum amount possibly in use. - MM_STREAM_USAGE_MAXIMUM + // Maximum amount possibly in use. + MM_STREAM_USAGE_MAXIMUM }; - #ifdef GRASS_CMAKE_BUILD #include #else @@ -94,88 +89,78 @@ enum MM_stream_usage { // BTEs that rely on the underlying OS to manage physical memory. class GRASS_IOSTREAM_EXPORT MM_register { private: - // The number of instances of this class and descendents that exist. - static int instances; - - // The amount of space remaining to be allocated. - size_t remaining; - - // The user-specified limit on memory. - size_t user_limit; - - // the amount that has been allocated. - size_t used; - - // flag indicates how we are keeping track of memory - static MM_mode register_new; - -//protected: -// // private methods, only called by operators new and delete. + // The number of instances of this class and descendents that exist. + static int instances; + + // The amount of space remaining to be allocated. + size_t remaining; + + // The user-specified limit on memory. + size_t user_limit; + + // the amount that has been allocated. + size_t used; + + // flag indicates how we are keeping track of memory + static MM_mode register_new; + + // protected: + // // private methods, only called by operators new and delete. public: // Need to be accessible from pqueue constructor - MM_err register_allocation (size_t sz); - MM_err register_deallocation(size_t sz); + MM_err register_allocation(size_t sz); + MM_err register_deallocation(size_t sz); - public: - MM_register(); - ~MM_register(void); + MM_register(); + ~MM_register(void); + + MM_err set_memory_limit(size_t sz); + void enforce_memory_limit(); + void ignore_memory_limit(); + void warn_memory_limit(); + MM_mode get_limit_mode(); + void print_limit_mode(); - MM_err set_memory_limit(size_t sz); - void enforce_memory_limit (); - void ignore_memory_limit (); - void warn_memory_limit (); - MM_mode get_limit_mode(); - void print_limit_mode(); + size_t memory_available(); + size_t memory_used(); + size_t memory_limit(); - size_t memory_available (); - size_t memory_used (); - size_t memory_limit (); + int space_overhead(); - int space_overhead (); - - void print(); + void print(); - // make these members of MM_register + // make these members of MM_register #ifdef GRASS_MM_USE_EXCEPTION_SPECIFIER - void * operator new(size_t) throw (std::bad_alloc); - void * operator new[] (size_t) throw (std::bad_alloc); - void operator delete(void *) throw(); - void operator delete[](void *) throw(); + void *operator new(size_t) throw(std::bad_alloc); + void *operator new[](size_t) throw(std::bad_alloc); + void operator delete(void *) throw(); + void operator delete[](void *) throw(); #else - void * operator new(size_t); - void * operator new[] (size_t); - void operator delete(void *) noexcept; - void operator delete[](void *) noexcept; + void *operator new(size_t); + void *operator new[](size_t); + void operator delete(void *) noexcept; + void operator delete[](void *) noexcept; #endif /* GRASS_MM_USE_EXCEPTION_SPECIFIER */ - friend class mm_register_init; + friend class mm_register_init; }; - - - // A class to make sure that MM_manager gets set up properly (only one // instance) . class mm_register_init { private: - // The number of mm_register_init objects that exist. - static unsigned int count; - + // The number of mm_register_init objects that exist. + static unsigned int count; + public: - mm_register_init(void); - ~mm_register_init(void); + mm_register_init(void); + ~mm_register_init(void); }; static mm_register_init source_file_mm_register_init; - - - - // Here is the single memory management object (defined in mm.C). extern GRASS_IOSTREAM_EXPORT MM_register MM_manager; - - -#endif // _MM_H +#endif // _MM_H diff --git a/lib/db/dbmi_base/dbmscap.c b/lib/db/dbmi_base/dbmscap.c index 84d72ecff6a..c6ce8f755de 100644 --- a/lib/db/dbmi_base/dbmscap.c +++ b/lib/db/dbmi_base/dbmscap.c @@ -20,17 +20,15 @@ #include #include -static char *dbmscap_files[] = { - "/etc/dbmscap", - "/lib/dbmscap", - "/usr/lib/dbmscap", - "/usr/local/lib/dbmscap", - "/usr/local/dbmi/lib/dbmscap", - NULL -}; - -static void -add_entry(dbDbmscap ** list, char *name, char *startup, char *comment); +static char *dbmscap_files[] = {"/etc/dbmscap", + "/lib/dbmscap", + "/usr/lib/dbmscap", + "/usr/local/lib/dbmscap", + "/usr/local/dbmi/lib/dbmscap", + NULL}; + +static void add_entry(dbDbmscap **list, char *name, char *startup, + char *comment); static char *dbmscap_filename(int err_flag) { @@ -78,7 +76,7 @@ int db_has_dbms(void) \param dst destination \param src source */ -void db_copy_dbmscap_entry(dbDbmscap * dst, dbDbmscap * src) +void db_copy_dbmscap_entry(dbDbmscap *dst, dbDbmscap *src) { strcpy(dst->driverName, src->driverName); strcpy(dst->comment, src->comment); @@ -90,16 +88,16 @@ void db_copy_dbmscap_entry(dbDbmscap * dst, dbDbmscap * src) dbmscap file was used in grass5.0 but it is not used in grass5.7 until we find it necessary. All code for dbmscap - file is commented here. + file is commented here. - Instead of in dbmscap file db_read_dbmscap() searches + Instead of in dbmscap file db_read_dbmscap() searches for available dbmi drivers in $(GISBASE)/driver/db/ \return pointer to dbDbmscap */ dbDbmscap *db_read_dbmscap(void) { - /* + /* FILE *fd; char *file; char name[1024]; @@ -170,7 +168,7 @@ dbDbmscap *db_read_dbmscap(void) dir = opendir(dirpath); if (dir == NULL) { db_syserror("Cannot open drivers directory"); - return (dbDbmscap *) NULL; + return (dbDbmscap *)NULL; } G_free(dirpath); @@ -178,8 +176,7 @@ dbDbmscap *db_read_dbmscap(void) while ((ent = readdir(dir))) { char *name; - if ((strcmp(ent->d_name, ".") == 0) - || (strcmp(ent->d_name, "..") == 0)) + if ((strcmp(ent->d_name, ".") == 0) || (strcmp(ent->d_name, "..") == 0)) continue; #ifdef _WIN32 @@ -192,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 @@ -209,20 +206,22 @@ dbDbmscap *db_read_dbmscap(void) return list; } -static int cmp_entry(dbDbmscap * a, dbDbmscap * b) +static int cmp_entry(dbDbmscap *a, dbDbmscap *b) { - return (*a->driverName && - *b->driverName ? strcmp(a->driverName, b->driverName) : 0); + return (*a->driverName && *b->driverName + ? strcmp(a->driverName, b->driverName) + : 0); } -static void add_entry(dbDbmscap ** list, char *name, char *startup, +static void add_entry(dbDbmscap **list, char *name, char *startup, char *comment) { - /* add an entry to the list, so that the list remains ordered (by driverName) */ + /* add an entry to the list, so that the list remains ordered (by + * driverName) */ dbDbmscap *head, *cur, *tail; - cur = (dbDbmscap *) db_malloc(sizeof(dbDbmscap)); + cur = (dbDbmscap *)db_malloc(sizeof(dbDbmscap)); if (cur == NULL) { *list = NULL; return; @@ -256,11 +255,11 @@ static void add_entry(dbDbmscap ** list, char *name, char *startup, } /*! - \brief Free dbmscap + \brief Free dbmscap \param list pointer to dbDbmscap */ -void db_free_dbmscap(dbDbmscap * list) +void db_free_dbmscap(dbDbmscap *list) { dbDbmscap *next, *cur; diff --git a/lib/external/ccmath/ccmath.h b/lib/external/ccmath/ccmath.h index dec8176a557..7ae879417ec 100644 --- a/lib/external/ccmath/ccmath.h +++ b/lib/external/ccmath/ccmath.h @@ -6,7 +6,7 @@ * * Modified by Soeren gebbert 2009/01/08 * Removed al unused functions in GRASS. Only the linear algebra - * functions are used. + * functions are used. * ------------------------------------------------------------------------ */ /* @@ -15,47 +15,45 @@ Numerical Analysis Toolkit Header File ELF Shared Library Version */ - /* Required for Shared Library */ +/* Required for Shared Library */ #ifndef _CCMATH_H_ #define _CCMATH_H_ #define XMATH 1 - /* Define File Pointers and Standard Library */ +/* Define File Pointers and Standard Library */ #include #include #include - /* Definitions of Types */ +/* Definitions of Types */ #ifndef NULL #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; #endif /* _MSC_VER */ -#define CPX 1 +#define CPX 1 #endif /* Linear Algebra */ - /* Real Linear Systems */ +/* Real Linear Systems */ int minv(double *a, int n); @@ -100,7 +98,7 @@ double vnrm(double *u, double *v, int n); void matprt(double *a, int n, int m, char *fmt); -void fmatprt(FILE * fp, double *a, int n, int m, char *fmt); +void fmatprt(FILE *fp, double *a, int n, int m, char *fmt); void trnm(double *a, int n); @@ -116,7 +114,7 @@ void ortho(double *evc, int n); void smgen(double *a, double *eval, double *evec, int n); - /* utility routines for real symmertic eigensystems */ +/* utility routines for real symmertic eigensystems */ void house(double *a, double *d, double *ud, int n); @@ -126,7 +124,7 @@ int qreval(double *eval, double *ud, int n); int qrevec(double *eval, double *evec, double *dp, int n); - /* utility routines for singular value decomposition */ +/* utility routines for singular value decomposition */ int qrbdi(double *d, double *e, int n); @@ -142,52 +140,50 @@ void atou1(double *a, int m, int n); void atovm(double *v, int n); +/* Complex Matrix Algebra */ - /* Complex Matrix Algebra */ +int cminv(Cpx *a, int n); +int csolv(Cpx *a, Cpx *b, int n); -int cminv(Cpx * a, int n); +void heigvec(Cpx *a, double *eval, int n); -int csolv(Cpx * a, Cpx * b, int n); +void heigval(Cpx *a, double *eval, int n); -void heigvec(Cpx * a, double *eval, int n); +double hevmax(Cpx *a, Cpx *u, int n); -void heigval(Cpx * a, double *eval, int n); +void cmmul(Cpx *c, Cpx *a, Cpx *b, int n); -double hevmax(Cpx * a, Cpx * u, int n); +void cmmult(Cpx *c, Cpx *a, Cpx *b, int m, int k, int n); -void cmmul(Cpx * c, Cpx * a, Cpx * b, int n); +void cvmul(Cpx *vp, Cpx *mat, Cpx *v, int n); -void cmmult(Cpx * c, Cpx * a, Cpx * b, int m, int k, int n); +Cpx cvnrm(Cpx *u, Cpx *v, int n); -void cvmul(Cpx * vp, Cpx * mat, Cpx * v, int n); +void cmprt(Cpx *a, int n, int m, char *fmt); -Cpx cvnrm(Cpx * u, Cpx * v, int n); +void trncm(Cpx *a, int n); -void cmprt(Cpx * a, int n, int m, char *fmt); +void hconj(Cpx *u, int n); -void trncm(Cpx * a, int n); +void cmattr(Cpx *a, Cpx *b, int m, int n); -void hconj(Cpx * u, int n); +void utrncm(Cpx *at, Cpx *u, Cpx *a, int n); -void cmattr(Cpx * a, Cpx * b, int m, int n); +void utrnhm(Cpx *ht, Cpx *u, Cpx *h0, int n); -void utrncm(Cpx * at, Cpx * u, Cpx * a, int n); +void cmcpy(Cpx *a, Cpx *b, int n); -void utrnhm(Cpx * ht, Cpx * u, Cpx * h0, int n); +void unitary(Cpx *u, int n); -void cmcpy(Cpx * a, Cpx * b, int n); +void hmgen(Cpx *h, double *eval, Cpx *u, int n); -void unitary(Cpx * u, int n); -void hmgen(Cpx * h, double *eval, Cpx * u, int n); +/* utility routines for hermitian eigen problems */ +void chouse(Cpx *a, double *d, double *ud, int n); - /* utility routines for hermitian eigen problems */ +void chousv(Cpx *a, double *d, double *ud, int n); -void chouse(Cpx * a, double *d, double *ud, int n); - -void chousv(Cpx * a, double *d, double *ud, int n); - -void qrecvc(double *eval, Cpx * evec, double *ud, int n); +void qrecvc(double *eval, Cpx *evec, double *ud, int n); #endif diff --git a/lib/gis/spawn.c b/lib/gis/spawn.c index 1e29f44c5c2..b31c6a6f707 100644 --- a/lib/gis/spawn.c +++ b/lib/gis/spawn.c @@ -41,16 +41,16 @@ /** \def MAX_SIGNALS Maximum number of signals */ /** \def MAX_REDIRECTS Maximum number of redirects */ -#define MAX_ARGS 256 -#define MAX_BINDINGS 256 -#define MAX_SIGNALS 32 +#define MAX_ARGS 256 +#define MAX_BINDINGS 256 +#define MAX_SIGNALS 32 #define MAX_REDIRECTS 32 /** * \brief Spawns a new process. * - * A more useful alternative to G_system(), which takes the + * A more useful alternative to G_system(), which takes the * arguments of command as parameters. * * \param[in] command command to execute @@ -58,16 +58,14 @@ * \return process status on success */ -struct redirect -{ +struct redirect { int dst_fd; int src_fd; const char *file; int mode; }; -struct signal -{ +struct signal { int which; int action; int signum; @@ -78,14 +76,12 @@ struct signal #endif }; -struct binding -{ +struct binding { const char *var; const char *val; }; -struct spawn -{ +struct spawn { const char *args[MAX_ARGS]; int num_args; struct redirect redirects[MAX_REDIRECTS]; @@ -103,8 +99,7 @@ static void parse_argvec(struct spawn *sp, const char **va); #ifdef _WIN32 -struct buffer -{ +struct buffer { char *str; size_t len; size_t size; @@ -220,12 +215,10 @@ static char *check_program(const char *pgm, const char *dir, const char *ext) char pathname[GPATH_MAX]; sprintf(pathname, "%s%s%s%s", dir, *dir ? "\\" : "", pgm, ext); - return access(pathname, 0) == 0 ? G_store(pathname) - : NULL; + return access(pathname, 0) == 0 ? G_store(pathname) : NULL; } -static char *find_program_ext(const char *pgm, const char *dir, - char **pathext) +static char *find_program_ext(const char *pgm, const char *dir, char **pathext) { char *result; int i; @@ -243,8 +236,7 @@ static char *find_program_ext(const char *pgm, const char *dir, return NULL; } -static char *find_program_dir_ext(const char *pgm, char **path, - char **pathext) +static char *find_program_dir_ext(const char *pgm, char **path, char **pathext) { char *result = NULL; int i; @@ -329,10 +321,9 @@ static HANDLE get_handle(int fd) if (fd < 0) return INVALID_HANDLE_VALUE; - h1 = (HANDLE) _get_osfhandle(fd); - if (!DuplicateHandle(GetCurrentProcess(), h1, - GetCurrentProcess(), &h2, - 0, TRUE, DUPLICATE_SAME_ACCESS)) + h1 = (HANDLE)_get_osfhandle(fd); + if (!DuplicateHandle(GetCurrentProcess(), h1, GetCurrentProcess(), &h2, 0, + TRUE, DUPLICATE_SAME_ACCESS)) return INVALID_HANDLE_VALUE; return h2; @@ -371,17 +362,17 @@ static int win_spawn(const char *cmd, const char **argv, const char **envp, si.hStdOutput = handles[1]; si.hStdError = handles[2]; - result = CreateProcess(program, /* lpApplicationName */ - args, /* lpCommandLine */ - NULL, /* lpProcessAttributes */ - NULL, /* lpThreadAttributes */ - 1, /* bInheritHandles */ - 0, /* dwCreationFlags */ - env, /* lpEnvironment */ - cwd, /* lpCurrentDirectory */ - &si, /* lpStartupInfo */ - &pi /* lpProcessInformation */ - ); + result = CreateProcess(program, /* lpApplicationName */ + args, /* lpCommandLine */ + NULL, /* lpProcessAttributes */ + NULL, /* lpThreadAttributes */ + 1, /* bInheritHandles */ + 0, /* dwCreationFlags */ + env, /* lpEnvironment */ + cwd, /* lpCurrentDirectory */ + &si, /* lpStartupInfo */ + &pi /* lpProcessInformation */ + ); G_free(args); G_free(env); @@ -479,7 +470,8 @@ static const char **do_bindings(const struct binding *bindings, const char **newenv; int i, n; - for (i = 0; _environ[i]; i++) ; + for (i = 0; _environ[i]; i++) + ; n = i; newenv = G_malloc((num_bindings + n + 1) * sizeof(char *)); @@ -504,9 +496,8 @@ static int do_spawn(struct spawn *sp, const char *command) do_redirects(sp->redirects, sp->num_redirects, handles); env = do_bindings(sp->bindings, sp->num_bindings); - status = - win_spawn(command, sp->args, env, sp->directory, handles, - sp->background, 1); + status = win_spawn(command, sp->args, env, sp->directory, handles, + sp->background, 1); if (!sp->background && status < 0) G_warning(_("G_spawn: unable to execute command")); @@ -535,16 +526,14 @@ static int undo_signals(const struct signal *signals, int num_signals, case SSA_IGNORE: case SSA_DEFAULT: if (sigaction(s->signum, &s->old_act, NULL) < 0) { - G_warning(_("G_spawn: unable to restore signal %d"), - s->signum); + G_warning(_("G_spawn: unable to restore signal %d"), s->signum); error = 1; } break; case SSA_BLOCK: case SSA_UNBLOCK: if (sigprocmask(SIG_UNBLOCK, &s->old_mask, NULL) < 0) { - G_warning(_("G_spawn: unable to restore signal %d"), - s->signum); + G_warning(_("G_spawn: unable to restore signal %d"), s->signum); error = 1; } break; @@ -583,8 +572,7 @@ static int do_signals(struct signal *signals, int num_signals, int which) case SSA_DEFAULT: act.sa_handler = SIG_DFL; if (sigaction(s->signum, &act, &s->old_act) < 0) { - G_warning(_("G_spawn: unable to ignore signal %d"), - s->signum); + G_warning(_("G_spawn: unable to ignore signal %d"), s->signum); error = 1; } else @@ -602,8 +590,7 @@ static int do_signals(struct signal *signals, int num_signals, int which) sigemptyset(&mask); sigaddset(&mask, s->signum); if (sigprocmask(SIG_UNBLOCK, &mask, &s->old_mask) < 0) { - G_warning(_("G_spawn: unable to unblock signal %d"), - s->signum); + G_warning(_("G_spawn: unable to unblock signal %d"), s->signum); error = 1; } else @@ -688,8 +675,7 @@ static int do_spawn(struct spawn *sp, const char *command) if (sp->directory) if (chdir(sp->directory) < 0) { - G_warning(_("Unable to change directory to %s"), - sp->directory); + G_warning(_("Unable to change directory to %s"), sp->directory); _exit(127); } @@ -711,7 +697,7 @@ static int do_spawn(struct spawn *sp, const char *command) do n = waitpid(pid, &status, 0); - while (n == (pid_t) - 1 && errno == EINTR); + while (n == (pid_t)-1 && errno == EINTR); if (n != pid) status = -1; @@ -743,8 +729,8 @@ static void begin_spawn(struct spawn *sp) sp->directory = NULL; } -#define NEXT_ARG(var, type) ((type) *(var)++) -#define NEXT_ARG_INT(var) (int)((intptr_t) *(var)++) +#define NEXT_ARG(var, type) ((type) * (var)++) +#define NEXT_ARG_INT(var) (int)((intptr_t) * (var)++) static void parse_argvec(struct spawn *sp, const char **va) { @@ -761,8 +747,7 @@ static void parse_argvec(struct spawn *sp, const char **va) sp->redirects[sp->num_redirects].src_fd = -1; sp->redirects[sp->num_redirects].mode = NEXT_ARG_INT(va); - sp->redirects[sp->num_redirects].file = - NEXT_ARG(va, const char *); + sp->redirects[sp->num_redirects].file = NEXT_ARG(va, const char *); sp->num_redirects++; } @@ -954,13 +939,13 @@ 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); + SF_ARGVEC, args, NULL); return status; } @@ -969,7 +954,7 @@ int G_wait(int i_pid) { #ifdef _WIN32 DWORD rights = PROCESS_QUERY_INFORMATION | SYNCHRONIZE; - HANDLE hProcess = OpenProcess(rights, FALSE, (DWORD) i_pid); + HANDLE hProcess = OpenProcess(rights, FALSE, (DWORD)i_pid); DWORD exitcode; if (!hProcess) @@ -977,19 +962,19 @@ int G_wait(int i_pid) WaitForSingleObject(hProcess, INFINITE); if (!GetExitCodeProcess(hProcess, &exitcode)) - exitcode = (DWORD) - 1; + exitcode = (DWORD)-1; CloseHandle(hProcess); return (int)exitcode; #else - pid_t pid = (pid_t) i_pid; + pid_t pid = (pid_t)i_pid; int status = -1; pid_t n; do n = waitpid(pid, &status, 0); - while (n == (pid_t) - 1 && errno == EINTR); + while (n == (pid_t)-1 && errno == EINTR); if (n != pid) return -1; diff --git a/lib/gis/user_config.c b/lib/gis/user_config.c index 15ec649fe2e..9bd541dc4cf 100644 --- a/lib/gis/user_config.c +++ b/lib/gis/user_config.c @@ -2,17 +2,17 @@ /*! * \file lib/gis/user_config.c * - * \brief GIS Library - Routines related to user's GRASS configuration, tmp, and + * \brief GIS Library - Routines related to user's GRASS configuration, tmp, and * miscellaneous files. * - * Functions related to the user's GRASS configuration, tmp, and - * miscellaneous files. Provides a set of routines for creating and - * accessing elements within the user's "rc" directory. The + * Functions related to the user's GRASS configuration, tmp, and + * miscellaneous files. Provides a set of routines for creating and + * accessing elements within the user's "rc" directory. The * directory is in $HOME/.grass.
* - * NOTE: As of 2001-03-25 this file is not hooked up. It is - * provided as a candidate for handling $HOME/.grass files and - * subdirectories. There may be more functionality desired (such as + * NOTE: As of 2001-03-25 this file is not hooked up. It is + * provided as a candidate for handling $HOME/.grass files and + * subdirectories. There may be more functionality desired (such as * deletion routines, directory globs).
* * (C) 2001-2014 by the GRASS Development Team @@ -46,7 +46,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; @@ -70,7 +70,7 @@ static char *_make_toplevel(void) homedir = defaulthomedir; } - len = strlen(homedir) + 8; /* + "/.grass\0" */ + len = strlen(homedir) + 8; /* + "/.grass\0" */ if (NULL == (path = G_calloc(1, len))) { return NULL; } @@ -81,7 +81,7 @@ static char *_make_toplevel(void) if (my_passwd == NULL) return NULL; - len = strlen(my_passwd->pw_dir) + 8; /* + "/.grass\0" */ + len = strlen(my_passwd->pw_dir) + 8; /* + "/.grass\0" */ if (NULL == (path = G_calloc(1, len))) return NULL; @@ -95,7 +95,7 @@ static char *_make_toplevel(void) if (errno == ENOENT) { status = G_mkdir(path); - if (status != 0) { /* mkdir failed */ + if (status != 0) { /* mkdir failed */ G_free(path); return NULL; } @@ -115,18 +115,16 @@ static char *_make_toplevel(void) /* Examine the stat "buf" */ /* It better be a directory */ - if (!S_ISDIR(buf.st_mode)) { /* File, link, something else */ - errno = ENOTDIR; /* element is not a directory, but should be */ + if (!S_ISDIR(buf.st_mode)) { /* File, link, something else */ + errno = ENOTDIR; /* element is not a directory, but should be */ G_free(path); return NULL; } /* No read/write/execute ??? */ - if (!((S_IRUSR & buf.st_mode) && - (S_IWUSR & buf.st_mode) && (S_IXUSR & buf.st_mode) - ) - ) { - errno = EACCES; /* Permissions error */ + if (!((S_IRUSR & buf.st_mode) && (S_IWUSR & buf.st_mode) && + (S_IXUSR & buf.st_mode))) { + errno = EACCES; /* Permissions error */ G_free(path); return NULL; } @@ -174,8 +172,8 @@ static int _elem_count_split(char *elems) /* okay, change '/' into '\0' */ begin = end; if (begin != NULL) { - *begin = '\0'; /* begin points at '/', change it */ - begin++; /* increment begin to next char */ + *begin = '\0'; /* begin points at '/', change it */ + begin++; /* increment begin to next char */ } } @@ -244,17 +242,15 @@ static char *_make_sublevels(const char *elems) else { /* Examine the stat "buf" */ /* It better be a directory */ - if (!S_ISDIR(buf.st_mode)) { /* File, link, something else */ - errno = ENOTDIR; /* element is not a directory, but should be */ + if (!S_ISDIR(buf.st_mode)) { /* File, link, something else */ + errno = ENOTDIR; /* element is not a directory, but should be */ G_free(path); return NULL; } /* No read/write/execute ??? */ - if (!((S_IRUSR & buf.st_mode) && - (S_IWUSR & buf.st_mode) && (S_IXUSR & buf.st_mode) - ) - ) { + if (!((S_IRUSR & buf.st_mode) && (S_IWUSR & buf.st_mode) && + (S_IXUSR & buf.st_mode))) { errno = EACCES; /* Permissions error */ G_free(path); return NULL; @@ -278,10 +274,10 @@ static char *_make_sublevels(const char *elems) /** * \brief Returns path to element and item. * - * Either element or item can be NULL, but not both. If - * element is NULL, then the file is assumed to live at the top - * level. If file is NULL, then it is assumed the caller is not - * interested in the file. If the element or rc dir do not exist, they + * Either element or item can be NULL, but not both. If + * element is NULL, then the file is assumed to live at the top + * level. If file is NULL, then it is assumed the caller is not + * interested in the file. If the element or rc dir do not exist, they * are created. However, the file is never checked for. * * \param[in] element @@ -310,7 +306,7 @@ char *G_rc_path(const char *element, const char *item) assert(*item != '.'); assert(path != NULL); - ptr = strchr(item, '/'); /* should not have slashes */ + ptr = strchr(item, '/'); /* should not have slashes */ assert(ptr == NULL); len = strlen(path) + strlen(item) + 2; if ((ptr = G_realloc(path, len)) == NULL) { @@ -322,7 +318,7 @@ char *G_rc_path(const char *element, const char *item) sprintf(ptr, "/%s", item); return path; -} /* G_rc_path */ +} /* G_rc_path */ /* vim: set softtabstop=4 shiftwidth=4 expandtab: */ diff --git a/lib/iostream/rtimer.cpp b/lib/iostream/rtimer.cpp index e59db17674e..b241a531d3e 100644 --- a/lib/iostream/rtimer.cpp +++ b/lib/iostream/rtimer.cpp @@ -1,16 +1,16 @@ /**************************************************************************** - * + * * MODULE: iostream * * COPYRIGHT (C) 2007 Laura Toma - * - * + * + * * Iostream is a library that implements streams, external memory * sorting on streams, and an external memory priority queue on * streams. These are the fundamental components used in external - * memory algorithms. + * memory algorithms. * Credits: The library was developed by Laura Toma. The kernel of * class STREAM is based on the similar class existent in the GPL TPIE @@ -20,7 +20,7 @@ * porting Terraflow to GRASS in 2001. PEARL upgrades in 2003 by * Rajiv Wickremesinghe as part of the Terracost project. - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -44,26 +44,24 @@ #include #endif -//#include +// #include #include -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); - } 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)); - } - return buf; +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); + } + 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)); + } + return buf; } - - - - diff --git a/lib/pngdriver/graph_set.c b/lib/pngdriver/graph_set.c index 75b72448011..03c65ebbb8d 100644 --- a/lib/pngdriver/graph_set.c +++ b/lib/pngdriver/graph_set.c @@ -42,15 +42,15 @@ 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); if (!ptr) return; #else - ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t) 0); + ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, (off_t)0); if (ptr == MAP_FAILED) return; #endif @@ -75,7 +75,7 @@ static void map_file(void) coordinate system used by the applications programs has the (0,0) origin in the upper left-hand corner. Hence, screen_left < screen_right - screen_top < screen_bottom + screen_top < screen_bottom */ int PNG_Graph_set(void) @@ -133,8 +133,7 @@ int PNG_Graph_set(void) if (p && *p && (sscanf(p, "%02x%02x%02x", &red, &grn, &blu) == 3 || G_str_to_color(p, (int *)&red, (int *)&grn, (int *)&blu) == 1)) { - png.background = - png_get_color(red, grn, blu, png.has_alpha ? 255 : 0); + png.background = png_get_color(red, grn, blu, png.has_alpha ? 255 : 0); } else { /* 0xffffff = white, 0x000000 = black */ diff --git a/lib/rst/interp_float/point2d.c b/lib/rst/interp_float/point2d.c index 4513b49b56b..0637d6820c2 100644 --- a/lib/rst/interp_float/point2d.c +++ b/lib/rst/interp_float/point2d.c @@ -32,7 +32,7 @@ #include #ifndef POINT2D_C -#define POINT2D_C 1 +#define POINT2D_C #endif #include @@ -45,21 +45,22 @@ * Checks if interpolating function interp() evaluates correct z-values at * given points. If smoothing is used calculate the maximum error caused * by smoothing. - * + * * *ertot* is a RMS deviation of the interpolated surface. - * + * * \todo * Alternative description: * ...calculate the maximum and RMS deviation caused by smoothing. */ -int IL_check_at_points_2d(struct interp_params *params, struct quaddata *data, /*!< current region */ - double *b, /*!< solution of linear equations */ - double *ertot, /*!< total error */ - double zmin, /*!< min z-value */ +int IL_check_at_points_2d(struct interp_params *params, + struct quaddata *data, /*!< current region */ + double *b, /*!< solution of linear equations */ + double *ertot, /*!< total error */ + double zmin, /*!< min z-value */ double dnorm, struct triple skip_point) { - int n_points = data->n_points; /* number of points */ - struct triple *points = data->points; /* points for interpolation */ + int n_points = data->n_points; /* number of points */ + struct triple *points = data->points; /* points for interpolation */ double east = data->xmax; double west = data->x_orig; double north = data->ymax; @@ -103,16 +104,15 @@ int IL_check_at_points_2d(struct interp_params *params, struct quaddata *data, err = hz - zz; xmm = points[mm - 1].x * dnorm + params->x_orig + west; ymm = points[mm - 1].y * dnorm + params->y_orig + south; - if ((xmm >= west + params->x_orig) && (xmm <= east + params->x_orig) - && (ymm >= south + params->y_orig) && - (ymm <= north + params->y_orig)) + if ((xmm >= west + params->x_orig) && (xmm <= east + params->x_orig) && + (ymm >= south + params->y_orig) && (ymm <= north + params->y_orig)) inside = 1; else inside = 0; if (params->create_devi) { - if (inside) { /* if the point is inside the region */ + if (inside) { /* if the point is inside the region */ Vect_reset_line(Pnts); Vect_reset_cats(Cats2); @@ -162,14 +162,13 @@ int IL_check_at_points_2d(struct interp_params *params, struct quaddata *data, xmm = skip_point.x * dnorm + params->x_orig + west; ymm = skip_point.y * dnorm + params->y_orig + south; - if ((xmm >= west + params->x_orig) && (xmm <= east + params->x_orig) - && (ymm >= south + params->y_orig) && - (ymm <= north + params->y_orig)) + if ((xmm >= west + params->x_orig) && (xmm <= east + params->x_orig) && + (ymm >= south + params->y_orig) && (ymm <= north + params->y_orig)) inside = 1; else inside = 0; - if (inside) { /* if the point is inside the region */ + if (inside) { /* if the point is inside the region */ Vect_reset_line(Pnts); Vect_reset_cats(Cats2); @@ -195,7 +194,7 @@ int IL_check_at_points_2d(struct interp_params *params, struct quaddata *data, } count++; } - } /* cv */ + } /* cv */ return 1; diff --git a/raster/r.viewshed/statusstructure.cpp b/raster/r.viewshed/statusstructure.cpp index e69986ca5a8..baeee60566d 100644 --- a/raster/r.viewshed/statusstructure.cpp +++ b/raster/r.viewshed/statusstructure.cpp @@ -10,16 +10,16 @@ * wkrichar@bowdoin.edu or willster3021@gmail.com * Markus Metz: surface interpolation * - * Date: april 2011 - * + * Date: april 2011 + * * PURPOSE: To calculate the viewshed (the visible cells in the * raster) for the given viewpoint (observer) location. The * visibility model is the following: Two points in the raster are * 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, - * i.e. if the line-of-sight does not pass through the cell center, + * 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 * terms of CPU operations and I/O operations. It has worst-case @@ -40,8 +40,7 @@ #include #include #include -extern "C" -{ +extern "C" { #include #include } @@ -58,10 +57,11 @@ extern "C" point represented by the StatusNode. Assumes all values (except gradient) in sn have been filled. The value returned is in [0, 180]. A value of 0 is directly below the specified viewing position, - 90 is due horizontal, and 180 is directly above the observer. + 90 is due horizontal, and 180 is directly above the observer. 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) +float get_vertical_angle(Viewpoint vp, StatusNode sn, surface_type elev, + int doCurv) { /*determine the difference in elevation, based on the curvature */ @@ -73,30 +73,30 @@ float get_vertical_angle(Viewpoint vp, StatusNode sn, surface_type elev, int doC /* 0 above, 180 below */ if (diffElev >= 0.0) - return (atan(sqrt(sn.dist2vp) / diffElev) * (180 / M_PI)); + return (atan(sqrt(sn.dist2vp) / diffElev) * (180 / M_PI)); else - return (atan(fabs(diffElev) / sqrt(sn.dist2vp)) * (180 / M_PI) + 90); + return (atan(fabs(diffElev) / sqrt(sn.dist2vp)) * (180 / M_PI) + 90); /* 180 above, 0 below */ if (diffElev >= 0.0) - return (atan(diffElev / sqrt(sn.dist2vp)) * (180 / M_PI) + 90); + return (atan(diffElev / sqrt(sn.dist2vp)) * (180 / M_PI) + 90); else - return (atan(sqrt(sn.dist2vp) / fabs(diffElev)) * (180 / M_PI)); + return (atan(sqrt(sn.dist2vp) / fabs(diffElev)) * (180 / M_PI)); } /* ------------------------------------------------------------ */ /*return an estimate of the size of active structure */ -long long get_active_str_size_bytes(GridHeader * hd) +long long get_active_str_size_bytes(GridHeader *hd) { long long sizeBytes; G_verbose_message(_("Estimated size active structure:")); G_verbose_message(_(" (key=%d, ptr=%d, total node=%d B)"), - (int)sizeof(TreeValue), - (int)sizeof(TreeNode *), (int)sizeof(TreeNode)); + (int)sizeof(TreeValue), (int)sizeof(TreeNode *), + (int)sizeof(TreeNode)); sizeBytes = sizeof(TreeNode) * std::max(hd->ncols, hd->nrows); G_verbose_message(_(" Total= %lld B"), sizeBytes); return sizeBytes; @@ -105,35 +105,34 @@ long long get_active_str_size_bytes(GridHeader * hd) /* ------------------------------------------------------------ */ /*given a StatusNode, fill in its dist2vp and gradient */ -void calculate_dist_n_gradient(StatusNode * sn, double elev, - Viewpoint * vp, GridHeader hd) +void calculate_dist_n_gradient(StatusNode *sn, double elev, Viewpoint *vp, + GridHeader hd) { assert(sn && vp); /*sqrt is expensive - //sn->dist2vp = sqrt((float) ( pow(sn->row - vp->row,2.0) + + //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)), - Rast_row_to_northing(sn->row + 0.5, &(hd.window)), - Rast_col_to_easting(vp->col + 0.5, &(hd.window)), - Rast_row_to_northing(vp->row + 0.5, &(hd.window))); + double dist = + G_distance(Rast_col_to_easting(sn->col + 0.5, &(hd.window)), + Rast_row_to_northing(sn->row + 0.5, &(hd.window)), + Rast_col_to_easting(vp->col + 0.5, &(hd.window)), + Rast_row_to_northing(vp->row + 0.5, &(hd.window))); - sn->dist2vp = dist * dist; + sn->dist2vp = dist * dist; } else { - double dx = ((double)sn->col - vp->col) * hd.ew_res; - double dy = ((double)sn->row - vp->row) * hd.ns_res; - - sn->dist2vp = (dx * dx) + (dy * dy); + double dx = ((double)sn->col - vp->col) * hd.ew_res; + double dy = ((double)sn->row - vp->row) * hd.ns_res; + + sn->dist2vp = (dx * dx) + (dy * dy); } if (diffElev == 0) { - sn->gradient[1] = 0; - return; + sn->gradient[1] = 0; + return; } /* PI / 2 above, - PI / 2 below, like r.los */ @@ -143,9 +142,9 @@ void calculate_dist_n_gradient(StatusNode * sn, double elev, /* PI above, 0 below. slower than r.los - like */ if (diffElev >= 0.0) - sn->gradient[1] = (atan(diffElev / sqrt(sn->dist2vp)) + M_PI / 2); + sn->gradient[1] = (atan(diffElev / sqrt(sn->dist2vp)) + M_PI / 2); else - sn->gradient[1] = (atan(sqrt(sn->dist2vp) / fabs(diffElev))); + sn->gradient[1] = (atan(sqrt(sn->dist2vp) / fabs(diffElev))); return; @@ -153,40 +152,38 @@ void calculate_dist_n_gradient(StatusNode * sn, double elev, sn->gradient[1] = (diffElev * diffElev) / (sn->dist2vp); /*maintain sign */ if (elev < vp->elev) - sn->gradient[1] = -sn->gradient[1]; - + sn->gradient[1] = -sn->gradient[1]; return; } /* ------------------------------------------------------------ */ /* calculate gradient for ENTERING or EXITING event */ -void calculate_event_gradient(StatusNode * sn, int e_idx, - double row, double col, double elev, - Viewpoint * vp, GridHeader hd) +void calculate_event_gradient(StatusNode *sn, int e_idx, double row, double col, + double elev, Viewpoint *vp, GridHeader hd) { assert(sn && vp); /*sqrt is expensive - //sn->dist2vp = sqrt((float) ( pow(sn->row - vp->row,2.0) + + //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; if (G_projection() == PROJECTION_LL) { - double dist = G_distance(Rast_col_to_easting(col + 0.5, &(hd.window)), - Rast_row_to_northing(row + 0.5, &(hd.window)), - Rast_col_to_easting(vp->col + 0.5, &(hd.window)), - Rast_row_to_northing(vp->row + 0.5, &(hd.window))); + double dist = + G_distance(Rast_col_to_easting(col + 0.5, &(hd.window)), + Rast_row_to_northing(row + 0.5, &(hd.window)), + Rast_col_to_easting(vp->col + 0.5, &(hd.window)), + Rast_row_to_northing(vp->row + 0.5, &(hd.window))); - dist2vp = dist * dist; + dist2vp = dist * dist; } else { - double dx = (col - vp->col) * hd.ew_res; - double dy = (row - vp->row) * hd.ns_res; - - dist2vp = (dx * dx) + (dy * dy); + double dx = (col - vp->col) * hd.ew_res; + double dy = (row - vp->row) * hd.ns_res; + + dist2vp = (dx * dx) + (dy * dy); } /* PI / 2 above, - PI / 2 below */ @@ -196,9 +193,9 @@ void calculate_event_gradient(StatusNode * sn, int e_idx, /* PI above, 0 below. slower than r.los - like */ if (diffElev >= 0.0) - sn->gradient[e_idx] = (atan(diffElev / sqrt(dist2vp)) + M_PI / 2); + sn->gradient[e_idx] = (atan(diffElev / sqrt(dist2vp)) + M_PI / 2); else - sn->gradient[e_idx] = (atan(sqrt(dist2vp) / fabs(diffElev))); + sn->gradient[e_idx] = (atan(sqrt(dist2vp) / fabs(diffElev))); return; @@ -206,7 +203,7 @@ void calculate_event_gradient(StatusNode * sn, int e_idx, sn->gradient[e_idx] = (diffElev * diffElev) / (dist2vp); /*maintain sign */ if (elev < vp->elev) - sn->gradient[e_idx] = -sn->gradient[e_idx]; + sn->gradient[e_idx] = -sn->gradient[e_idx]; return; } @@ -218,7 +215,7 @@ StatusList *create_status_struct() { StatusList *sl; - sl = (StatusList *) G_malloc(sizeof(StatusList)); + sl = (StatusList *)G_malloc(sizeof(StatusList)); assert(sl); TreeValue tv; @@ -240,7 +237,7 @@ StatusList *create_status_struct() /* ------------------------------------------------------------ */ /*delete a status structure */ -void delete_status_structure(StatusList * sl) +void delete_status_structure(StatusList *sl) { assert(sl); delete_tree(sl->rbt); @@ -252,7 +249,7 @@ void delete_status_structure(StatusList * sl) /* ------------------------------------------------------------ */ /*delete the statusNode with the given key */ -void delete_from_status_struct(StatusList * sl, double dist2vp) +void delete_from_status_struct(StatusList *sl, double dist2vp) { assert(sl); delete_from(sl->rbt, dist2vp); @@ -264,7 +261,7 @@ void delete_from_status_struct(StatusList * sl, double dist2vp) /* ------------------------------------------------------------ */ /*insert the element into the status structure */ -void insert_into_status_struct(StatusNode sn, StatusList * sl) +void insert_into_status_struct(StatusNode sn, StatusList *sl) { assert(sl); TreeValue tv; @@ -286,13 +283,14 @@ void insert_into_status_struct(StatusNode sn, StatusList * sl) /* ------------------------------------------------------------ */ /*find the node with max Gradient within the distance (from viewpoint) //given */ -double find_max_gradient_in_status_struct(StatusList * sl, double dist, double angle, double gradient) +double find_max_gradient_in_status_struct(StatusList *sl, double dist, + double angle, double gradient) { assert(sl); /*note: if there is nothing in the status struccture, it means this cell is VISIBLE */ if (is_empty(sl)) - return SMALLEST_GRADIENT; + return SMALLEST_GRADIENT; /*it is also possible that the status structure is not empty, but there are no events with key < dist ---in this case it returns SMALLEST_GRADIENT; */ @@ -300,9 +298,9 @@ double find_max_gradient_in_status_struct(StatusList * sl, double dist, double a } /*returns true if it is empty */ -int is_empty(StatusList * sl) +int is_empty(StatusList *sl) { assert(sl); return (is_empty(sl->rbt) || - sl->rbt->root->value.maxGradient == SMALLEST_GRADIENT); + sl->rbt->root->value.maxGradient == SMALLEST_GRADIENT); } From 3cb02415242f6f1229616fa0935c3c628af8518a Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Wed, 4 Jan 2023 14:38:28 +0100 Subject: [PATCH 27/32] 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 bda11f8f71a..88cb1e52e24 100644 --- a/lib/gis/parser_interface.c +++ b/lib/gis/parser_interface.c @@ -113,7 +113,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 33f201c171b..10cd39ee0fa 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 0507d0bfe8c..90038a61e06 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 2e0e73be1cca31399b3433d53a59092e0b9448c1 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 19:57:28 +0100 Subject: [PATCH 28/32] 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 f258904a9c040f371da612aaaf68739b442200a1 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 20:05:46 +0100 Subject: [PATCH 29/32] 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 816b835bf2e3cfbcf15b2871b5fd350cd1a35e3f Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 21:42:20 +0100 Subject: [PATCH 30/32] 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 3eae7922903f7a90cec03ea87dce1f91c1b02eff Mon Sep 17 00:00:00 2001 From: Nicklas Larsson Date: Thu, 5 Jan 2023 01:24:26 +0100 Subject: [PATCH 31/32] pylint: ignore cmakelists.txt --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 486592c5f94..0d0bb653823 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -78,7 +78,7 @@ jobs: export PYTHONPATH=`grass --config python_path`:$PYTHONPATH export LD_LIBRARY_PATH=$HOME/install/grass83/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 c160dd577295336027073295b6288a779630bfb9 Mon Sep 17 00:00:00 2001 From: Markus Neteler Date: Wed, 4 Jan 2023 20:20:18 +0100 Subject: [PATCH 32/32] 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