Skip to content

Commit

Permalink
Update cmake-build for Linux (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
sushichop authored Jun 21, 2021
1 parent dc82e65 commit de36536
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [x.y.z](https://github.com/sushichop/Puppy/releases/tag/x.y.z) (yyyy-mm-dd)

- Update `cmake-build` for Linux. [#19](https://github.com/sushichop/Puppy/pull/19)

## [0.2.0](https://github.com/sushichop/Puppy/releases/tag/x.y.z) (2021-06-17)

- Instantiate `DispatchQueue` and add an argument named of `asynchronous`. [#9](https://github.com/sushichop/Puppy/pull/9)
Expand Down
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
cmake_minimum_required(VERSION 3.16)
project(Puppy C Swift)

if(CMAKE_VERSION VERSION_LESS 3.17)
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
set(CMAKE_EXECUTABLE_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(CMAKE_EXECUTABLE_RUNTIME_Swift_FLAG_SEP "")
set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG_SEP "")
else()
set(CMAKE_EXECUTABLE_RUNTIME_Swift_FLAG_SEP ":")
set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG_SEP ":")
endif()
endif()
endif()

list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)

set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down
3 changes: 1 addition & 2 deletions Externals/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ add_library(Logging

target_link_libraries(Logging PRIVATE
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>)

set_target_properties(Logging PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

install_swiftmodule(Logging)
install_swift_module(Logging)
set_property(GLOBAL APPEND PROPERTY PUPPY_EXPORTS Logging)
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ let package = Package(
.package(url: "https://github.com/apple/swift-log.git", from: "1.4.2"),
],
targets: [
.target(name: "CPuppy"),
.target(name: "Puppy", dependencies: [.product(name: "Logging", package: "swift-log")]),
.target(name: "CPuppy",
exclude: ["CMakeLists.txt"]),
.target(name: "Puppy", dependencies: [.product(name: "Logging", package: "swift-log")],
exclude: ["CMakeLists.txt"]),
.testTarget(name: "PuppyTests", dependencies: ["Puppy"]),
],
swiftLanguageVersions: [.v5]
Expand Down
2 changes: 1 addition & 1 deletion Sources/CPuppy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ target_include_directories(CPuppy PUBLIC
include)

set_target_properties(CPuppy PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include;${CMAKE_Swift_MODULE_DIRECTORY}")

set_property(GLOBAL APPEND PROPERTY PUPPY_EXPORTS CPuppy)
6 changes: 2 additions & 4 deletions Sources/Puppy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ add_library(Puppy
PuppyLogHandler.swift
SystemLogger.swift)

target_include_directories(Puppy PRIVATE
$<TARGET_PROPERTY:CPuppy,INCLUDE_DIRECTORIES>)
target_link_libraries(Puppy PRIVATE
target_link_libraries(Puppy PUBLIC
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
$<$<NOT:$<PLATFORM_ID:Darwin>>:CPuppy>
Logging)
set_target_properties(Puppy PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})

install_swiftmodule(Puppy)
install_swift_module(Puppy)
set_property(GLOBAL APPEND PROPERTY PUPPY_EXPORTS Puppy)
22 changes: 8 additions & 14 deletions cmake/modules/SwiftSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function(get_swift_host_os result_var_name)
endif()
endfunction()

function(install_swiftmodule module)
function(install_swift_module module)
get_swift_host_os(swift_os)
get_target_property(type ${module} TYPE)

Expand All @@ -78,17 +78,11 @@ function(install_swiftmodule module)
set(module_name ${module})
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
RENAME ${swift_arch}.swiftdoc)
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
RENAME ${swift_arch}.swiftmodule)
else()
install(FILES
$<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc
$<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule
DESTINATION lib/${swift}/${swift_os}/${swift_arch})
endif()
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftdoc
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
RENAME ${swift_arch}.swiftdoc)
install(FILES $<TARGET_PROPERTY:${module},Swift_MODULE_DIRECTORY>/${module_name}.swiftmodule
DESTINATION lib/${swift}/${swift_os}/${module_name}.swiftmodule
RENAME ${swift_arch}.swiftmodule)

endfunction()

0 comments on commit de36536

Please sign in to comment.