Skip to content

build improvements #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,9 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
endif()
install(TARGETS
BlocksRuntime
DESTINATION
${INSTALL_TARGET_DIR})
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
RUNTIME DESTINATION bin)
endif()

check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE)
Expand Down
43 changes: 38 additions & 5 deletions cmake/modules/SwiftSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include(CMakeParseArguments)
function(add_swift_target target)
set(options LIBRARY;SHARED;STATIC)
set(single_value_options MODULE_NAME;MODULE_LINK_NAME;MODULE_PATH;MODULE_CACHE_PATH;OUTPUT;TARGET)
set(multiple_value_options CFLAGS;DEPENDS;LINK_FLAGS;SOURCES;SWIFT_FLAGS)
set(multiple_value_options CFLAGS;DEPENDS;LINK_FLAGS;RESOURCES;SOURCES;SWIFT_FLAGS)

cmake_parse_arguments(AST "${options}" "${single_value_options}" "${multiple_value_options}" ${ARGN})

Expand Down Expand Up @@ -70,6 +70,11 @@ function(add_swift_target target)
set(AST_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${target}.dir/${target}${CMAKE_EXECUTABLE_SUFFIX})
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
if(AST_SHARED OR BUILD_SHARED_LIBS)
set(IMPORT_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/${target}.dir/${CMAKE_IMPORT_LIBRARY_PREFIX}${target}${CMAKE_IMPORT_LIBRARY_SUFFIX})
endif()
endif()

set(sources)
foreach(source ${AST_SOURCES})
Expand Down Expand Up @@ -132,16 +137,14 @@ function(add_swift_target target)
if(AST_LIBRARY)
set(emit_library -emit-library)
endif()
if(library_kind STREQUAL SHARED)
if(NOT AST_LIBRARY OR library_kind STREQUAL SHARED)
add_custom_command(OUTPUT
${AST_OUTPUT}
DEPENDS
${objs}
${AST_DEPENDS}
COMMAND
${CMAKE_SWIFT_COMPILER} ${emit_library} ${link_flags} -o ${AST_OUTPUT} ${objs}
COMMAND
${CMAKE_COMMAND} -E copy ${AST_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR})
${CMAKE_SWIFT_COMPILER} ${emit_library} ${link_flags} -o ${AST_OUTPUT} ${objs})
add_custom_target(${target}
ALL
DEPENDS
Expand All @@ -150,6 +153,7 @@ function(add_swift_target target)
${documentation})
else()
add_library(${target}-static STATIC ${objs})
add_dependencies(${target}-static ${AST_DEPENDS})
get_filename_component(ast_output_bn ${AST_OUTPUT} NAME)
get_filename_component(ast_output_dn ${AST_OUTPUT} DIRECTORY)
set_target_properties(${target}-static
Expand All @@ -164,6 +168,35 @@ function(add_swift_target target)
${module}
${documentation})
endif()

if(AST_RESOURCES)
add_custom_command(TARGET
${target}
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${target}
COMMAND
${CMAKE_COMMAND} -E copy ${AST_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${target}
COMMAND
${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${target}/Resources
COMMAND
${CMAKE_COMMAND} -E copy ${AST_RESOURCES} ${CMAKE_CURRENT_BINARY_DIR}/${target}/Resources)
else()
add_custom_command(TARGET
${target}
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy ${AST_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR})
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
if(AST_SHARED OR BUILD_SHARED_LIBS)
add_custom_command(TARGET
${target}
POST_BUILD
COMMAND
${CMAKE_COMMAND} -E copy ${IMPORT_LIBRARY} ${CMAKE_CURRENT_BINARY_DIR})
endif()
endif()
endif()
endfunction()

function(add_swift_library library)
Expand Down
1 change: 1 addition & 0 deletions os/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
install(FILES
object.h
generic_unix_base.h
generic_win_base.h
DESTINATION
"${INSTALL_OS_HEADERS_DIR}")

18 changes: 15 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ if(WIN32)
PRIVATE
_CRT_NONSTDC_NO_WARNINGS)
endif()
if(NOT "${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
target_compile_options(dispatch PRIVATE /EHs-c-)
else()
target_compile_options(dispatch PRIVATE -fno-exceptions)
endif()
if(DISPATCH_ENABLE_ASSERTS)
Expand Down Expand Up @@ -247,8 +249,10 @@ dispatch_set_linker(dispatch)

install(TARGETS
dispatch
DESTINATION
"${INSTALL_TARGET_DIR}")
ARCHIVE DESTINATION ${INSTALL_TARGET_DIR}
LIBRARY DESTINATION ${INSTALL_TARGET_DIR}
RUNTIME DESTINATION bin)

if(ENABLE_SWIFT)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/swift/Dispatch.swiftmodule
Expand All @@ -267,5 +271,13 @@ if(ENABLE_SWIFT)
${swiftDispatch_OUTPUT_FILE}
DESTINATION
${INSTALL_TARGET_DIR})
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
if(BUILD_SHARED_LIBS)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}swiftDispatch${CMAKE_IMPORT_LIBRARY_SUFFIX}
DESTINATION
${INSTALL_TARGET_DIR})
endif()
endif()
endif()