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