Windows-Embarcadero.cmake 4.9 KB

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