@@ -22,22 +22,46 @@ set(PROJECT_URL
2222set (PROJECT_USE_CMAKE_EXPORT TRUE )
2323
2424# Check if the submodule cmake have been initialized
25- if (NOT EXISTS "${CMAKE_SOURCE_DIR} /cmake/base.cmake" )
26- message (
27- FATAL_ERROR
28- "\n Please run the following command first:\n git submodule update --init\n "
29- )
25+ set (JRL_CMAKE_MODULES "${CMAKE_CURRENT_LIST_DIR} /cmake" )
26+ if (EXISTS "${JRL_CMAKE_MODULES} /base.cmake" )
27+ message (STATUS "JRL cmakemodules found in 'cmake/' git submodule" )
28+ else ()
29+ find_package (jrl-cmakemodules QUIET CONFIG)
30+ if (jrl-cmakemodules_FOUND)
31+ get_property (
32+ JRL_CMAKE_MODULES
33+ TARGET jrl-cmakemodules::jrl-cmakemodules
34+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES )
35+ message (STATUS "JRL cmakemodules found on system at ${JRL_CMAKE_MODULES} " )
36+ elseif (${CMAKE_VERSION} VERSION_LESS "3.14.0" )
37+ message (
38+ FATAL_ERROR
39+ "\n Can't find jrl-cmakemodules. Please either:\n "
40+ " - use git submodule: 'git submodule update --init'\n "
41+ " - or install https://github.com/jrl-umi3218/jrl-cmakemodules\n "
42+ " - or upgrade your CMake version to >= 3.14 to allow automatic fetching\n "
43+ )
44+ else ()
45+ message (STATUS "JRL cmakemodules not found. Let's fetch it." )
46+ include (FetchContent)
47+ FetchContent_Declare(
48+ "jrl-cmakemodules"
49+ GIT_REPOSITORY "https://github.com/jrl-umi3218/jrl-cmakemodules.git" )
50+ FetchContent_MakeAvailable("jrl-cmakemodules" )
51+ FetchContent_GetProperties("jrl-cmakemodules" SOURCE_DIR JRL_CMAKE_MODULES)
52+ endif ()
3053endif ()
3154
3255# --- OPTIONS ----------------------------------------
3356option (BUILD_PYTHON_INTERFACE "Build the python binding" ON )
3457option (PYTHON_STANDARD_LAYOUT "Enable standard Python package layout" ON )
3558option (PYTHON_DEB_LAYOUT "Enable Debian-style Python package layout" OFF )
36- include (cmake/base.cmake)
37- include (cmake/boost.cmake)
38- include (cmake/python.cmake)
39- include (cmake/ide.cmake)
40- include (cmake/apple .cmake)
59+
60+ include ("${JRL_CMAKE_MODULES} /base.cmake" )
61+ include ("${JRL_CMAKE_MODULES} /boost.cmake" )
62+ include ("${JRL_CMAKE_MODULES} /python.cmake" )
63+ include ("${JRL_CMAKE_MODULES} /ide.cmake" )
64+ include ("${JRL_CMAKE_MODULES} /apple.cmake" )
4165
4266compute_project_args(PROJECT_ARGS LANGUAGES CXX)
4367project (${PROJECT_NAME} ${PROJECT_ARGS} )
0 commit comments