2 #=============================================================================
3 # Copyright 2002-2012 Kitware, Inc.
5 # Distributed under the OSI-approved BSD License (the "License");
6 # see accompanying file Copyright.txt for details.
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.)
15 # This module is shared by multiple languages; use include blocker.
16 if(__WINDOWS_EMBARCADERO)
19 set(__WINDOWS_EMBARCADERO 1)
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!!)
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.
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
44 set(_COMPILE_CXX "-P -c")
46 set(CMAKE_LIBRARY_PATH_FLAG "-L")
47 set(CMAKE_LINK_LIBRARY_FLAG "")
49 set(CMAKE_FIND_LIBRARY_SUFFIXES "-bcc.lib" ".lib")
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)
56 # Borland cannot handle + in the file name, so mangle object file name
57 set (CMAKE_MANGLE_OBJECT_FILE_NAMES "ON")
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}" )
64 set (CMAKE_BUILD_TYPE Debug CACHE STRING
65 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.")
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})
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.
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}"
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>"
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}"
99 # Borland >= 5.6 allows -P option for cpp32, <= 5.5 does not
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}"
106 # Create an import library for another target.
107 set(CMAKE_${lang}_CREATE_IMPORT_LIBRARY
108 "implib -c -w <TARGET_IMPLIB> <TARGET>"
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}
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}"
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")