1bde561c4SJohn Ericson# Extend the path in `base_path` with the path in `current_segment`, returning 2bde561c4SJohn Ericson# the result in `joined_path`. If `current_segment` is an absolute path then 3bde561c4SJohn Ericson# just return it, in effect overriding `base_path`, and issue a warning. 4bde561c4SJohn Ericson# 5bde561c4SJohn Ericson# Note that the code returns a relative path (avoiding introducing leading 6bde561c4SJohn Ericson# slashes) if `base_path` is empty. 7bde561c4SJohn Ericsonfunction(extend_path joined_path base_path current_segment) 8bde561c4SJohn Ericson if("${current_segment}" STREQUAL "") 9bde561c4SJohn Ericson set(temp_path "${base_path}") 10bde561c4SJohn Ericson elseif("${base_path}" STREQUAL "") 11bde561c4SJohn Ericson set(temp_path "${current_segment}") 12bde561c4SJohn Ericson elseif(IS_ABSOLUTE "${current_segment}") 13*5da6d268SJohn Ericson message(WARNING "Since \"${current_segment}\" is absolute, it overrides base path: \"${base_path}\".") 14bde561c4SJohn Ericson set(temp_path "${current_segment}") 15bde561c4SJohn Ericson else() 16bde561c4SJohn Ericson set(temp_path "${base_path}/${current_segment}") 17bde561c4SJohn Ericson endif() 18bde561c4SJohn Ericson set(${joined_path} "${temp_path}" PARENT_SCOPE) 19bde561c4SJohn Ericsonendfunction() 20