I followed this and this link to write a function that:
- takes a list of files as input,
- appends path to each file
Creates a new list (passed as an output parameter to the function itself) by appending all the files to it
function(concat_path iLiItems oLiItems cVal) foreach(pfile ${${iLiItems}}) string(CONCAT l ${${cVal}} ${pfile}) message(STATUS ${pfile} " - " ${l}) set(${oLiItems} ${${oLiItems}} ${l} PARENT_SCOPE) endforeach() endfunction() function(list_print liItems) message(STATUS "The list contains: ") foreach(f ${${liItems}}) message(STATUS ${f}) endforeach() endfunction() set(PROTO_SRCS base.proto dht.proto) foreach(pfile ${PROTO_SRCS}) string(REPLACE ".proto" ".pb" fname ${pfile}) string(CONCAT cc ${fname} ".cc") string(CONCAT h ${fname} ".h") set(PROTO_CPP_SRCS ${PROTO_CPP_SRCS} ${cc} ${h}) endforeach() string(CONCAT path_prefix ${CMAKE_CURRENT_SOURCE_DIR} "/") concat_path(PROTO_SRCS PROTO_SRCS_PATH path_prefix) list_print(PROTO_SRCS_PATH)
The problem I see is that when I finally print using the function, "list_print" i see that only one element is present in the output list (PROTO_SRCS_PATH) where as I was expecting two corresponding to both the input files:
-- base.proto - C:/Users/vaddina/workspace/protobuf-tests/app-wo-findprotobuf/base.proto
-- dht.proto - C:/Users/vaddina/workspace/protobuf-tests/app-wo-findprotobuf/dht.proto
-- The list contains:
-- C:/Users/vaddina/workspace/protobuf-tests/app-wo-findprotobuf/dht.proto
What am I doing wrong ? Thank you.