Merge topic 'fix-absolute-libs-for-cray-wrappers'

928d2085 CrayPrgEnv: Don't use absolute paths for imlicit libraries
This commit is contained in:
Brad King 2015-12-21 09:41:02 -05:00 committed by CMake Topic Stage
commit 3768a79c23

View File

@ -4,12 +4,14 @@ if(__craylinux_crayprgenv)
endif() endif()
set(__craylinux_crayprgenv 1) set(__craylinux_crayprgenv 1)
macro(__cray_extract_args cmd tag_regex out_var) macro(__cray_extract_args cmd tag_regex out_var make_absolute)
string(REGEX MATCHALL "${tag_regex}" args "${cmd}") string(REGEX MATCHALL "${tag_regex}" args "${cmd}")
foreach(arg IN LISTS args) foreach(arg IN LISTS args)
string(REGEX REPLACE "^${tag_regex}$" "\\2" param "${arg}") string(REGEX REPLACE "^${tag_regex}$" "\\2" param "${arg}")
get_filename_component(param_abs "${param}" ABSOLUTE) if(make_absolute)
list(APPEND ${out_var} ${param_abs}) get_filename_component(param "${param}" ABSOLUTE)
endif()
list(APPEND ${out_var} ${param})
endforeach() endforeach()
endmacro() endmacro()
@ -21,15 +23,18 @@ function(__cray_extract_implicit src compiler_cmd link_cmd lang include_dirs_var
OUTPUT_VARIABLE output OUTPUT_VARIABLE output
ERROR_VARIABLE error ERROR_VARIABLE error
) )
set(include_dirs)
set(link_dirs)
set(link_libs)
string(REGEX REPLACE "\r?\n" ";" output_lines "${output}\n${error}") string(REGEX REPLACE "\r?\n" ";" output_lines "${output}\n${error}")
foreach(line IN LISTS output_lines) foreach(line IN LISTS output_lines)
if("${line}" MATCHES "${compiler_cmd}") if("${line}" MATCHES "${compiler_cmd}")
__cray_extract_args("${line}" " -(I ?|isystem )([^ ]*)" include_dirs) __cray_extract_args("${line}" " -(I ?|isystem )([^ ]*)" include_dirs 1)
set(processed_include 1) set(processed_include 1)
endif() endif()
if("${line}" MATCHES "${link_cmd}") if("${line}" MATCHES "${link_cmd}")
__cray_extract_args("${line}" " -(L ?)([^ ]*)" link_dirs) __cray_extract_args("${line}" " -(L ?)([^ ]*)" link_dirs 1)
__cray_extract_args("${line}" " -(l ?)([^ ]*)" link_libs) __cray_extract_args("${line}" " -(l ?)([^ ]*)" link_libs 0)
set(processed_link 1) set(processed_link 1)
endif() endif()
if(processed_include AND processed_link) if(processed_include AND processed_link)