Skip to content

Commit 5c1f89a

Browse files
authored
Merge pull request #458 from robotology/fixrobsub1690
Fix regression(s) introduced by YCMEPHelper refactor
2 parents 50ce674 + 4017827 commit 5c1f89a

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

YCMConfig.cmake.in

+12-3
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,20 @@ if(NOT DEFINED YCM_USE_CMAKE OR YCM_USE_CMAKE)
4141
endif()
4242

4343
# Use modules from unreleased CMake (default ON)
44-
if(NOT DEFINED YCM_USE_CMAKE_NEXT OR NOT YCM_USE_CMAKE_NEXT)
45-
set_property(GLOBAL PROPERTY YCM_USE_CMAKE_NEXT OFF)
44+
if(CMAKE_VERSION VERSION_LESS 3.22)
45+
set(YCM_USE_CMAKE_NEXT_DEFAULT_VALUE ON)
4646
else()
47+
set(YCM_USE_CMAKE_NEXT_DEFAULT_VALUE OFF)
48+
endif()
49+
option(YCM_USE_CMAKE_NEXT "Use legacy YCM fork of ExternalProject module instead of upstream CMake ExternalProject" ${YCM_USE_CMAKE_NEXT_DEFAULT_VALUE})
50+
if(NOT YCM_USE_CMAKE_NEXT AND CMAKE_VERSION VERSION_LESS 3.22)
51+
message(FATAL_ERROR "YCM_USE_CMAKE_NEXT set to OFF is not supported with CMake < 3.22")
52+
endif()
53+
if(YCM_USE_CMAKE_NEXT)
4754
set_property(GLOBAL PROPERTY YCM_USE_CMAKE_NEXT ON)
48-
list(APPEND YCM_MODULE_PATH "${YCM_MODULE_DIR}/cmake-next/proposed")
55+
list(APPEND CMAKE_MODULE_PATH ${_YCM_SRC_DIR}/cmake-next/proposed)
56+
else()
57+
set_property(GLOBAL PROPERTY YCM_USE_CMAKE_NEXT OFF)
4958
endif()
5059

5160
# Use modules from specific CMake versions (default ON)

modules/YCMEPHelper.cmake

+17-3
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,10 @@ function(YCM_EP_HELPER _name)
11601160
# a git repo folder if it already exists
11611161

11621162
# We do not define the custom GIT DOWNLOAD command if the outside call of YCMEPHelper already redefined it
1163-
if(NOT DEFINED _YH_${_name}_DOWNLOAD_COMMAND)
1163+
# or if we are using the vendored ExternalProject of YCM, that already redefines DOWNLOAD internally
1164+
get_property(_yeph_YCM_USE_CMAKE_NEXT GLOBAL PROPERTY YCM_USE_CMAKE_NEXT)
1165+
1166+
if(NOT DEFINED _YH_${_name}_DOWNLOAD_COMMAND AND NOT _yeph_YCM_USE_CMAKE_NEXT)
11641167
# Coherently with how the gitclone command is created inside ExternalProject, we also define a CMake
11651168
# script that defines the clone commands, and then we call it
11661169
# This part is inspired by https://gitlab.kitware.com/cmake/cmake/-/blob/v3.30.2/Modules/ExternalProject/shared_internal_commands.cmake#L945-1034
@@ -1186,8 +1189,8 @@ function(YCM_EP_HELPER _name)
11861189
set(git_remote_name "origin")
11871190
endif()
11881191

1189-
_ep_get_tls_version(${_name} tls_version)
1190-
_ep_get_tls_verify(${_name} tls_verify)
1192+
set(tls_version "")
1193+
set(tls_verify "")
11911194
set(git_shallow "${_YH_${_name}_SHALLOW}")
11921195
set(git_progress "")
11931196
set(git_config "")
@@ -1216,6 +1219,7 @@ submodules=${git_submodules}
12161219
get_filename_component(work_dir "${${_name}_SOURCE_DIR}" PATH)
12171220

12181221
set(clone_script ${${_name}_TMP_DIR}/${_name}-gitsafeclone.cmake)
1222+
set(stamp_dir ${${_name}_STAMP_DIR})
12191223
_ycm_ep_write_gitclone_script(
12201224
${clone_script}
12211225
${${_name}_SOURCE_DIR}
@@ -1242,6 +1246,16 @@ submodules=${git_submodules}
12421246
-P ${clone_script}
12431247
)
12441248

1249+
# We use configure_file() to write the repo_info_file for compatibility
1250+
# with upstreams CMake's gitclone
1251+
1252+
set(repo_info_file ${stamp_dir}/${_name}-gitinfo.txt)
1253+
configure_file(
1254+
"${YCM_MODULE_DIR}/modules/YCMEPHelper/RepositoryInfo.txt.in"
1255+
"${repo_info_file}"
1256+
@ONLY
1257+
)
1258+
12451259
list(APPEND ${_name}_COMMAND_ARGS DOWNLOAD_COMMAND "${cmd}")
12461260
endif()
12471261

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This is a generated file and its contents are an internal implementation detail.
2+
# The download step will be re-executed if anything in this file changes.
3+
# No other meaning or use of this file is supported.
4+
5+
method=git
6+
command=@cmd@
7+
source_dir=@source_dir@
8+
work_dir=@work_dir@
9+
@extra_repo_info@
10+

modules/YCMEPHelper/gitsafeclone.txt.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ if(EXISTS "@source_dir@")
7575
set(number_of_tries 0)
7676
while(error_code AND number_of_tries LESS 3)
7777
execute_process(
78-
COMMAND "@git_EXECUTABLE@" fetch @git_clone_options@ origin
78+
COMMAND "@git_EXECUTABLE@" fetch origin
7979
WORKING_DIRECTORY "@work_dir@/@src_name@"
8080
RESULT_VARIABLE error_code
8181
)

tools/UseYCMFromSource.cmake

+11-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ list(APPEND CMAKE_MODULE_PATH ${_YCM_SRC_DIR}/modules)
1616
list(APPEND CMAKE_MODULE_PATH ${_YCM_SRC_DIR}/find-modules)
1717
list(APPEND CMAKE_MODULE_PATH ${_YCM_SRC_DIR}/build-modules)
1818
list(APPEND CMAKE_MODULE_PATH ${_YCM_SRC_DIR}/style-modules)
19-
if(NOT DEFINED YCM_USE_CMAKE_NEXT OR YCM_USE_CMAKE_NEXT)
19+
20+
if(CMAKE_VERSION VERSION_LESS 3.22)
21+
set(YCM_USE_CMAKE_NEXT_DEFAULT_VALUE ON)
22+
else()
23+
set(YCM_USE_CMAKE_NEXT_DEFAULT_VALUE OFF)
24+
endif()
25+
option(YCM_USE_CMAKE_NEXT "Use legacy YCM fork of ExternalProject module instead of upstream CMake ExternalProject" ${YCM_USE_CMAKE_NEXT_DEFAULT_VALUE})
26+
if(NOT YCM_USE_CMAKE_NEXT AND CMAKE_VERSION VERSION_LESS 3.22)
27+
message(FATAL_ERROR "YCM_USE_CMAKE_NEXT set to OFF is not supported with CMake < 3.22")
28+
endif()
29+
if(YCM_USE_CMAKE_NEXT)
2030
set_property(GLOBAL PROPERTY YCM_USE_CMAKE_NEXT ON)
2131
list(APPEND CMAKE_MODULE_PATH ${_YCM_SRC_DIR}/cmake-next/proposed)
2232
else()

0 commit comments

Comments
 (0)