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 #3621

Merged
merged 270 commits into from
Feb 22, 2025
Merged

build: Add CMake build #3621

merged 270 commits into from
Feb 22, 2025

Conversation

HuidaeCho
Copy link
Member

@HuidaeCho HuidaeCho commented Apr 18, 2024

This PR replaces #3021. Branched from https://github.com/nilason/grass/tree/cmake_build_work. Thanks @nilason!

Current status: I can compile the entire gisbase using CMake 3.29.1 and GCC 13.2.0. Running grass directly from build/gisbase works fine.

Windows Tests

For my records, message from message(WIN32=${WIN32}, MSVC=${MSVC}, MSYS=${MSYS}, MINGW=${MINGW}) on Windows (all from cmd in ssh):

CMake variables:

TODOs

  • Windows
  • macOS
  • locale
  • addon support
  • ...

Documentation

@Mahesh1998 and I are testing, fixing, and documenting this PR on Ubuntu. https://github.com/Mahesh1998/grass-docs/blob/main/cmake_build_docs/

Building on Windows

  1. Install Visual Studio Community Edition. Select these two components:
    • MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
    • Windows 11 SDK (10.0.26100.0)
  2. Install Git for Windows
  3. Install GitHub CLI
  4. Install Miniconda
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe
Miniconda3-latest-Windows-x86_64.exe /S /D=C:\opt\miniconda
C:\opt\miniconda\condabin\conda.bat init
  1. Start Developer Command Prompt for VS 2022
  2. Setup Conda for GRASS build
conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -n grass cmake pkg-config winflexbison proj libgdal pcre fftw openblas pdal wxpython pywin32
  1. Download the source code
git clone [email protected]:OSGeo/grass.git
cd grass
gh auth login
gh repo set-default
gh pr checkout 3621
  1. Build!
conda activate grass

mkdir build
cd build
cmake .. -DWITH_OPENGL=OFF > cmake.log 2>&1
msbuild grass.sln > msbuild.log 2>&1

Building on Slackware with Conda packages

Install Miniconda

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod a+x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh -b -u -p ~/usr/local/opt/miniconda
~/usr/local/opt/miniconda/bin/conda init
. ~/.bashrc
conda config --add channels conda-forge
conda config --set channel_priority strict

Create a new environment and install libraries

conda create -n grass proj libgdal fftw blas libpdal wxpython
conda activate grass

Build GRASS

mkdir build
cd build
# ignore warnings about runtime path (Conda libraries will be picked over system libraries)
cmake .. -DCMAKE_PREFIX_PATH=$HOME/usr/local/opt/miniconda/envs/grass
make -j`nproc`

Run GRASS

./output/bin/grass

@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 HuidaeCho mentioned this pull request Apr 18, 2024
21 tasks
@HuidaeCho HuidaeCho marked this pull request as draft April 18, 2024 12:30
@HuidaeCho HuidaeCho self-assigned this Apr 21, 2024
@HuidaeCho
Copy link
Member Author

HuidaeCho commented Apr 21, 2024

Current status: I can compile the entire gisbase using CMake 3.29.1 and GCC 13.2.0. Running grass directly from build/gisbase works fine.

For my records, message from message(WIN32=${WIN32}, MSVC=${MSVC}, MSYS=${MSYS}, MINGW=${MINGW}) on Windows (all from cmd in ssh):

CMake variables:

Copy link
Member

@echoix echoix left a comment

Choose a reason for hiding this comment

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

I did what I could to help out on this feature (that I really want) with what I'm good with, the CI. I made them as code suggestions to be easier to apply without being tedious.

@HuidaeCho
Copy link
Member Author

HuidaeCho commented Apr 22, 2024

I did what I could to help out on this feature (that I really want) with what I'm good with, the CI. I made them as code suggestions to be easier to apply without being tedious.

@echoix What YAML formatter should I use (e.g., working with pre-commit yamllint)? Are we/you already using one?

@nilason
Copy link
Contributor

nilason commented Apr 22, 2024

I did what I could to help out on this feature (that I really want) with what I'm good with, the CI. I made them as code suggestions to be easier to apply without being tedious.

@echoix What YAML formatter should I use (e.g., working with pre-commit yamllint)? Are we/you already using one?

pre-commit is using:

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.29.0
hooks:
- id: yamllint
args: [--format, parsable, --strict, -d,
'{extends: default, rules: {truthy: disable,
line-length: {max: 120, allow-non-breakable-words: true},
comments: {min-spaces-from-content: 1}}}']

@HuidaeCho
Copy link
Member Author

I did what I could to help out on this feature (that I really want) with what I'm good with, the CI. I made them as code suggestions to be easier to apply without being tedious.

@echoix What YAML formatter should I use (e.g., working with pre-commit yamllint)? Are we/you already using one?

