Skip to content

Commit c1cd9c3

Browse files
authored
Merge pull request #124 from WardF/param_git_tag.wif
Parameterize dependencies to allow for easier testing against PRs, branches.
2 parents 7536fbc + a038ac1 commit c1cd9c3

File tree

2 files changed

+69
-8
lines changed

2 files changed

+69
-8
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,37 @@ Pre-made grids for use in MUSICA are available [here](https://wiki.ucar.edu/disp
2727
Checkout our [software development plan](docs/Software%20Development%20Plan.pdf)
2828
to see how you can contribute new science to MUSICA software.
2929

30+
## Developer Options
31+
32+
### Specifying dependency versions via paramaterization at configure time
33+
34+
Introduced in [Pull Request #124](https://github.com/NCAR/musica/pull/124), it is possible for developers to specify which versions of various dependencies should be used. These options are currently limited to those dependencies managed via `FetchContent`. This change allows for more easily testing `musica` against changes committed in different repositories and branches. The environmental variables introduced are outlined in the following table.
35+
36+
#### CMake Dependency Variables
37+
38+
| Musica Dependency | Repository | Branch, Tag or Hash|
39+
| ------------------------------------------------------ | --------------------------|--------------------|
40+
| [Google Test](https://github.com/google/googletest.git)| GOOGLETEST_GIT_REPOSITORY | GOOGLETEST_GIT_TAG |
41+
| [MICM](https://github.com/NCAR/mcim.git) | MICM_GIT_REPOSITORY | MICM_GIT_TAG |
42+
| [TUV-X](https://github.com/NCAR/tuv-x.git) | TUVX_GIT_REPOSITORY | TUVX_GIT_TAG |
43+
| [PyBind11](https://github.com/pybind/pybind11) | PYBIND11_GIT_REPOSITORY | PYBIND11_GIT_TAG |
44+
45+
#### Example Usage
46+
47+
> The following examples assume the working directory is a `build/` directory inside the `musica` source directory.
48+
49+
Specifying a different version of `tuv-x`, to ensure a change won't break anything.
50+
51+
$ cmake .. \
52+
-DTUVX_GIT_REPOSITORY="https://github.com/WardF/tuv-x.git" \
53+
-DTUVX_GIT_TAG=test-fix
54+
55+
Specifying a specific version of `tuv-x` by has, but using the official repository.
56+
57+
$ cmake .. \
58+
-DTUVX_GIT_TAG=a6b2c4d8745
59+
60+
3061
## Citing MUSICA
3162

3263
MUSICA can be cited in at least two ways. The first is to cite [the paper](https://doi.org/10.1175/BAMS-D-19-0331.1) that defines the vision

cmake/dependencies.cmake

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
include(FetchContent)
22

3+
4+
################################################################################
5+
# Function to reduce repeated code, set a value to a variable only if the
6+
# variable is not already defined.
7+
function(set_git_default git_var git_val)
8+
9+
if(NOT ${git_var})
10+
set(${git_var} ${git_val} PARENT_SCOPE)
11+
endif()
12+
13+
endfunction(set_git_default)
14+
315
################################################################################
416
# NetCDF library
517
if (MUSICA_BUILD_FORTRAN_INTERFACE)
@@ -10,9 +22,14 @@ endif()
1022
################################################################################
1123
# google test
1224
if(MUSICA_ENABLE_TESTS)
25+
26+
set_git_default(GOOGLETEST_GIT_REPOSITORY https://github.com/google/googletest.git)
27+
set_git_default(GOOGLETEST_GIT_TAG be03d00f5f0cc3a997d1a368bee8a1fe93651f48)
28+
1329
FetchContent_Declare(googletest
14-
GIT_REPOSITORY https://github.com/google/googletest.git
15-
GIT_TAG be03d00f5f0cc3a997d1a368bee8a1fe93651f48
30+
GIT_REPOSITORY ${GOOGLETEST_GIT_REPOSITORY}
31+
GIT_TAG ${GOOGLETEST_GIT_TAG}
32+
GIT_PROGRESS NOT ${FETCHCONTENT_QUIET}
1633
)
1734

1835
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
@@ -31,9 +48,14 @@ endif()
3148
# MICM
3249

3350
if (MUSICA_ENABLE_MICM AND MUSICA_BUILD_C_CXX_INTERFACE)
51+
52+
set_git_default(MICM_GIT_REPOSITORY https://github.com/NCAR/micm.git)
53+
set_git_default(MICM_GIT_TAG 2a5cd4e11a6973974f3c584dfa9841d70e0a42d5)
54+
3455
FetchContent_Declare(micm
35-
GIT_REPOSITORY https://github.com/NCAR/micm.git
36-
GIT_TAG 8c4cff0d
56+
GIT_REPOSITORY ${MICM_GIT_REPOSITORY}
57+
GIT_TAG ${MICM_GIT_TAG}
58+
GIT_PROGRESS NOT ${FETCHCONTENT_QUIET}
3759
)
3860
set(MICM_ENABLE_TESTS OFF)
3961
set(MICM_ENABLE_EXAMPLES OFF)
@@ -50,9 +72,13 @@ if (MUSICA_ENABLE_TUVX AND MUSICA_BUILD_C_CXX_INTERFACE)
5072
set(TUVX_INSTALL_MOD_DIR ${MUSICA_INSTALL_INCLUDE_DIR} CACHE STRING "" FORCE)
5173
set(TUVX_INSTALL_INCLUDE_DIR ${MUSICA_INSTALL_INCLUDE_DIR} CACHE STRING "" FORCE)
5274

75+
set_git_default(TUVX_GIT_REPOSITORY https://github.com/NCAR/tuv-x.git)
76+
set_git_default(TUVX_GIT_TAG 6ff27992da1485392329208b736d2ec1522dafa3)
77+
5378
FetchContent_Declare(tuvx
54-
GIT_REPOSITORY https://github.com/NCAR/tuv-x.git
55-
GIT_TAG 6ff27992da1485392329208b736d2ec1522dafa3
79+
GIT_REPOSITORY ${TUVX_GIT_REPOSITORY}
80+
GIT_TAG ${TUVX_GIT_TAG}
81+
GIT_PROGRESS NOT ${FETCHCONTENT_QUIET}
5682
)
5783

5884
FetchContent_MakeAvailable(tuvx)
@@ -63,9 +89,13 @@ endif()
6389
if(MUSICA_ENABLE_PYTHON_LIBRARY)
6490
set(PYBIND11_NEWPYTHON ON)
6591

92+
set_git_default(PYBIND11_GIT_REPOSITORY https://github.com/pybind/pybind11)
93+
set_git_default(PYBIND11_GIT_TAG v2.12.0)
94+
6695
FetchContent_Declare(pybind11
67-
GIT_REPOSITORY https://github.com/pybind/pybind11
68-
GIT_TAG v2.12.0
96+
GIT_REPOSITORY ${PYBIND11_GIT_REPOSITORY}
97+
GIT_TAG ${PYBIND11_GIT_TAG}
98+
GIT_PROGRESS NOT ${FETCHCONTENT_QUIET}
6999
)
70100

71101
FetchContent_GetProperties(pybind11)

0 commit comments

Comments
 (0)