Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

Commit 16121f2

Browse files
committed
Fix generator expression for binary targets in compile definitions
* Affected generator expressions are replaced through the static variable value and a corresponding STREQUAL generator expression. * Closes #135
1 parent 391bf6b commit 16121f2

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

CMake/cotire.cmake

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2355,12 +2355,22 @@ function (cotire_generate_target_script _language _configurations _target _targe
23552355
CMAKE_${_language}_SOURCE_FILE_EXTENSIONS)
23562356
if (DEFINED ${_var})
23572357
string (REPLACE "\"" "\\\"" _value "${${_var}}")
2358-
set (_contents "${_contents}set (${_var} \"${_value}\")\n")
2359-
if (NOT _contentsHasGeneratorExpressions)
2360-
if ("${_value}" MATCHES "\\$<.*>")
2358+
2359+
if ("${_value}" MATCHES "\\$<.*>")
2360+
# We have to evaluate generator expressions
2361+
if (NOT _contentsHasGeneratorExpressions)
23612362
set (_contentsHasGeneratorExpressions TRUE)
23622363
endif()
2364+
2365+
# Expand various generator expressions which can only be evaluated on binary targets manually
2366+
foreach(_currentReplacedGeneratorExpression "C_COMPILER_ID" "CXX_COMPILER_ID")
2367+
set(_currentReplacement ${CMAKE_${_currentReplacedGeneratorExpression}})
2368+
2369+
string (REGEX REPLACE "\\$<${_currentReplacedGeneratorExpression}:([a-zA-Z0-9]*)>" "$<STREQUAL:\\\\\"${_currentReplacement}\\\\\",\\\\\"\\1\\\\\">" _value "${_value}")
2370+
endforeach(_currentReplacedGeneratorExpression)
23632371
endif()
2372+
2373+
set (_contents "${_contents}set (${_var} \"${_value}\")\n")
23642374
endif()
23652375
endforeach()
23662376
# generate target script file

0 commit comments

Comments
 (0)