Skip to content

Commit 4f179b3

Browse files
committed
[cmake] Skip regex when CMAKE_STATIC_LIBRARY_PREFIX is empty.
In platforms like Windows, there's no prefix for static libraries. Interpolating it in the regex will end up with a regex "^", which seems not to be valid. Since the regex was removing the prefix, we can simply skip the operation and the result will be the same. Also do the same for CMAKE_STATIC_LIBRARY_SUFFIX, even if in that case, Windows will have a value (but if it is empty, it will fail trying to create the regex).
1 parent d782c4f commit 4f179b3

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: cmake/modules/SwiftSupport.cmake

+6-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,12 @@ function(add_swift_target target)
155155
add_dependencies(${target}-static ${AST_DEPENDS})
156156
endif()
157157
get_filename_component(ast_output_bn ${AST_OUTPUT} NAME)
158-
string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" ast_output_bn ${ast_output_bn})
159-
string(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" ast_output_bn ${ast_output_bn})
158+
if(NOT CMAKE_STATIC_LIBRARY_PREFIX STREQUAL "")
159+
string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" ast_output_bn ${ast_output_bn})
160+
endif()
161+
if(NOT CMAKE_STATIC_LIBRARY_SUFFIX STREQUAL "")
162+
string(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" ast_output_bn ${ast_output_bn})
163+
endif()
160164
get_filename_component(ast_output_dn ${AST_OUTPUT} DIRECTORY)
161165
set_target_properties(${target}-static
162166
PROPERTIES

0 commit comments

Comments
 (0)