1# Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2# file Copyright.txt or https://cmake.org/licensing for details. 3 4 5# This module is shared by multiple languages; use include blocker. 6if(__WINDOWS_EMBARCADERO) 7 return() 8endif() 9set(__WINDOWS_EMBARCADERO 1) 10 11set(BORLAND 1) 12 13set(__pch_header_C "c-header") 14set(__pch_header_CXX "c++-header") 15set(__pch_header_OBJC "objective-c-header") 16set(__pch_header_OBJCXX "objective-c++-header") 17 18if("${CMAKE_${_lang}_COMPILER_VERSION}" VERSION_LESS 6.30) 19 # Borland target type flags (bcc32 -h -t): 20 set(_tW "-tW") # -tW GUI App (implies -U__CONSOLE__) 21 set(_tC "-tWC") # -tWC Console App (implies -D__CONSOLE__=1) 22 set(_tD "-tWD") # -tWD Build a DLL (implies -D__DLL__=1 -D_DLL=1) 23 set(_tM "-tWM") # -tWM Enable threads (implies -D__MT__=1 -D_MT=1) 24 set(_tR "-tWR -tW-") # -tWR Use DLL runtime (implies -D_RTLDLL, and '-tW' too!!) 25 # Notes: 26 # - The flags affect linking so we pass them to the linker. 27 # - The flags affect preprocessing so we pass them to the compiler. 28 # - Since '-tWR' implies '-tW' we use '-tWR -tW-' instead. 29 # - Since '-tW-' disables '-tWD' we use '-tWR -tW- -tWD' for DLLs. 30else() 31 set(EMBARCADERO 1) 32 set(_tC "-tC") # Target is a console application 33 set(_tD "-tD") # Target is a shared library 34 set(_tM "-tM") # Target is multi-threaded 35 set(_tR "-tR") # Target uses the dynamic RTL 36 set(_tW "-tW") # Target is a Windows application 37endif() 38set(_COMPILE_C "") 39set(_COMPILE_CXX " -P") 40 41set(CMAKE_LIBRARY_PATH_FLAG "-L") 42set(CMAKE_LINK_LIBRARY_FLAG "") 43 44set(CMAKE_FIND_LIBRARY_SUFFIXES "-bcc.lib" ".lib") 45 46# uncomment these out to debug makefiles 47#set(CMAKE_START_TEMP_FILE "") 48#set(CMAKE_END_TEMP_FILE "") 49#set(CMAKE_VERBOSE_MAKEFILE 1) 50 51# Borland cannot handle + in the file name, so mangle object file name 52set (CMAKE_MANGLE_OBJECT_FILE_NAMES "ON") 53 54set (CMAKE_BUILD_TYPE Debug CACHE STRING 55 "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.") 56 57foreach(t EXE SHARED MODULE) 58 string(APPEND CMAKE_${t}_LINKER_FLAGS_INIT " ${_tM} -lS:1048576 -lSc:4098 -lH:1048576 -lHc:8192 ") 59 string(APPEND CMAKE_${t}_LINKER_FLAGS_DEBUG_INIT " -v") 60 string(APPEND CMAKE_${t}_LINKER_FLAGS_RELWITHDEBINFO_INIT " -v") 61endforeach() 62 63# The Borland link tool does not support multiple concurrent 64# invocations within a single working directory. 65if(NOT DEFINED CMAKE_JOB_POOL_LINK) 66 set(CMAKE_JOB_POOL_LINK BCC32LinkPool) 67 get_property(_bccjp GLOBAL PROPERTY JOB_POOLS) 68 if(NOT _bccjp MATCHES "BCC32LinkPool=") 69 set_property(GLOBAL APPEND PROPERTY JOB_POOLS BCC32LinkPool=1) 70 endif() 71 unset(_bccjp) 72endif() 73 74macro(__embarcadero_language lang) 75 set(CMAKE_${lang}_COMPILE_OPTIONS_DLL "${_tD}") # Note: This variable is a ';' separated list 76 set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "${_tD}") # ... while this is a space separated string. 77 set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1) 78 79 set (CMAKE_${lang}_LINKER_WRAPPER_FLAG "-l") 80 81 # compile a source file into an object file 82 # place <DEFINES> outside the response file because Borland refuses 83 # to parse quotes from the response file. 84 set(CMAKE_${lang}_COMPILE_OBJECT 85 "<CMAKE_${lang}_COMPILER> ${_tR} -DWIN32 <DEFINES> <INCLUDES> <FLAGS> -o<OBJECT>${_COMPILE_${lang}} -c <SOURCE>" 86 ) 87 88 set(CMAKE_${lang}_LINK_EXECUTABLE 89 "<CMAKE_${lang}_COMPILER> ${_tR} -e<TARGET> <LINK_FLAGS> <FLAGS> ${CMAKE_START_TEMP_FILE} <LINK_LIBRARIES> <OBJECTS>${CMAKE_END_TEMP_FILE}" 90 # "implib -c -w <TARGET_IMPLIB> <TARGET>" 91 ) 92 93 # place <DEFINES> outside the response file because Borland refuses 94 # to parse quotes from the response file. 95 set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE 96 "cpp32 -DWIN32 <DEFINES> <INCLUDES> <FLAGS> -o<PREPROCESSED_SOURCE>${_COMPILE_${lang}} -c <SOURCE>" 97 ) 98 # Borland >= 5.6 allows -P option for cpp32, <= 5.5 does not 99 100 # Create a module library. 101 set(CMAKE_${lang}_CREATE_SHARED_MODULE 102 "<CMAKE_${lang}_COMPILER> ${_tR} ${_tD} ${CMAKE_START_TEMP_FILE}-e<TARGET> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS>${CMAKE_END_TEMP_FILE}" 103 ) 104 105 # Create an import library for another target. 106 set(CMAKE_${lang}_CREATE_IMPORT_LIBRARY 107 "implib -c -w <TARGET_IMPLIB> <TARGET>" 108 ) 109 110 # Create a shared library. 111 # First create a module and then its import library. 112 set(CMAKE_${lang}_CREATE_SHARED_LIBRARY 113 ${CMAKE_${lang}_CREATE_SHARED_MODULE} 114 ${CMAKE_${lang}_CREATE_IMPORT_LIBRARY} 115 ) 116 117 # create a static library 118 set(CMAKE_${lang}_CREATE_STATIC_LIBRARY 119 "tlib ${CMAKE_START_TEMP_FILE}/p512 <LINK_FLAGS> /a <TARGET_QUOTED> <OBJECTS>${CMAKE_END_TEMP_FILE}" 120 ) 121 122 set(CMAKE_${lang}_CREATE_WIN32_EXE "${_tW}") 123 set(CMAKE_${lang}_CREATE_CONSOLE_EXE "${_tC}") 124 125 # Precompile Headers 126 if (EMBARCADERO) 127 set(CMAKE_PCH_EXTENSION .pch) 128 set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>) 129 set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}}) 130 endif() 131 132 # Initial configuration flags. 133 string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_tM}") 134 string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -Od -v") 135 string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -O1 -DNDEBUG") 136 string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O2 -DNDEBUG") 137 string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -Od") 138 set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "import32.lib") 139endmacro() 140