pre-commit is using:

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.29.0
hooks:
- id: yamllint
args: [--format, parsable, --strict, -d,
'{extends: default, rules: {truthy: disable,
line-length: {max: 120, allow-non-breakable-words: true},
comments: {min-spaces-from-content: 1}}}']

Can I use yamllint for formatting? Looks like, it only checks, not format.

@nilason
Copy link
Contributor

nilason commented Apr 22, 2024

Can I use yamllint for formatting?

No.

Looks like, it only checks, not format.

Yes, it is only a linter ("checker") not formatter.

@nilason
Copy link
Contributor

nilason commented Apr 22, 2024

I have just tried this PR out and you've come a long way!
I hit some obstacles configuring/building on Mac, if you reached the point to receive a "pre-review" I'm glad to share my experiences.

@nilason
Copy link
Contributor

nilason commented Feb 22, 2025

Green!

Copy link
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

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

Awesome! What a great achievement! Thanks for all the hard work.

@HuidaeCho
Copy link
Member Author

Awesome! What a great achievement! Thanks for all the hard work.

Just one more approval away!

@hellik
Copy link
Member

hellik commented Feb 22, 2025

Is there any how-to available for testing locally in Windows?

@HuidaeCho
Copy link
Member Author

HuidaeCho commented Feb 22, 2025

Is there any how-to available for testing locally in Windows?

Please see the first block in this PR. Building on Windows.

Copy link
Contributor

@nilason nilason left a comment

Choose a reason for hiding this comment

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

Great teamwork, thank you all!

There's still a way for full functionality, but a very important milestone.

@nilason
Copy link
Contributor

nilason commented Feb 22, 2025

(The CI runner creates a testreport artefact, testing rate is now set at 72 per cent, so the report presents a convenient status update).

@nilason
Copy link
Contributor

nilason commented Feb 22, 2025

Note the CI speed for CMake, 22 mins, with full tests on ubuntu.

@echoix
Copy link
Member

echoix commented Feb 22, 2025

Note the CI speed for CMake, 22 mins, with full tests on ubuntu.

1 min 30s to configure+build. (Instead of 4 min now)!!. Both without cache, but the 4 minutes also uses a faster linker. Here I don't think the markdown docs and/or normal html docs are handled yet, and at least we don't uselessly (and inefficiently) create .pyc files at the wrong locations. I'm curious if make vs ninja has something to do here, or simply because the rules are now better defined. There's also some build flags that we use in the 4 minutes of equivalent CI runs that I know take a little longer than without.

@nilason
Copy link
Contributor

nilason commented Feb 22, 2025

I repost the draft commit message, for easy access, note: email addresses need to be filled in:

cmake: initial commit adding CMake support

Based on original work by Rashad Kanavath in 2020 with pull request:
https://github.com/OSGeo/grass/pull/289

This update introduces preliminary support for building and installing
GRASS GIS using CMake across multiple platforms, including Windows with
MSVS, Linux, and macOS. The installation can be performed using either
the traditional GRASS file structure or a structure that complies with
the Filesystem Hierarchy Standard (FHS).

Co-authored-by: @rkanavath
Co-authored-by: @neteler
Co-authored-by: Loïc Bartoletti <[email protected]>
Co-authored-by: Aaron Saw <[email protected]>
Co-authored-by: Nicklas Larsson <[email protected]>
Co-authored-by: Huidae Cho <[email protected]>
Co-authored-by: Mahesh Maddineni <[email protected]>
Co-authored-by: Kandel Nelson <[email protected]>
Co-authored-by: Edouard Choinière <[email protected]>

@HuidaeCho
Copy link
Member Author

HuidaeCho commented Feb 22, 2025

Update branch doesn't seem to work?

Response.json: Body has already been consumed.

@echoix
Copy link
Member

echoix commented Feb 22, 2025

Update branch doesn't seem to work?

We have the setting enabled to always show it (when the PR is not exactly up to date with the latest commit on the target branch). That means it's always an option, not that there is a problem with the PR and the merge won't be clean, merging would have worked anyway.

@HuidaeCho
Copy link
Member Author

Update branch doesn't seem to work?

We have the setting enabled to always show it (when the PR is not exactly up to date with the latest commit on the target branch). That means it's always an option, not that there is a problem with the PR and the merge won't be clean, merging would have worked anyway.

I can only see "Enable auto-merge (squash)" without the green Merge button. Just Updated branch and waiting...

@echoix
Copy link
Member

echoix commented Feb 22, 2025

Maybe there was still open conversations, but now the required jobs need to finish since it was updated.

@HuidaeCho
Copy link
Member Author

cmake: initial commit adding CMake support

Based on original work by Rashad Kanavath in 2020 with pull request:
#289

This update introduces preliminary support for building and installing
GRASS GIS using CMake across multiple platforms, including Windows with
MSVS, Linux, and macOS. The installation can be performed using either
the traditional GRASS file structure or a structure that complies with
the Filesystem Hierarchy Standard (FHS).

