|
|
@@ -5,16 +5,27 @@ cmake_policy(PUSH)
|
|
|
cmake_policy(SET CMP0053 NEW)
|
|
|
cmake_policy(SET CMP0054 NEW)
|
|
|
|
|
|
-# Function parse implicit linker options.
|
|
|
+# Function to parse implicit linker options.
|
|
|
+#
|
|
|
# This is used internally by CMake and should not be included by user
|
|
|
# code.
|
|
|
-
|
|
|
+#
|
|
|
+# Note: this function is leaked/exposed by FindOpenMP and therefore needs
|
|
|
+# to have a stable API so projects that copied `FindOpenMP` for backwards
|
|
|
+# compatibility don't break.
|
|
|
+#
|
|
|
function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj_regex)
|
|
|
set(implicit_libs_tmp "")
|
|
|
+ set(implicit_objs_tmp "")
|
|
|
set(implicit_dirs_tmp)
|
|
|
set(implicit_fwks_tmp)
|
|
|
set(log "")
|
|
|
|
|
|
+ set(keywordArgs)
|
|
|
+ set(oneValueArgs COMPUTE_IMPLICIT_OBJECTS)
|
|
|
+ set(multiValueArgs )
|
|
|
+ cmake_parse_arguments(EXTRA_PARSE "${keywordArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
+
|
|
|
# Parse implicit linker arguments.
|
|
|
set(linker "CMAKE_LINKER-NOTFOUND")
|
|
|
if(CMAKE_LINKER)
|
|
|
@@ -103,11 +114,15 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
|
|
|
set(lib "${CMAKE_MATCH_2}")
|
|
|
list(APPEND implicit_libs_tmp ${lib})
|
|
|
string(APPEND log " arg [${arg}] ==> lib [${lib}]\n")
|
|
|
- elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.o$"
|
|
|
- AND obj_regex AND "${arg}" MATCHES "${obj_regex}")
|
|
|
- # Object file full path.
|
|
|
- list(APPEND implicit_libs_tmp ${arg})
|
|
|
- string(APPEND log " arg [${arg}] ==> obj [${arg}]\n")
|
|
|
+ elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.o$")
|
|
|
+ if(EXTRA_PARSE_COMPUTE_IMPLICIT_OBJECTS)
|
|
|
+ list(APPEND implicit_objs_tmp ${arg})
|
|
|
+ string(APPEND log " arg [${arg}] ==> obj [${arg}]\n")
|
|
|
+ endif()
|
|
|
+ if(obj_regex AND "${arg}" MATCHES "${obj_regex}")
|
|
|
+ # Object file full path.
|
|
|
+ list(APPEND implicit_libs_tmp ${arg})
|
|
|
+ endif()
|
|
|
elseif("${arg}" MATCHES "^-Y(P,)?[^0-9]")
|
|
|
# Sun search path ([^0-9] avoids conflict with Mac -Y<num>).
|
|
|
string(REGEX REPLACE "^-Y(P,)?" "" dirs "${arg}")
|
|
|
@@ -170,6 +185,21 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
|
|
|
endif()
|
|
|
endforeach()
|
|
|
|
|
|
+ if(EXTRA_PARSE_COMPUTE_IMPLICIT_OBJECTS)
|
|
|
+ set(implicit_objs "")
|
|
|
+ foreach(obj IN LISTS implicit_objs_tmp)
|
|
|
+ if(IS_ABSOLUTE "${obj}")
|
|
|
+ get_filename_component(abs "${obj}" ABSOLUTE)
|
|
|
+ if(NOT "x${obj}" STREQUAL "x${abs}")
|
|
|
+ string(APPEND log " collapse obj [${obj}] ==> [${abs}]\n")
|
|
|
+ endif()
|
|
|
+ list(APPEND implicit_objs "${abs}")
|
|
|
+ else()
|
|
|
+ list(APPEND implicit_objs "${obj}")
|
|
|
+ endif()
|
|
|
+ endforeach()
|
|
|
+ endif()
|
|
|
+
|
|
|
# Cleanup list of library and framework directories.
|
|
|
set(desc_dirs "library")
|
|
|
set(desc_fwks "framework")
|
|
|
@@ -191,6 +221,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
|
|
|
|
|
|
# Log results.
|
|
|
string(APPEND log " implicit libs: [${implicit_libs}]\n")
|
|
|
+ string(APPEND log " implicit objs: [${implicit_objs}]\n")
|
|
|
string(APPEND log " implicit dirs: [${implicit_dirs}]\n")
|
|
|
string(APPEND log " implicit fwks: [${implicit_fwks}]\n")
|
|
|
|
|
|
@@ -199,6 +230,10 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
|
|
|
set(${dir_var} "${implicit_dirs}" PARENT_SCOPE)
|
|
|
set(${fwk_var} "${implicit_fwks}" PARENT_SCOPE)
|
|
|
set(${log_var} "${log}" PARENT_SCOPE)
|
|
|
+
|
|
|
+ if(EXTRA_PARSE_COMPUTE_IMPLICIT_OBJECTS)
|
|
|
+ set(${EXTRA_PARSE_COMPUTE_IMPLICIT_OBJECTS} "${implicit_objs}" PARENT_SCOPE)
|
|
|
+ endif()
|
|
|
endfunction()
|
|
|
|
|
|
cmake_policy(POP)
|