Windows-Embarcadero.cmake 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # This module is shared by multiple languages; use include blocker.
  4. if(__WINDOWS_EMBARCADERO)
  5. return()
  6. endif()
  7. set(__WINDOWS_EMBARCADERO 1)
  8. set(BORLAND 1)
  9. set(__pch_header_C "c-header")
  10. set(__pch_header_CXX "c++-header")
  11. set(__pch_header_OBJC "objective-c-header")
  12. set(__pch_header_OBJCXX "objective-c++-header")
  13. if("${CMAKE_${_lang}_COMPILER_VERSION}" VERSION_LESS 6.30)
  14. # Borland target type flags (bcc32 -h -t):
  15. set(_tW "-tW") # -tW GUI App (implies -U__CONSOLE__)
  16. set(_tC "-tWC") # -tWC Console App (implies -D__CONSOLE__=1)
  17. set(_tD "-tWD") # -tWD Build a DLL (implies -D__DLL__=1 -D_DLL=1)
  18. set(_tM "-tWM") # -tWM Enable threads (implies -D__MT__=1 -D_MT=1)
  19. set(_tR "-tWR -tW-") # -tWR Use DLL runtime (implies -D_RTLDLL, and '-tW' too!!)
  20. # Notes:
  21. # - The flags affect linking so we pass them to the linker.
  22. # - The flags affect preprocessing so we pass them to the compiler.
  23. # - Since '-tWR' implies '-tW' we use '-tWR -tW-' instead.
  24. # - Since '-tW-' disables '-tWD' we use '-tWR -tW- -tWD' for DLLs.
  25. else()
  26. set(EMBARCADERO 1)
  27. set(_tC "-tC") # Target is a console application
  28. set(_tD "-tD") # Target is a shared library
  29. set(_tM "-tM") # Target is multi-threaded
  30. set(_tR "-tR") # Target uses the dynamic RTL
  31. set(_tW "-tW") # Target is a Windows application
  32. endif()
  33. set(_COMPILE_C "")
  34. set(_COMPILE_CXX " -P")
  35. set(CMAKE_LIBRARY_PATH_FLAG "-L")
  36. set(CMAKE_LINK_LIBRARY_FLAG "")
  37. set(CMAKE_FIND_LIBRARY_SUFFIXES "-bcc.lib" ".lib")
  38. # uncomment these out to debug makefiles
  39. #set(CMAKE_START_TEMP_FILE "")
  40. #set(CMAKE_END_TEMP_FILE "")
  41. #set(CMAKE_VERBOSE_MAKEFILE 1)
  42. # Borland cannot handle + in the file name, so mangle object file name
  43. set (CMAKE_MANGLE_OBJECT_FILE_NAMES "ON")
  44. # extra flags for a win32 exe
  45. set(CMAKE_CREATE_WIN32_EXE "${_tW}" )
  46. # extra flags for a console app
  47. set(CMAKE_CREATE_CONSOLE_EXE "${_tC}" )
  48. set (CMAKE_BUILD_TYPE Debug CACHE STRING
  49. "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.")
  50. foreach(t EXE SHARED MODULE)
  51. string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_tM} -lS:1048576 -lSc:4098 -lH:1048576 -lHc:8192 ")
  52. string(APPEND CMAKE_${t}_LINKER_FLAGS_DEBUG_INIT " -v")
  53. string(APPEND CMAKE_${t}_LINKER_FLAGS_RELWITHDEBINFO_INIT " -v")
  54. endforeach()
  55. # The Borland link tool does not support multiple concurrent
  56. # invocations within a single working directory.
  57. if(NOT DEFINED CMAKE_JOB_POOL_LINK)
  58. set(CMAKE_JOB_POOL_LINK BCC32LinkPool)
  59. get_property(_bccjp GLOBAL PROPERTY JOB_POOLS)
  60. if(NOT _bccjp MATCHES "BCC32LinkPool=")
  61. set_property(GLOBAL APPEND PROPERTY JOB_POOLS BCC32LinkPool=1)
  62. endif()
  63. unset(_bccjp)
  64. endif()
  65. macro(__embarcadero_language lang)
  66. set(CMAKE_${lang}_COMPILE_OPTIONS_DLL "${_tD}") # Note: This variable is a ';' separated list
  67. set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "${_tD}") # ... while this is a space separated string.
  68. set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
  69. set (CMAKE_${lang}_LINKER_WRAPPER_FLAG "-l")
  70. # compile a source file into an object file
  71. # place <DEFINES> outside the response file because Borland refuses
  72. # to parse quotes from the response file.
  73. set(CMAKE_${lang}_COMPILE_OBJECT
  74. "<CMAKE_${lang}_COMPILER> ${_tR} -DWIN32 <DEFINES> <INCLUDES> <FLAGS> -o<OBJECT>${_COMPILE_${lang}} -c <SOURCE>"
  75. )
  76. set(CMAKE_${lang}_LINK_EXECUTABLE
  77. "<CMAKE_${lang}_COMPILER> ${_tR} -e<TARGET> <LINK_FLAGS> <FLAGS> ${CMAKE_START_TEMP_FILE} <LINK_LIBRARIES> <OBJECTS>${CMAKE_END_TEMP_FILE}"
  78. # "implib -c -w <TARGET_IMPLIB> <TARGET>"
  79. )
  80. # place <DEFINES> outside the response file because Borland refuses
  81. # to parse quotes from the response file.
  82. set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE
  83. "cpp32 -DWIN32 <DEFINES> <INCLUDES> <FLAGS> -o<PREPROCESSED_SOURCE>${_COMPILE_${lang}} -c <SOURCE>"
  84. )
  85. # Borland >= 5.6 allows -P option for cpp32, <= 5.5 does not
  86. # Create a module library.
  87. set(CMAKE_${lang}_CREATE_SHARED_MODULE
  88. "<CMAKE_${lang}_COMPILER> ${_tR} ${_tD} ${CMAKE_START_TEMP_FILE}-e<TARGET> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS>${CMAKE_END_TEMP_FILE}"
  89. )
  90. # Create an import library for another target.
  91. set(CMAKE_${lang}_CREATE_IMPORT_LIBRARY
  92. "implib -c -w <TARGET_IMPLIB> <TARGET>"
  93. )
  94. # Create a shared library.
  95. # First create a module and then its import library.
  96. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  97. ${CMAKE_${lang}_CREATE_SHARED_MODULE}
  98. ${CMAKE_${lang}_CREATE_IMPORT_LIBRARY}
  99. )
  100. # create a static library
  101. set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
  102. "tlib ${CMAKE_START_TEMP_FILE}/p512 <LINK_FLAGS> /a <TARGET_QUOTED> <OBJECTS>${CMAKE_END_TEMP_FILE}"
  103. )
  104. # Precompile Headers
  105. if (EMBARCADERO)
  106. set(CMAKE_PCH_EXTENSION .pch)
  107. set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>)
  108. set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}})
  109. endif()
  110. # Initial configuration flags.
  111. string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_tM}")
  112. string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -Od -v")
  113. string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O1 -DNDEBUG")
  114. string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2 -DNDEBUG")
  115. string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Od")
  116. set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "import32.lib")
  117. endmacro()