Skip to content

Commit ddb28c4

Browse files
committed
intregrate get-jrl-cmakemodules.cmake
1 parent 0946867 commit ddb28c4

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@ project(
77
HOMEPAGE_URL "https://github.com/stack-of-tasks/eigenpy"
88
)
99

10-
set(JRL_CMAKEMODULES_USE_V2 ON CACHE BOOL "Use jrl-cmakemodules v2")
11-
if(JRL_CMAKEMODULES_SOURCE_DIR)
12-
message(STATUS "Using jrl-cmakemodules from source directory: ${JRL_CMAKEMODULES_SOURCE_DIR}")
13-
add_subdirectory(${JRL_CMAKEMODULES_SOURCE_DIR} jrl-cmakemodules)
14-
else()
15-
find_package(jrl-cmakemodules 0.2.0 CONFIG REQUIRED)
16-
endif()
10+
include(cmake/get-jrl-cmakemodules.cmake)
1711

1812
jrl_configure_defaults()
1913

cmake/get-jrl-cmakemodules.cmake

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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

Comments
 (0)