From 73726fa986540f0020380508dbac72daba54ff26 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 15 Nov 2018 15:39:24 -0800 Subject: [PATCH 1/2] build: rename flags to cmake_flags (NFC) --- cmake/modules/SwiftSupport.cmake | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cmake/modules/SwiftSupport.cmake b/cmake/modules/SwiftSupport.cmake index 537e60cb8..7d8c1ea43 100644 --- a/cmake/modules/SwiftSupport.cmake +++ b/cmake/modules/SwiftSupport.cmake @@ -8,31 +8,31 @@ function(add_swift_target target) cmake_parse_arguments(AST "${options}" "${single_value_options}" "${multiple_value_options}" ${ARGN}) - set(flags ${CMAKE_SWIFT_FLAGS}) + set(compile_flags ${CMAKE_SWIFT_FLAGS}) set(link_flags) if(AST_TARGET) - list(APPEND flags -target;${AST_TARGET}) + list(APPEND compile_flags -target;${AST_TARGET}) endif() if(AST_MODULE_NAME) - list(APPEND flags -module-name;${AST_MODULE_NAME}) + list(APPEND compile_flags -module-name;${AST_MODULE_NAME}) else() - list(APPEND flags -module-name;${target}) + list(APPEND compile_flags -module-name;${target}) endif() if(AST_MODULE_LINK_NAME) - list(APPEND flags -module-link-name;${AST_MODULE_LINK_NAME}) + list(APPEND compile_flags -module-link-name;${AST_MODULE_LINK_NAME}) endif() if(AST_MODULE_CACHE_PATH) - list(APPEND flags -module-cache-path;${AST_MODULE_CACHE_PATH}) + list(APPEND compile_flags -module-cache-path;${AST_MODULE_CACHE_PATH}) endif() if(AST_SWIFT_FLAGS) foreach(flag ${AST_SWIFT_FLAGS}) - list(APPEND flags ${flag}) + list(APPEND compile_flags ${flag}) endforeach() endif() if(AST_CFLAGS) foreach(flag ${AST_CFLAGS}) - list(APPEND flags -Xcc;${flag}) + list(APPEND compile_flags -Xcc;${flag}) endforeach() endif() if(AST_LINK_FLAGS) @@ -99,7 +99,7 @@ function(add_swift_target target) ${source} ${AST_DEPENDS} COMMAND - ${CMAKE_SWIFT_COMPILER} -frontend ${flags} -emit-module-path ${mod} -emit-module-doc-path ${doc} -o ${obj} -c ${all_sources}) + ${CMAKE_SWIFT_COMPILER} -frontend ${compile_flags} -emit-module-path ${mod} -emit-module-doc-path ${doc} -o ${obj} -c ${all_sources}) list(APPEND objs ${obj}) list(APPEND mods ${mod}) @@ -122,7 +122,7 @@ function(add_swift_target target) ${docs} ${AST_DEPENDS} COMMAND - ${CMAKE_SWIFT_COMPILER} -frontend ${flags} -sil-merge-partial-modules -emit-module ${mods} -o ${module} -emit-module-doc-path ${documentation}) + ${CMAKE_SWIFT_COMPILER} -frontend ${compile_flags} -sil-merge-partial-modules -emit-module ${mods} -o ${module} -emit-module-doc-path ${documentation}) endif() if(AST_LIBRARY) From 63e21d124891aab43eb11827ad0fabcae0bc57cb Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 15 Nov 2018 15:40:53 -0800 Subject: [PATCH 2/2] build: enable cross-linking --- cmake/modules/SwiftSupport.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/modules/SwiftSupport.cmake b/cmake/modules/SwiftSupport.cmake index 7d8c1ea43..bda9e6fb2 100644 --- a/cmake/modules/SwiftSupport.cmake +++ b/cmake/modules/SwiftSupport.cmake @@ -13,6 +13,7 @@ function(add_swift_target target) if(AST_TARGET) list(APPEND compile_flags -target;${AST_TARGET}) + list(APPEND link_flags -target;${AST_TARGET}) endif() if(AST_MODULE_NAME) list(APPEND compile_flags -module-name;${AST_MODULE_NAME}) @@ -25,6 +26,9 @@ function(add_swift_target target) if(AST_MODULE_CACHE_PATH) list(APPEND compile_flags -module-cache-path;${AST_MODULE_CACHE_PATH}) endif() + if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) + list(APPEND compile_flags -g) + endif() if(AST_SWIFT_FLAGS) foreach(flag ${AST_SWIFT_FLAGS}) list(APPEND compile_flags ${flag})