• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2find_program(SWIFT_EXEC swift)
3if (SWIFT_EXEC MATCHES "SWIFT_EXEC-NOTFOUND")
4  message(FATAL_ERROR "`swift` executable not found")
5endif ()
6
7file(
8  COPY .
9  DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
10  REGEX "(/\\.build)|(.+\\.db)" EXCLUDE
11)
12
13list(TRANSFORM PROJECT_INCLUDE_DIRS PREPEND "-Xcc;-I" OUTPUT_VARIABLE SWIFT_IDIRS)
14
15if (CMAKE_BUILD_TYPE STREQUAL "Release")
16  set(SWIFT_BUILD_TYPE "release")
17else()
18  set(SWIFT_BUILD_TYPE "debug")
19endif()
20
21add_custom_target(
22  ejdb2_swift_binding ALL
23  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/EJDB2Swift
24  COMMAND swift build
25               -c ${SWIFT_BUILD_TYPE}
26               -Xlinker -L${CMAKE_BINARY_DIR}/src
27               -Xcc -DINPROJECT_BUILD
28               ${SWIFT_IDIRS}
29  COMMAND_EXPAND_LISTS
30)
31
32add_dependencies(ejdb2_swift_binding ejdb2)
33
34if (BUILD_TESTS)
35
36  if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
37
38    add_test(
39      NAME ejdb2_swift
40      COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src;DYLD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src"
41              swift test
42                  -Xlinker -L${CMAKE_BINARY_DIR}/src
43                  -Xcc -DINPROJECT_BUILD
44                  ${SWIFT_IDIRS}
45      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/EJDB2Swift
46    )
47
48  else()
49
50    add_test(
51      NAME ejdb2_swift
52      COMMAND ${CMAKE_COMMAND} -E env "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src;DYLD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src"
53              swift test
54                  -Xlinker -L${CMAKE_BINARY_DIR}/src
55                  -Xcc -DINPROJECT_BUILD
56                  ${SWIFT_IDIRS}
57      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/EJDB2Swift
58      COMMAND_EXPAND_LISTS
59    )
60  endif()
61
62endif()
63
64
65
66
67
68