46 lines
1.7 KiB
CMake
46 lines
1.7 KiB
CMake
# Swift language support
|
|
cmake_minimum_required (VERSION 3.15)
|
|
|
|
file (READ ../xK-version project_version)
|
|
configure_file (../xK-version xK-version.tag COPYONLY)
|
|
string (STRIP "${project_version}" project_version)
|
|
|
|
# There were two issues when building this from the main CMakeLists.txt:
|
|
# a) renaming main.swift to xM.swift requires removing top-level statements,
|
|
# b) there is a "redefinition of module 'FFI'" error.
|
|
project (xM VERSION "${project_version}"
|
|
DESCRIPTION "Cocoa frontend for xC" LANGUAGES Swift)
|
|
|
|
set (root "${PROJECT_SOURCE_DIR}/..")
|
|
add_custom_command (OUTPUT xC-proto.swift
|
|
COMMAND env LC_ALL=C awk
|
|
-f ${root}/liberty/tools/lxdrgen.awk
|
|
-f ${root}/liberty/tools/lxdrgen-swift.awk
|
|
-v PrefixCamel=Relay
|
|
${root}/xC.lxdr > xC-proto.swift
|
|
DEPENDS
|
|
${root}/liberty/tools/lxdrgen.awk
|
|
${root}/liberty/tools/lxdrgen-swift.awk
|
|
${root}/xC.lxdr
|
|
COMMENT "Generating xC relay protocol code" VERBATIM)
|
|
|
|
set (MACOSX_BUNDLE_GUI_IDENTIFIER name.janouch.${PROJECT_NAME})
|
|
set (MACOSX_BUNDLE_ICON_FILE xM.icns)
|
|
|
|
# Avoid including binary files in the repository by generating icons in code.
|
|
# sips(1) + Javascript + iconutil(1) could probably also be used.
|
|
find_program (SWIFT_EXECUTABLE swift REQUIRED)
|
|
|
|
set (icon "${PROJECT_BINARY_DIR}/${MACOSX_BUNDLE_ICON_FILE}")
|
|
add_custom_command (OUTPUT "${icon}"
|
|
COMMAND ${SWIFT_EXECUTABLE} "${PROJECT_SOURCE_DIR}/gen-icon.swift" "${icon}"
|
|
DEPENDS gen-icon.swift
|
|
COMMENT "Generating xM application icon" VERBATIM)
|
|
set_source_files_properties ("${icon}" PROPERTIES
|
|
MACOSX_PACKAGE_LOCATION Resources)
|
|
|
|
# Other requirements: macOS 10.14 for Network, and macOS 11 for Logger.
|
|
set (CMAKE_Swift_LANGUAGE_VERSION 5)
|
|
add_executable (xM MACOSX_BUNDLE
|
|
main.swift "${icon}" "${PROJECT_BINARY_DIR}/xC-proto.swift")
|