Skip to content

Commit de985e9

Browse files
authored
Wrap linker flags with LINKER: prefix for IntelLLVM (#553)
The Intel C++ compiler passes linker flags through the compiler driver since CMake 3.25, therefore they need to be escaped with the `LINKER:` prefix. This expands to the empty string in MSVC and clang-cl or older versions of CMake, so no special handling is needed for that. Fixes: #552
1 parent 227eee9 commit de985e9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

CMakeLists.txt

+2-3
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,12 @@ if (WIN32)
326326
file(TO_NATIVE_PATH ${RT_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${TARGET_NAME}_stripped.pdb PDB_NAME)
327327
if (${MSVC_VERSION} EQUAL 1500)
328328
# Visual Studio 2008
329-
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS "${LINK_FLAGS} /PDBSTRIPPED:${PDB_NAME}")
329+
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY LINK_OPTIONS "LINKER:/PDBSTRIPPED:${PDB_NAME}")
330330
else (${MSVC_VERSION} EQUAL 1500)
331331
# Visual Studio 2010 (assumed if not Visual Studio 2008)
332332
# This is a fix due to a bug in CMake, Does not add the flag /DEBUG to the linker flags in Release mode.
333333
# The /DEBUG flag is required in order to create stripped pdbs.
334-
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS_DEBUG "${LINK_FLAGS_DEBUG} /PDBSTRIPPED:${PDB_NAME}")
335-
set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS_RELEASE "${LINK_FLAGS_RELEASE} /DEBUG /PDBSTRIPPED:${PDB_NAME}")
334+
set_property(TARGET ${TARGET_NAME} APPEND PROPERTY LINK_OPTIONS $<$<CONFIG:Release>:LINKER:/DEBUG> "$<$<CONFIG:Debug,Release>:LINKER:/PDBSTRIPPED:${PDB_NAME}>")
336335
endif (${MSVC_VERSION} EQUAL 1500)
337336
if (INSTALL_PDBS)
338337
install(FILES ${RT_OUTPUT_DIRECTORY}/\${BUILD_TYPE}/${TARGET_NAME}.pdb DESTINATION bin)

0 commit comments

Comments
 (0)