CMakeSwiftInformation.cmake 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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_INCLUDE_FLAG_Swift "-I ")
  17. if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
  18. set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -install_name -Xlinker ")
  19. elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  20. set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -soname -Xlinker ")
  21. endif()
  22. if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
  23. set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG "-Xlinker -rpath -Xlinker ")
  24. set(CMAKE_SHARED_LIBRARY_RUNTIME_Swift_FLAG_SEP ":")
  25. endif()
  26. set(CMAKE_Swift_COMPILE_OPTIONS_TARGET "-target ")
  27. set(CMAKE_Swift_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN "-tools-directory ")
  28. # NOTE(compnerd) the `-sdk` support is not yet ready in the compiler; when that
  29. # is fully working, we should be able to enable this.
  30. # set(CMAKE_Swift_COMPILE_OPTIONS_SYSROOT "-sdk ")
  31. # NOTE(compnerd) do not setup `-frontend` as we use the compiler as the driver
  32. # during the link phase and use that to drive the compilation
  33. set(CMAKE_Swift_COMPILER_ARG1 "")
  34. set(CMAKE_Swift_DEFINE_FLAG -D)
  35. set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-F ")
  36. set(CMAKE_Swift_LIBRARY_PATH_FLAG "-L ")
  37. set(CMAKE_Swift_LIBRARY_PATH_TERMINATOR "")
  38. set(CMAKE_Swift_LINK_LIBRARY_FLAG "-l")
  39. set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ")
  40. set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @)
  41. set(CMAKE_Swift_LINKER_PREFERENCE 50)
  42. set(CMAKE_Swift_LINKER_PREFERENCE_PROPAGATES 1)
  43. # NOTE(compnerd) use the short form for convenience and ease of search. They
  44. # are treated equivalent to their long form names as well as custom Swift
  45. # specific names.
  46. set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -libc MT)
  47. set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -libc MD)
  48. set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -libc MTd)
  49. set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -libc MDd)
  50. set(CMAKE_Swift_FLAGS_DEBUG_INIT "-g")
  51. set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O")
  52. set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g")
  53. set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize")
  54. cmake_initialize_per_config_variable(CMAKE_Swift_FLAGS "Swift Compiler Flags")
  55. # NOTE(compnerd) we do not have an object compile rule since we build the objects as part of the link step
  56. if(NOT CMAKE_Swift_COMPILE_OBJECT)
  57. set(CMAKE_Swift_COMPILE_OBJECT ":")
  58. endif()
  59. if(NOT CMAKE_Swift_NUM_THREADS MATCHES "^[0-9]+$")
  60. cmake_host_system_information(RESULT CMAKE_Swift_NUM_THREADS QUERY NUMBER_OF_LOGICAL_CORES)
  61. endif()
  62. if(CMAKE_SYSTEM_NAME STREQUAL Windows)
  63. set(CMAKE_Swift_IMPLIB_LINKER_FLAGS "-Xlinker -implib:<TARGET_IMPLIB>")
  64. endif()
  65. if(NOT CMAKE_Swift_CREATE_SHARED_LIBRARY)
  66. 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>")
  67. endif()
  68. if(NOT CMAKE_Swift_CREATE_SHARED_MODULE)
  69. set(CMAKE_Swift_CREATE_SHARED_MODULE ${CMAKE_Swift_CREATE_SHARED_LIBRARY})
  70. endif()
  71. if(NOT CMAKE_Swift_LINK_EXECUTABLE)
  72. 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-module -emit-module-path <SWIFT_MODULE> -emit-dependencies <DEFINES> <FLAGS> <INCLUDES> <SWIFT_SOURCES> <LINK_FLAGS> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <LINK_LIBRARIES>")
  73. endif()
  74. if(NOT CMAKE_Swift_CREATE_STATIC_LIBRARY)
  75. 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>")
  76. set(CMAKE_Swift_ARCHIVE_CREATE "<CMAKE_AR> crs <TARGET> <OBJECTS>")
  77. set(CMAKE_Swift_ARCHIVE_FINISH "")
  78. endif()
  79. set(CMAKE_Swift_INFORMATION_LOADED 1)