|
| 1 | +# Get jrl-cmakemodules package |
| 2 | + |
| 3 | +# Upstream (https://github.com/jrl-umi3218/jrl-cmakemodules), the new v2 version is located in a subfolder, |
| 4 | +# We need to set this variable to bypass the v1 and load the v2. |
| 5 | +set( |
| 6 | + JRL_CMAKEMODULES_USE_V2 |
| 7 | + ON |
| 8 | + CACHE BOOL |
| 9 | + "Use jrl-cmakemodules v2 on https://github.com/jrl-umi3218/jrl-cmakemodules" |
| 10 | +) |
| 11 | + |
| 12 | +# Option 1: pass -DJRL_CMAKEMODULES_SOURCE_DIR=... to cmake command line |
| 13 | +if(JRL_CMAKEMODULES_SOURCE_DIR) |
| 14 | + message( |
| 15 | + DEBUG |
| 16 | + "JRL_CMAKEMODULES_SOURCE_DIR variable set, adding jrl-cmakemodules from source directory: ${JRL_CMAKEMODULES_SOURCE_DIR}" |
| 17 | + ) |
| 18 | + add_subdirectory(${JRL_CMAKEMODULES_SOURCE_DIR} jrl-cmakemodules) |
| 19 | + return() |
| 20 | +endif() |
| 21 | + |
| 22 | +# Option 2: use JRL_CMAKEMODULES_SOURCE_DIR environment variable (pixi might unset it, prefer option 1) |
| 23 | +if(ENV{JRL_CMAKEMODULES_SOURCE_DIR}) |
| 24 | + message( |
| 25 | + DEBUG |
| 26 | + "JRL_CMAKEMODULES_SOURCE_DIR environement variable set, adding jrl-cmakemodules from source directory: ${JRL_CMAKEMODULES_SOURCE_DIR}" |
| 27 | + ) |
| 28 | + add_subdirectory(${JRL_CMAKEMODULES_SOURCE_DIR} jrl-cmakemodules) |
| 29 | + return() |
| 30 | +endif() |
| 31 | + |
| 32 | +# Try to look for the installed package |
| 33 | +message(DEBUG "Looking for jrl-cmakemodules package...") |
| 34 | +find_package(jrl-cmakemodules CONFIG QUIET) |
| 35 | + |
| 36 | +# If we have the package, we are done. |
| 37 | +if(jrl-cmakemodules_FOUND) |
| 38 | + message(DEBUG "Found jrl-cmakemodules package.") |
| 39 | + return() |
| 40 | +endif() |
| 41 | + |
| 42 | +# Fallback to FetchContent if not found |
| 43 | +message(DEBUG "Fetching jrl-cmakemodules using FetchContent...") |
| 44 | +include(FetchContent) |
| 45 | +FetchContent_Declare( |
| 46 | + jrl-cmakemodules |
| 47 | + GIT_REPOSITORY https://github.com/ahoarau/jrl-cmakemodules-v2 |
| 48 | + GIT_TAG main |
| 49 | +) |
| 50 | +FetchContent_MakeAvailable(jrl-cmakemodules) |
0 commit comments