Skip to content

Commit fb368f6

Browse files
Merge pull request #433 from compnerd/static-build
build: make the static build work well
2 parents e3ae79b + 7896b18 commit fb368f6

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

cmake/modules/SwiftSupport.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ function(add_swift_target target)
6262
if(AST_SHARED OR BUILD_SHARED_LIBS)
6363
set(AST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}.dir/${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX})
6464
else()
65-
# NOTE(compnerd) this is a hack for the computation of the
66-
# basename/dirname below for the static path.
67-
set(AST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}.dir/${target})
65+
set(AST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}.dir/${CMAKE_STATIC_LIBRARY_PREFIX}${target}${CMAKE_STATIC_LIBRARY_SUFFIX})
6866
endif()
6967
else()
7068
set(AST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}.dir/${target}${CMAKE_EXECUTABLE_SUFFIX})
@@ -155,10 +153,13 @@ function(add_swift_target target)
155153
add_library(${target}-static STATIC ${objs})
156154
add_dependencies(${target}-static ${AST_DEPENDS})
157155
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})
158158
get_filename_component(ast_output_dn ${AST_OUTPUT} DIRECTORY)
159159
set_target_properties(${target}-static
160160
PROPERTIES
161161
LINKER_LANGUAGE C
162+
ARCHIVE_OUTPUT_DIRECTORY ${ast_output_dn}
162163
OUTPUT_DIRECTORY ${ast_output_dn}
163164
OUTPUT_NAME ${ast_output_bn})
164165
add_custom_target(${target}

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ if(ENABLE_SWIFT)
120120
-fblocks
121121
-fmodule-map-file=${PROJECT_SOURCE_DIR}/dispatch/module.modulemap
122122
DEPENDS
123-
${PROJECT_SOURCE_DIR}/dispatch/module.modulemap
123+
module-maps
124124
DispatchStubs
125125
LINK_FLAGS
126126
${use_ld_flag}

0 commit comments

Comments
 (0)