Windows-Embarcadero.cmake 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. set (CMAKE_${lang}_LINKER_WRAPPER_FLAG "-l")
  66. # compile a source file into an object file
  67. # place <DEFINES> outside the response file because Borland refuses
  68. # to parse quotes from the response file.
  69. set(CMAKE_${lang}_COMPILE_OBJECT
  70. "<CMAKE_${lang}_COMPILER> ${_tR} -DWIN32 <DEFINES> <INCLUDES> <FLAGS> -o<OBJECT> ${_COMPILE_${lang}} <SOURCE>"
  71. )
  72. set(CMAKE_${lang}_LINK_EXECUTABLE
  73. "<CMAKE_${lang}_COMPILER> ${_tR} -e<TARGET> <LINK_FLAGS> <FLAGS> ${CMAKE_START_TEMP_FILE} <LINK_LIBRARIES> <OBJECTS>${CMAKE_END_TEMP_FILE}"
  74. # "implib -c -w <TARGET_IMPLIB> <TARGET>"
  75. )
  76. # place <DEFINES> outside the response file because Borland refuses
  77. # to parse quotes from the response file.
  78. set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE
  79. "cpp32 -DWIN32 <DEFINES> <INCLUDES> <FLAGS> -o<PREPROCESSED_SOURCE> ${_COMPILE_${lang}} <SOURCE>"
  80. )
  81. # Borland >= 5.6 allows -P option for cpp32, <= 5.5 does not
  82. # Create a module library.
  83. set(CMAKE_${lang}_CREATE_SHARED_MODULE
  84. "<CMAKE_${lang}_COMPILER> ${_tR} ${_tD} ${CMAKE_START_TEMP_FILE}-e<TARGET> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS>${CMAKE_END_TEMP_FILE}"
  85. )
  86. # Create an import library for another target.
  87. set(CMAKE_${lang}_CREATE_IMPORT_LIBRARY
  88. "implib -c -w <TARGET_IMPLIB> <TARGET>"
  89. )
  90. # Create a shared library.
  91. # First create a module and then its import library.
  92. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  93. ${CMAKE_${lang}_CREATE_SHARED_MODULE}
  94. ${CMAKE_${lang}_CREATE_IMPORT_LIBRARY}
  95. )
  96. # create a static library
  97. set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
  98. "tlib ${CMAKE_START_TEMP_FILE}/p512 <LINK_FLAGS> /a <TARGET_QUOTED> <OBJECTS>${CMAKE_END_TEMP_FILE}"
  99. )
  100. # Precompile Headers
  101. if (EMBARCADERO)
  102. set(CMAKE_PCH_EXTENSION .pch)
  103. set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE>)
  104. set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER>)
  105. endif()
  106. # Initial configuration flags.
  107. string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_tM}")
  108. string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -Od -v")
  109. string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O1 -DNDEBUG")
  110. string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2 -DNDEBUG")
  111. string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Od")
  112. set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "import32.lib")
  113. endmacro()