Skip to content

Conversation

@cabreraam
Copy link

@cabreraam cabreraam commented Apr 26, 2022

Hello SNAP devs,

Out of a need to build SNAP with CMakeLists.txt for a different project (directly related to #19), I have implemented CMake build infrastructure for SNAP. In using modern CMake, I tried as much as possible to make it the CMakeLists.txt file easy to understand for folks who are used to the Make build infrastructure. Credit to @banach-space for helping stir me into using modern CMake constructs.

Here are some of the salient features of my CMake contribution:

  1. Instead of having different build targets for different compilers, e.g., gsnap, isnap, there is a single build target called snap. The idea now would that developers would create a different build directory each time they wanted to try out a new compiler, e.g., build_gnu.

An example build may take on the following form, as given in a bash script:

#!/usr/bin/env bash

mkdir -p build_gnu
cd build_gnu

# mpifort doesn't set all of the MPI_Fortran_* stuff
# As long as we specify MPI, all of the MPI_Fortran_* stuff gets set
CMAKE_OPTIONS="-DCMAKE_Fortran_COMPILER=gfortran \
        -DOPENMP=ON \
        -DMPI=ON \
        -DOPT=ON \
        -DCRAY=ON \
"

cmake ${CMAKE_OPTIONS} ..
make VERBOSE=1 -j4
  1. The build options specified by the original Makefile all exist in the CMakeLists.txt files. As shown above in the script, they should be passed in as CMake build options. Of note is the CRAY variable. In the original makefile, information for MPI include and library directories are only passed if MPI is set to "cray". I've honored that in my Makefile, but the way I've written it, developers should specify -DCRAY=ON for now, in order to pass include and library directories for MPI.

  2. There is a custom target called count which is equivalent to the original Makefile target count.

I've tested with both Make and Ninja as generators.

I would appreciate if y'all would test my contribution to see if it's worth adding.

Thanks!
Anthony

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.

1 participant