Co-authored-by: @rkanavath
Co-authored-by: @neteler
Co-authored-by: Loïc Bartoletti [email protected]
Co-authored-by: Aaron Saw [email protected]
Co-authored-by: Nicklas Larsson [email protected]
Co-authored-by: Huidae Cho [email protected]
Co-authored-by: Mahesh Maddineni [email protected]
Co-authored-by: Kandel Nelson [email protected]
Co-authored-by: Edouard Choinière [email protected]

Almost forgot... Will I see a textbox for this when I click Squash and merge?

@HuidaeCho
Copy link
Member Author

@nilason, What about this with GitHub handles?

cmake: initial commit adding CMake support

Based on original work by Rashad Kanavath in 2020 with pull request:
https://github.com/OSGeo/grass/pull/289

This update introduces preliminary support for building and installing
GRASS GIS using CMake across multiple platforms, including Windows with
MSVS, Linux, and macOS. The installation can be performed using either
the traditional GRASS file structure or a structure that complies with
the Filesystem Hierarchy Standard (FHS).

Co-authored-by: @rkanavath
Co-authored-by: @neteler
Co-authored-by: @lbartoletti
Co-authored-by: @aaronsms
Co-authored-by: @nilason
Co-authored-by: @HuidaeCho
Co-authored-by: @Mahesh1998
Co-authored-by: @KandelN
Co-authored-by: @echoix

@nilason
Copy link
Contributor

nilason commented Feb 22, 2025

@nilason, What about this with GitHub handles?

cmake: initial commit adding CMake support

Based on original work by Rashad Kanavath in 2020 with pull request:
https://github.com/OSGeo/grass/pull/289

This update introduces preliminary support for building and installing
GRASS GIS using CMake across multiple platforms, including Windows with
MSVS, Linux, and macOS. The installation can be performed using either
the traditional GRASS file structure or a structure that complies with
the Filesystem Hierarchy Standard (FHS).

Co-authored-by: @rkanavath
Co-authored-by: @neteler
Co-authored-by: @lbartoletti
Co-authored-by: @aaronsms
Co-authored-by: @nilason
Co-authored-by: @HuidaeCho
Co-authored-by: @Mahesh1998
Co-authored-by: @KandelN
Co-authored-by: @echoix

Would be better with the actual email addresses, please search in git log. I just didn't want to put them out here.

@HuidaeCho
Copy link
Member Author

@nilason, What about this with GitHub handles?

cmake: initial commit adding CMake support

Based on original work by Rashad Kanavath in 2020 with pull request:
https://github.com/OSGeo/grass/pull/289

This update introduces preliminary support for building and installing
GRASS GIS using CMake across multiple platforms, including Windows with
MSVS, Linux, and macOS. The installation can be performed using either
the traditional GRASS file structure or a structure that complies with
the Filesystem Hierarchy Standard (FHS).

Co-authored-by: @rkanavath
Co-authored-by: @neteler
Co-authored-by: @lbartoletti
Co-authored-by: @aaronsms
Co-authored-by: @nilason
Co-authored-by: @HuidaeCho
Co-authored-by: @Mahesh1998
Co-authored-by: @KandelN
Co-authored-by: @echoix

Would be better with the actual email addresses, please search in git log. I just didn't want to put them out here.

Oops.. If so, deleting my comment ;-)

@nilason
Copy link
Contributor

nilason commented Feb 22, 2025

Almost forgot... Will I see a textbox for this when I click Squash and merge?

Yes, there will be a single line where cmake: initial commit adding CMake support will go. The rest will go to the box.

@HuidaeCho HuidaeCho merged commit c12df29 into OSGeo:main Feb 22, 2025
28 checks passed
@HuidaeCho
Copy link
Member Author

HuidaeCho commented Feb 22, 2025

Finally MERGED after 5 years of work!!! Thanks everyone!

@nilason
Copy link
Contributor

nilason commented Feb 22, 2025

(@HuidaeCho I'll delete the post where the "accident" occurred. )

@nilason
Copy link
Contributor

nilason commented Feb 22, 2025

(Never mind!)

@echoix
Copy link
Member

echoix commented Feb 22, 2025

Is there a place where we can list some small issues all at one place?

@HuidaeCho
Copy link
Member Author

Is there a place where we can list some small issues all at one place?

Something like this? #5192

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 CSS Related code is in CSS database Related to database management display docker Docker related docs general GUI wxGUI related HTML Related code is in HTML imagery libraries macOS macOS specific misc module notebook Python Related code is in Python raster Related to raster data processing raster3d RFC Request For Comment (RFC) document temporal Related to temporal data processing tests Related to Test Suite translation Message translation related vector Related to vector data processing windows Microsoft Windows specific
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants