Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Add CMake build #3021

Closed
wants to merge 60 commits into from
Closed

Conversation

lbartoletti
Copy link
Contributor

@lbartoletti lbartoletti commented Jun 5, 2023

#2684 rebase on main with new fixes

  • r.in.pdal
  • r.buildvrt
  • r.fill.stats
  • d.rgb
  • d.rhumbline
  • d.text
  • d.title
  • d.vect
  • d.vect.chart
  • d.vect.thematic
  • r3.mapcalc
  • r.object.geometry
  • ps,map (from ps/ps.map/ps_map.c)

Missing (python) scripts from installation:

  • d.background
  • g.download.location
  • g.gui.rdigit
  • i.band.library
  • r.drain
  • r.semantic.label
  • t.copy
  • t.upgrade

add_subdirectory(proj)

file(GLOB raster_SRCS "./raster/*.c")
list(APPEND raster_SRCS "./gis/gisinit.c")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gisinit.c shouldn't be included in other translation units (TU) other than than the gislib. The G__ struct is supposed to be external linkage wrt to other libraries. There will be issues on MSVC like some unrecoginized symbol. But the right fix is to have declspec(import/export) on the G__ global struct.

DEFS ${_grass_display_DEFS}
DEPENDS ${_grass_display_DEPENDS})

add_subdirectory(db)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably standardize "add_subdirectory" vs inlining the library defines. Else it will be displayed under different folders in Visual Studio. I prefer the former.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with your proposal. Please don't hesitate to create a PR on my branch.

@wenzeslaus wenzeslaus changed the title Cmake build Add CMake build Jun 5, 2023
@aaronsms
Copy link
Contributor

aaronsms commented Jun 5, 2023

Here are some modules that are still left out since the last Cmake configuration:
(moved to the start)

@aaronsms
Copy link
Contributor

aaronsms commented Jun 5, 2023

I don't have maintainer rights, but you can checkout some commits from my local branch which is built on top this PR. After these changes, I can verify that I can reach the end of BUILD on CMake 3.26 on gcc13 on Ninja generator, mostly depending on system packages from Arch repository.

Still some work for Windows build and packaging.

@lbartoletti
Copy link
Contributor Author

I don't have maintainer rights, but you can checkout some commits from my local branch which is built on top this PR. After these changes, I can verify that I can reach the end of BUILD on CMake 3.26 on gcc13 on Ninja generator, mostly depending on system packages from Arch repository.

Still some work for Windows build and packaging.

Thanks, merged in 19600aa

@aaronsms
Copy link
Contributor

aaronsms commented Jun 5, 2023

Missing (python) scripts from installation:
(move to the start)

@lbartoletti
Copy link
Contributor Author

@aaronsms

  • d.rgb
  • d.rhumbline
  • d.text
  • d.title
  • d.vect
  • d.vect.chart
  • d.vect.thematic

rkanavath and others added 21 commits June 6, 2023 09:40
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669989265 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669989193 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669989189 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669989180 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669988019 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669987997 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669987899 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669986420 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669986410 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669985337 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669984062 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669984050 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 1669984037 +0100

parent 464ffca
author Rashad Kanavath <mohammedrashadkm@gmail.com> 1497210739 +0200
committer Markus Neteler <neteler@gmail.com> 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 ab2b961.

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 <mohammedrashadkm@gmail.com>

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 9e83f6f.

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 OSGeo#2681)
Attempt to add a CI workflow
Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com>
Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com>
Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com>
Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com>
Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com>
Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com>
Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com>
@lbartoletti
Copy link
Contributor Author

@lbartoletti Does this PR override #2684? If so, can we close #2684?

Yes!
But this PR is not totally finished.
@nilason by chance, was you able to continue this work?

@nilason
Copy link
Contributor

nilason commented Sep 26, 2023

@lbartoletti Does this PR override #2684? If so, can we close #2684?

Yes! But this PR is not totally finished. @nilason by chance, was you able to continue this work?

I believe we can close #2684. And yes, I did continue but it is still WIP. In case someone is very keen to continue in this very moment I can make a draft PR against "lbartoletti:cmake_build" branch for reference. I did substantially more than just incremental changes...

@petrasovaa
Copy link
Contributor

petrasovaa commented Mar 1, 2024

How much 'finished' this needs to be before merging it? Is unfinished cmake transition going to break things?

If the changes of the actual grass code isn't affected, it shouldn't break our current builds. But it won't work correctly yet to build with CMake.

@HuidaeCho
Copy link
Member

I'm currently looking into a possibility of automating this conversion from Makefile to CMake. Converting Existing Systems To CMake

@github-actions github-actions bot added GUI wxGUI related CI Continuous integration vector Related to vector data processing raster Related to raster data processing temporal Related to temporal data processing C Related code is in C C++ Related code is in C++ database Related to database management libraries module docs general display imagery raster3d misc labels Apr 18, 2024
@HuidaeCho
Copy link
Member

Replaced by #3621. Closing it.

@HuidaeCho HuidaeCho closed this Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C C++ Related code is in C++ CI Continuous integration database Related to database management display docs enhancement New feature or request general GUI wxGUI related imagery libraries misc module raster Related to raster data processing raster3d temporal Related to temporal data processing vector Related to vector data processing
Development

Successfully merging this pull request may close these issues.

7 participants