cmake: Call get_filename_component() with DIRECTORY mode instead of PATH mode (#9614)
PATH mode is legacy alias for DIRECTORY mode (needed only for CMake <= 2.8.11):
https://cmake.org/cmake/help/latest/command/get_filename_component.html
diff --git a/cmake/install.cmake b/cmake/install.cmake
index 9b5f433..825cb25 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -51,7 +51,7 @@
string(REPLACE "\\" "/" _header ${_header})
get_filename_component(_extract_from "${protobuf_SOURCE_DIR}/src/${_header}" ABSOLUTE)
get_filename_component(_extract_name ${_header} NAME)
- get_filename_component(_extract_to "${CMAKE_INSTALL_INCLUDEDIR}/${_header}" PATH)
+ get_filename_component(_extract_to "${CMAKE_INSTALL_INCLUDEDIR}/${_header}" DIRECTORY)
if(EXISTS "${_extract_from}")
install(FILES "${_extract_from}"
DESTINATION "${_extract_to}"
@@ -88,10 +88,10 @@
foreach(_file ${nobase_dist_proto_DATA})
get_filename_component(_file_from "${protobuf_SOURCE_DIR}/src/${_file}" ABSOLUTE)
get_filename_component(_file_name ${_file} NAME)
- get_filename_component(_file_path ${_file} PATH)
+ get_filename_component(_dir ${_file} DIRECTORY)
if(EXISTS "${_file_from}")
install(FILES "${_file_from}"
- DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_file_path}"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_dir}"
COMPONENT protobuf-protos
RENAME "${_file_name}")
else()
diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in
index b433209..6166911 100644
--- a/cmake/protobuf-config.cmake.in
+++ b/cmake/protobuf-config.cmake.in
@@ -84,10 +84,10 @@
# Create an include path for each file specified
foreach(_file ${protobuf_generate_PROTOS})
get_filename_component(_abs_file ${_file} ABSOLUTE)
- get_filename_component(_abs_path ${_abs_file} PATH)
- list(FIND _protobuf_include_path ${_abs_path} _contains_already)
+ get_filename_component(_abs_dir ${_abs_file} DIRECTORY)
+ list(FIND _protobuf_include_path ${_abs_dir} _contains_already)
if(${_contains_already} EQUAL -1)
- list(APPEND _protobuf_include_path -I ${_abs_path})
+ list(APPEND _protobuf_include_path -I ${_abs_dir})
endif()
endforeach()
endif()
diff --git a/cmake/tests.cmake b/cmake/tests.cmake
index c92b07e..931de2e 100644
--- a/cmake/tests.cmake
+++ b/cmake/tests.cmake
@@ -92,7 +92,7 @@
)
macro(compile_proto_file filename)
- get_filename_component(dirname ${filename} PATH)
+ get_filename_component(dirname ${filename} DIRECTORY)
get_filename_component(basename ${filename} NAME_WE)
add_custom_command(
OUTPUT ${protobuf_SOURCE_DIR}/src/${dirname}/${basename}.pb.cc