Skip to content

Commit 94b9d84

Browse files
author
Liam Merino
committed
Fix install path duplication when source root contains regex metacharacters
draco_install.cmake stripped ${draco_src_root} from header paths via list(TRANSFORM ... REPLACE), whose pattern is a regex. When ${draco_src_root} contained a regex metacharacter (e.g. '+' or '.'), the strip silently failed and install(FILES) re-prepended the prefix, producing a doubled path that broke `cmake --install`. Replace with per-element file(RELATIVE_PATH ...), the path-aware API. Available since CMake 3.0; no minimum-version bump. Fixes #1132.
1 parent 77e616e commit 94b9d84

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

cmake/draco_install.cmake

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ macro(draco_setup_install_target)
3737

3838
list(REMOVE_DUPLICATES draco_api_includes)
3939

40-
# Strip $draco_src_root from the file paths: we need to install relative to
41-
# $include_directory.
42-
list(TRANSFORM draco_api_includes REPLACE "${draco_src_root}/" "")
43-
40+
# Use file(RELATIVE_PATH) — not list(TRANSFORM REPLACE) — because the
41+
# REPLACE pattern is a regex, and ${draco_src_root} may contain regex
42+
# metacharacters (e.g. '+', '.') in package-manager and sandboxed paths.
4443
foreach(draco_api_include ${draco_api_includes})
45-
get_filename_component(file_directory ${draco_api_include} DIRECTORY)
44+
file(RELATIVE_PATH rel_include "${draco_src_root}" "${draco_api_include}")
45+
get_filename_component(file_directory "${rel_include}" DIRECTORY)
4646
set(target_directory "${includes_path}/draco/${file_directory}")
47-
install(FILES ${draco_src_root}/${draco_api_include}
47+
install(FILES "${draco_api_include}"
4848
DESTINATION "${target_directory}")
4949
endforeach()
5050

0 commit comments

Comments
 (0)