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

Added basic CI for MacOS and Windows #307

Conversation

makepath-alex
Copy link
Collaborator

@makepath-alex makepath-alex commented Dec 2, 2024

The current basic workflow is to use conda
It has been tested on Windows/Linux/Mac and WSL.
Unfortunately still on some systems we encounter errors, which I am trying to figure out as they emerge, but in most cases the workflow works as expected.
Steps to configure and build:

Create conda dev environment:

conda env create -f environment-dev.yml

Set environment variables:

export FC=gfortran
export FCFLAGS="-ffree-line-length-none -m64 -std=f2008 -march=native -fbounds-check -fmodule-private -fimplicit-none -finit-real=nan"
export RRTMGP_DATA_VERSION=v1.8.2
export FP_MODEL=DP
export RTE_CBOOL=ON
export RTE_KERNELS=default
export FAILURE_THRESHOLD=7.e-4

Configure build using Ninja. We use ninja becuase it is multiplatform and thus the setup is identical on Windows, Linux and Mac. Feel free to replace the genertor with another one of your choince, for example -G "Unix Makefiles"

cmake -S . -B build -G "Ninja" \
        -DCMAKE_Fortran_COMPILER=$FC \
        -DCMAKE_Fortran_FLAGS="$FCFLAGS" \
        -DRRTMGP_DATA_VERSION=$RRTMGP_DATA_VERSION \
        -DPRECISION=$FP_MODEL \
        -DUSE_C_BOOL=$RTE_CBOOL \
        -DKERNEL_MODE=$RTE_KERNELS \
        -DENABLE_TESTS=ON \
        -DFAILURE_THRESHOLD=$FAILURE_THRESHOLD \
        -DCMAKE_BUILD_TYPE=Debug

Note that we configure CMAKE for release build -DCMAKE_BUILD_TYPE=Release.
Alternatively if you want a debug configuration, change the work Release with Debug and debug flags like -g will automatically be added to the compiler.

The build configuration will be stored in build folder and then you can either go there and build the source using your generator's default instruments, or you can build it with Cmake. I prefer telling CMake to build it for me, this way it's the same command line that I can use on all OS and it's agnostic of the generator I use, be it Ninja, Makefiles or MS Visual Studio

cmake --build build --target all --parallel

Finally, if ENABLE_TESTS option was selected, you can also run the tests using

ctest --test-dir build/ -V

Important note.
Once CMake has been configured, all the build-rated files will be located in the build folder.
If you want to do small reconfigurations, you don't need to delete the entire build folder and start the process from scratch, you can simply go to the build folder and run simething like

cd build
cmake . -DENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release

This will update the existing configuration to disable tests and switch to Debug mode.

After that you need to recompile as usual.

@RobertPincus
Copy link
Member

@makepath-alex It seems like many of these changes in the PR are already in the makepath-cmake branch - do you know why so many files are still listed as being changed?

@makepath-alex
Copy link
Collaborator Author

makepath-alex commented Dec 4, 2024

@makepath-alex It seems like many of these changes in the PR are already in the makepath-cmake branch - do you know why so many files are still listed as being changed?

It was not updated. Should be better now :)

@makepath-alex makepath-alex force-pushed the cmake-mac-win-dev branch 2 times, most recently from 4ff2ae2 to e80e13f Compare December 6, 2024 09:34
@RobertPincus RobertPincus merged commit 3d99501 into earth-system-radiation:makepath-cmake Dec 11, 2024
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants