Skip to content

Commit e0dced0

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 bc00e13 commit e0dced0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

cmake/modules/SwiftSupport.cmake

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,12 @@ function(add_swift_target target)
153153
add_library(${target}-static STATIC ${objs})
154154
add_dependencies(${target}-static ${AST_DEPENDS})
155155
get_filename_component(ast_output_bn ${AST_OUTPUT} NAME)
156-
string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" ast_output_bn ${ast_output_bn})
157-
string(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" ast_output_bn ${ast_output_bn})
156+
if(NOT CMAKE_STATIC_LIBRARY_PREFIX STREQUAL "")
157+
string(REGEX REPLACE "^${CMAKE_STATIC_LIBRARY_PREFIX}" "" ast_output_bn ${ast_output_bn})
158+
endif()
159+
if(NOT CMAKE_STATIC_LIBRARY_SUFFIX STREQUAL "")
160+
string(REGEX REPLACE "${CMAKE_STATIC_LIBRARY_SUFFIX}$" "" ast_output_bn ${ast_output_bn})
161+
endif()
158162
get_filename_component(ast_output_dn ${AST_OUTPUT} DIRECTORY)
159163
set_target_properties(${target}-static
160164
PROPERTIES

0 commit comments

Comments
 (0)