Windows-Embarcadero.cmake 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #=============================================================================
  2. # Copyright 2002-2012 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distribute this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. # This module is shared by multiple languages; use include blocker.
  14. if(__WINDOWS_EMBARCADERO)
  15. return()
  16. endif()
  17. set(__WINDOWS_EMBARCADERO 1)
  18. set(BORLAND 1)
  19. if("${CMAKE_${_lang}_COMPILER_VERSION}" VERSION_LESS 6.30)
  20. # Borland target type flags (bcc32 -h -t):
  21. set(_tW "-tW") # -tW GUI App (implies -U__CONSOLE__)
  22. set(_tC "-tWC") # -tWC Console App (implies -D__CONSOLE__=1)
  23. set(_tD "-tWD") # -tWD Build a DLL (implies -D__DLL__=1 -D_DLL=1)
  24. set(_tM "-tWM") # -tWM Enable threads (implies -D__MT__=1 -D_MT=1)
  25. set(_tR "-tWR -tW-") # -tWR Use DLL runtime (implies -D_RTLDLL, and '-tW' too!!)
  26. # Notes:
  27. # - The flags affect linking so we pass them to the linker.
  28. # - The flags affect preprocessing so we pass them to the compiler.
  29. # - Since '-tWR' implies '-tW' we use '-tWR -tW-' instead.
  30. # - Since '-tW-' disables '-tWD' we use '-tWR -tW- -tWD' for DLLs.
  31. else()
  32. set(EMBARCADERO 1)
  33. set(_tC "-tC") # Target is a console application
  34. set(_tD "-tD") # Target is a shared library
  35. set(_tM "-tM") # Target is multi-threaded
  36. set(_tR "-tR") # Target uses the dynamic RTL
  37. set(_tW "-tW") # Target is a Windows application
  38. endif()
  39. set(_COMPILE_C "-c")
  40. set(_COMPILE_CXX "-P -c")
  41. set(CMAKE_LIBRARY_PATH_FLAG "-L")
  42. set(CMAKE_LINK_LIBRARY_FLAG "")
  43. set(CMAKE_FIND_LIBRARY_SUFFIXES "-bcc.lib" ".lib")
  44. # uncomment these out to debug makefiles
  45. #set(CMAKE_START_TEMP_FILE "")
  46. #set(CMAKE_END_TEMP_FILE "")
  47. #set(CMAKE_VERBOSE_MAKEFILE 1)
  48. # Borland cannot handle + in the file name, so mangle object file name
  49. set (CMAKE_MANGLE_OBJECT_FILE_NAMES "ON")
  50. # extra flags for a win32 exe
  51. set(CMAKE_CREATE_WIN32_EXE "${_tW}" )
  52. # extra flags for a console app
  53. set(CMAKE_CREATE_CONSOLE_EXE "${_tC}" )
  54. set (CMAKE_BUILD_TYPE Debug CACHE STRING
  55. "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.")
  56. set (CMAKE_EXE_LINKER_FLAGS_INIT "${_tM} -lS:10000000 -lSc:10000000 ")
  57. set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "-v")
  58. set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "-v")
  59. set (CMAKE_SHARED_LINKER_FLAGS_INIT ${CMAKE_EXE_LINKER_FLAGS_INIT})
  60. set (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT ${CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT})
  61. set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT})
  62. set (CMAKE_MODULE_LINKER_FLAGS_INIT ${CMAKE_SHARED_LINKER_FLAGS_INIT})
  63. set (CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT ${CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT})
  64. set (CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT})
  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. # compile a source file into an object file
  69. # place <DEFINES> outside the response file because Borland refuses
  70. # to parse quotes from the response file.
  71. set(CMAKE_${lang}_COMPILE_OBJECT
  72. "<CMAKE_${lang}_COMPILER> ${_tR} <DEFINES> ${CMAKE_START_TEMP_FILE}-DWIN32 -o<OBJECT> <FLAGS> ${_COMPILE_${lang}} <SOURCE>${CMAKE_END_TEMP_FILE}"
  73. )
  74. set(CMAKE_${lang}_LINK_EXECUTABLE
  75. "<CMAKE_${lang}_COMPILER> ${_tR} -e<TARGET> ${CMAKE_START_TEMP_FILE}<LINK_FLAGS> <FLAGS> <LINK_LIBRARIES> <OBJECTS>${CMAKE_END_TEMP_FILE}"
  76. # "implib -c -w <TARGET_IMPLIB> <TARGET>"
  77. )
  78. # place <DEFINES> outside the response file because Borland refuses
  79. # to parse quotes from the response file.
  80. set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE
  81. "cpp32 <DEFINES> ${CMAKE_START_TEMP_FILE}-DWIN32 <FLAGS> -o<PREPROCESSED_SOURCE> ${_COMPILE_${lang}} <SOURCE>${CMAKE_END_TEMP_FILE}"
  82. )
  83. # Borland >= 5.6 allows -P option for cpp32, <= 5.5 does not
  84. # Create a module library.
  85. set(CMAKE_${lang}_CREATE_SHARED_MODULE
  86. "<CMAKE_${lang}_COMPILER> ${_tR} ${_tD} ${CMAKE_START_TEMP_FILE}-e<TARGET> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS>${CMAKE_END_TEMP_FILE}"
  87. )
  88. # Create an import library for another target.
  89. set(CMAKE_${lang}_CREATE_IMPORT_LIBRARY
  90. "implib -c -w <TARGET_IMPLIB> <TARGET>"
  91. )
  92. # Create a shared library.
  93. # First create a module and then its import library.
  94. set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
  95. ${CMAKE_${lang}_CREATE_SHARED_MODULE}
  96. ${CMAKE_${lang}_CREATE_IMPORT_LIBRARY}
  97. )
  98. # create a static library
  99. set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
  100. "tlib ${CMAKE_START_TEMP_FILE}/p512 <LINK_FLAGS> /a <TARGET_QUOTED> <OBJECTS>${CMAKE_END_TEMP_FILE}"
  101. )
  102. # Initial configuration flags.
  103. set(CMAKE_${lang}_FLAGS_INIT "${_tM}")
  104. set(CMAKE_${lang}_FLAGS_DEBUG_INIT "-Od -v")
  105. set(CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-O1 -DNDEBUG")
  106. set(CMAKE_${lang}_FLAGS_RELEASE_INIT "-O2 -DNDEBUG")
  107. set(CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-Od")
  108. set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "import32.lib")
  109. endmacro()