CMakeSwiftInformation.cmake 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. if(UNIX)
  4. set(CMAKE_Swift_OUTPUT_EXTENSION .o)
  5. else()
  6. set(CMAKE_Swift_OUTPUT_EXTENSION .obj)
  7. endif()
  8. # Load compiler-specific information.
  9. if(CMAKE_Swift_COMPILER_ID)
  10. include(Compiler/${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL)
  11. if(CMAKE_SYSTEM_PROCESSOR)
  12. include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL)
  13. endif()
  14. include(Platform/${CMAKE_EFFECTIVE_SYSTEM_NAME}-${CMAKE_Swift_COMPILER_ID}-Swift OPTIONAL)
  15. endif()
  16. set(CMAKE_EXE_EXPORTS_Swift_FLAG "-emit-module -emit-module-path <SWIFT_MODULE> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS}")
  17. set(CMAKE_INCLUDE_FLAG_Swift "-I ")
  18. if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
  19. set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -install_name -Xlinker ")
  20. elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  21. set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -soname -Xlinker ")
  22. endif()
  23. if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  24. set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
  25. set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG_SEP ":")
  26. endif()
  27. set(CMAKE_Swift_COMPILE_OPTIONS_TARGET "-target ")
  28. set(CMAKE_Swift_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "-tools-directory ")
  29. # NOTE(compnerd) the `-sdk` support is not yet ready in the compiler; when that
  30. # is fully working, we should be able to enable this.
  31. # set(CMAKE_Swift_COMPILE_OPTIONS_SYSROOT "-sdk ")
  32. # NOTE(compnerd) do not setup `-frontend` as we use the compiler as the driver
  33. # during the link phase and use that to drive the compilation
  34. set(CMAKE_Swift_COMPILER_ARG1 "")
  35. set(CMAKE_Swift_DEFINE_FLAG -D)
  36. set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-F ")
  37. set(CMAKE_Swift_LIBRARY_PATH_FLAG "-L ")
  38. set(CMAKE_Swift_LIBRARY_PATH_TERMINATOR "")
  39. set(CMAKE_Swift_LINK_LIBRARY_FLAG "-l")
  40. set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ")
  41. set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @)
  42. set(CMAKE_Swift_LINKER_PREFERENCE 50)
  43. set(CMAKE_Swift_LINKER_PREFERENCE_PROPAGATES 1)
  44. # NOTE(compnerd) use the short form for convenience and ease of search. They
  45. # are treated equivalent to their long form names as well as custom Swift
  46. # specific names.
  47. set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -libc MT)
  48. set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -libc MD)
  49. set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -libc MTd)
  50. set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -libc MDd)
  51. set(CMAKE_Swift_FLAGS_DEBUG_INIT "-g")
  52. set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O")
  53. set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g")
  54. set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize")
  55. cmake_initialize_per_config_variable(CMAKE_Swift_FLAGS "Swift Compiler Flags")
  56. # NOTE(compnerd) we do not have an object compile rule since we build the objects as part of the link step
  57. if(NOT CMAKE_Swift_COMPILE_OBJECT)
  58. set(CMAKE_Swift_COMPILE_OBJECT ":")
  59. endif()
  60. if(NOT CMAKE_Swift_NUM_THREADS MATCHES "^[0-9]+$")
  61. cmake_host_system_information(RESULT CMAKE_Swift_NUM_THREADS QUERY NUMBER_OF_LOGICAL_CORES)
  62. endif()
  63. if(NOT CMAKE_Swift_CREATE_SHARED_LIBRARY)
  64. set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-library -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
  65. endif()
  66. if(NOT CMAKE_Swift_CREATE_SHARED_MODULE)
  67. set(CMAKE_Swift_CREATE_SHARED_MODULE ${CMAKE_Swift_CREATE_SHARED_LIBRARY})
  68. endif()
  69. if(NOT CMAKE_Swift_LINK_EXECUTABLE)
  70. set(CMAKE_Swift_LINK_EXECUTABLE "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-executable -o <TARGET> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
  71. endif()
  72. if(NOT CMAKE_Swift_CREATE_STATIC_LIBRARY)
  73. set(CMAKE_Swift_CREATE_STATIC_LIBRARY "<CMAKE_Swift_COMPILER> -output-file-map <SWIFT_OUTPUT_FILE_MAP> -incremental -j ${CMAKE_Swift_NUM_THREADS} -emit-library -static -o <TARGET> -module-name <SWIFT_MODULE_NAME> -module-link-name <SWIFT_LIBRARY_NAME> -emit-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> <LINK_LIBRARIES>")
  74. set(CMAKE_Swift_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <OBJECTS>")
  75. set(CMAKE_Swift_ARCHIVE_FINISH "")
  76. endif()
  77. set(CMAKE_Swift_INFORMATION_LOADED 1)