1# binary_dir_relative_path sets outvar to 2# ${CMAKE_CURRENT_BINARY_DIR}/${cur_bin_dir_relative}, but expressed relative to 3# ${CMAKE_BINARY_DIR}. 4# 5# TODO(davidben): When we require CMake 3.20 or later, this can be replaced with 6# the built-in cmake_path(RELATIVE_PATH) function. 7function(binary_dir_relative_path cur_bin_dir_relative outvar) 8 string(LENGTH "${CMAKE_BINARY_DIR}/" root_dir_length) 9 string(SUBSTRING "${CMAKE_CURRENT_BINARY_DIR}/${cur_bin_dir_relative}" ${root_dir_length} -1 result) 10 set(${outvar} ${result} PARENT_SCOPE) 11endfunction() 12