| @@ -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) | |||