Skip to content

Commit 5d496eb

Browse files
committed
[CMake] FetchContent on missing submodule
1 parent c279e00 commit 5d496eb

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

CMakeLists.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@ SET(PROJECT_USE_KEYWORD_LINK_LIBRARIES TRUE)
1313
SET(PROJECT_CUSTOM_HEADER_EXTENSION "hpp")
1414

1515
# Check if the submodule cmake have been initialized
16+
set(JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR}/cmake")
1617
IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/cmake/base.cmake")
17-
MESSAGE(FATAL_ERROR "\nPlease run the following command first:\ngit submodule update --init\n")
18+
IF(${CMAKE_VERSION} VERSION_LESS "3.14.0")
19+
MESSAGE(FATAL_ERROR "\nPlease run the following command first:\ngit submodule update --init\n")
20+
ELSE()
21+
message(STATUS "JRL cmakemodules not found. Let's fetch it.")
22+
include(FetchContent)
23+
FetchContent_Declare("jrl-cmakemodules"
24+
GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git")
25+
FetchContent_MakeAvailable("jrl-cmakemodules")
26+
FetchContent_GetProperties("jrl-cmakemodules" SOURCE_DIR JRL_CMAKE_MODULES)
27+
ENDIF()
1828
ENDIF()
1929

2030
# Disable -Werror on Unix for now.
@@ -35,14 +45,14 @@ IF(DEFINED BUILD_UNIT_TESTS)
3545
SET(BUILD_TESTING ${BUILD_UNIT_TESTS})
3646
ENDIF(DEFINED BUILD_UNIT_TESTS)
3747

38-
INCLUDE(cmake/base.cmake)
48+
INCLUDE("${JRL_CMAKE_MODULES}/base.cmake")
3949
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
4050
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
4151

42-
INCLUDE(cmake/boost.cmake)
43-
INCLUDE(cmake/python.cmake)
44-
INCLUDE(cmake/ide.cmake)
45-
INCLUDE(cmake/apple.cmake)
52+
INCLUDE("${JRL_CMAKE_MODULES}/boost.cmake")
53+
INCLUDE("${JRL_CMAKE_MODULES}/python.cmake")
54+
INCLUDE("${JRL_CMAKE_MODULES}/ide.cmake")
55+
INCLUDE("${JRL_CMAKE_MODULES}/apple.cmake")
4656

4757
OPTION(GENERATE_PYTHON_STUBS "Generate the Python stubs associated to the Python library" OFF)
4858

python/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ SET(PYWRAP ${PROJECT_NAME}_pywrap)
77
SET(PYWRAP ${PYWRAP} PARENT_SCOPE)
88

99
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/python/${PROJECT_NAME}")
10-
include(${PROJECT_SOURCE_DIR}/cmake/stubs.cmake)
10+
include("${JRL_CMAKE_MODULES}/stubs.cmake")
1111

1212
ADD_CUSTOM_TARGET(python)
1313
SET_TARGET_PROPERTIES(python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True)
@@ -58,4 +58,3 @@ FOREACH(python ${PYTHON_FILES})
5858
"${CMAKE_CURRENT_SOURCE_DIR}/eigenpy/${python}"
5959
DESTINATION ${${PYWRAP}_INSTALL_DIR})
6060
ENDFOREACH(python)
61-

0 commit comments

Comments
 (0)