浏览代码

fix bugs related to handling of interface libraries

master
Sascha Kratky 8 年前
父节点
当前提交
6b1f2c888d
共有 1 个文件被更改,包括 42 次插入9 次删除
  1. +42
    -9
      CMake/cotire.cmake

+ 42
- 9
CMake/cotire.cmake 查看文件

@@ -389,6 +389,24 @@ function (cotire_filter_compile_flags _language _flagFilter _matchedOptionsVar _
set (${_unmatchedOptionsVar} ${_unmatchedOptions} PARENT_SCOPE)
endfunction()

function (cotire_is_target_supported _target _isSupportedVar)
if (NOT TARGET "${_target}")
set (${_isSupportedVar} FALSE PARENT_SCOPE)
return()
endif()
get_target_property(_imported ${_target} IMPORTED)
if (_imported)
set (${_isSupportedVar} FALSE PARENT_SCOPE)
return()
endif()
get_target_property(_targetType ${_target} TYPE)
if (NOT _targetType MATCHES "EXECUTABLE|(STATIC|SHARED|MODULE|OBJECT)_LIBRARY")
set (${_isSupportedVar} FALSE PARENT_SCOPE)
return()
endif()
set (${_isSupportedVar} TRUE PARENT_SCOPE)
endfunction()

function (cotire_get_target_compile_flags _config _language _target _flagsVar)
string (TOUPPER "${_config}" _upperConfig)
# collect options from CMake language variables
@@ -3029,10 +3047,16 @@ function (cotire_target _target)
if (NOT _option_CONFIGURATIONS)
cotire_get_configuration_types(_option_CONFIGURATIONS)
endif()
# trivial checks
get_target_property(_imported ${_target} IMPORTED)
if (_imported)
message (WARNING "cotire: imported target ${_target} cannot be cotired.")
# check if cotire can be applied to target at all
cotire_is_target_supported(${_target} _isSupported)
if (NOT _isSupported)
get_target_property(_imported ${_target} IMPORTED)
get_target_property(_targetType ${_target} TYPE)
if (_imported)
message (WARNING "cotire: imported ${_targetType} target ${_target} cannot be cotired.")
else()
message (STATUS "cotire: ${_targetType} target ${_target} cannot be cotired.")
endif()
return()
endif()
# resolve alias
@@ -3097,11 +3121,16 @@ endfunction(cotire_target)
function (cotire_map_libraries _strategy _mappedLibrariesVar)
set (_mappedLibraries "")
foreach (_library ${ARGN})
if (TARGET "${_library}" AND "${_strategy}" MATCHES "COPY_UNITY")
# use target's corresponding unity target, if available
get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME)
if (TARGET "${_libraryUnityTargetName}")
list (APPEND _mappedLibraries "${_libraryUnityTargetName}")
if ("${_strategy}" MATCHES "COPY_UNITY")
cotire_is_target_supported(${_library} _isSupported)
if (_isSupported)
# use target's corresponding unity target, if available
get_target_property(_libraryUnityTargetName ${_library} COTIRE_UNITY_TARGET_NAME)
if (TARGET "${_libraryUnityTargetName}")
list (APPEND _mappedLibraries "${_libraryUnityTargetName}")
else()
list (APPEND _mappedLibraries "${_library}")
endif()
else()
list (APPEND _mappedLibraries "${_library}")
endif()
@@ -3114,6 +3143,10 @@ function (cotire_map_libraries _strategy _mappedLibrariesVar)
endfunction()

function (cotire_target_link_libraries _target)
cotire_is_target_supported(${_target} _isSupported)
if (NOT _isSupported)
return()
endif()
get_target_property(_unityTargetName ${_target} COTIRE_UNITY_TARGET_NAME)
if (TARGET "${_unityTargetName}")
get_target_property(_linkLibrariesStrategy ${_target} COTIRE_UNITY_LINK_LIBRARIES_INIT)


正在加载...
取消
保存