WIP: Factor source search into function
This commit is contained in:
parent
a0cf4a49a7
commit
ffb3604121
|
@ -69,27 +69,40 @@ foreach(d ${arch_path})
|
|||
endforeach()
|
||||
include_directories(${includes})
|
||||
|
||||
function(find_source src_var name)
|
||||
set(found "")
|
||||
foreach(d ${arch_path})
|
||||
if(ARGN)
|
||||
foreach(ext ${ARGN})
|
||||
set(src "${GTM_SOURCE_DIR}/${d}/${name}${ext}")
|
||||
if(EXISTS "${src}")
|
||||
set(found "${src}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
else()
|
||||
set(src "${GTM_SOURCE_DIR}/${d}/${name}")
|
||||
if(EXISTS "${src}")
|
||||
set(found "${src}")
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
if(found)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT found)
|
||||
message(FATAL_ERROR "Cannot find \"${name}\" as ${ARGN}")
|
||||
endif()
|
||||
set("${src_var}" "${found}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(load_source_list srcs_var listfile)
|
||||
set(srcs "")
|
||||
file(STRINGS "${listfile}" names)
|
||||
foreach(name ${names})
|
||||
set(found 0)
|
||||
foreach(d ${arch_path})
|
||||
foreach(ext .c .s .si)
|
||||
set(src "${GTM_SOURCE_DIR}/${d}/${name}${ext}")
|
||||
if(EXISTS "${src}")
|
||||
list(APPEND srcs "${src}")
|
||||
set(found 1)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(found)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT found)
|
||||
message(FATAL_ERROR "Cannot find ${name}")
|
||||
endif()
|
||||
find_source(src ${name} .c .s .si)
|
||||
list(APPEND srcs ${src})
|
||||
endforeach()
|
||||
set(${srcs_var} "${srcs}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
@ -262,21 +275,13 @@ foreach(h
|
|||
gtm_limits.h
|
||||
main_pragma.h
|
||||
)
|
||||
set(found 0)
|
||||
foreach(d ${arch_path})
|
||||
set(hdr "${GTM_SOURCE_DIR}/${d}/${h}")
|
||||
if(EXISTS "${hdr}")
|
||||
list(APPEND hdrs "${hdr}")
|
||||
set(found 1)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT found)
|
||||
message(FATAL_ERROR "Cannot find header ${h}")
|
||||
endif()
|
||||
find_source(hdr ${h})
|
||||
list(APPEND hdrs ${hdr})
|
||||
endforeach()
|
||||
install(FILES ${hdrs} DESTINATION .)
|
||||
|
||||
|
||||
|
||||
# Would install to:
|
||||
# /usr/lib/fis-gtm/V5.5-000_x86
|
||||
# /usr/lib/fis-gtm/V5.5-000_x86_64
|
||||
|
|
Loading…
Reference in New Issue