Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally use cmake_path on cmake < 3.20 #424

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions gz-msgs-extras.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ include(${@PROJECT_NAME@_DIR}/gz_msgs_factory.cmake)
include(${@PROJECT_NAME@_DIR}/gz_msgs_generate.cmake)

set(@PROJECT_NAME@_INSTALL_PATH "${@PROJECT_NAME@_DIR}/@PROJECT_CMAKE_EXTRAS_PATH_TO_PREFIX@")
cmake_path(NORMAL_PATH @PROJECT_NAME@_INSTALL_PATH OUTPUT_VARIABLE @PROJECT_NAME@_INSTALL_PATH)

if(CMAKE_VERSION VERSION_LESS "3.20.0")
file(TO_CMAKE_PATH @PROJECT_NAME@_INSTALL_PATH NORMALIZED_PATH) # Converts native path to CMake style with forward slashes.
get_filename_component(ABSOLUTE_PATH "${NORMALIZED_PATH}" ABSOLUTE) # Extracts the absolute path component.
set(@PROJECT_NAME@_INSTALL_PATH "${ABSOLUTE_PATH}") # Stores the normalized absolute path back to the original variable.
else()
cmake_path(NORMAL_PATH @PROJECT_NAME@_INSTALL_PATH OUTPUT_VARIABLE @PROJECT_NAME@_INSTALL_PATH)
endif()

set(PROTOC_NAME "$<TARGET_FILE_NAME:@PROJECT_NAME@_protoc_plugin>")
set(PROTO_SCRIPT_NAME "@PROJECT_NAME@_generate.py")
set(FACTORY_SCRIPT_NAME "@PROJECT_NAME@_generate_factory.py")
Expand All @@ -37,7 +45,7 @@ if(NOT DEFINED @PROJECT_NAME@_PROTOC_EXECUTABLE)
endif()
if(NOT DEFINED @PROJECT_NAME@_PYTHON_INTERPRETER)
set(@PROJECT_NAME@_PYTHON_INTERPRETER Python3::Interpreter)
endif()
endif()
set(@PROJECT_NAME@_PROTO_GENERATOR_SCRIPT ${@PROJECT_NAME@_INSTALL_PATH}/bin/${PROTO_SCRIPT_NAME})
set(@PROJECT_NAME@_FACTORY_GENERATOR_SCRIPT ${@PROJECT_NAME@_INSTALL_PATH}/bin/${FACTORY_SCRIPT_NAME})

Expand Down
Loading