"Borland Makefiles" generator always adds "-tR" flag
This flags causes linking errors when trying to link cmake built libs with executables built without the flag (non cmake/legacy projects).
Setting this flags enables "Dynamic linking of RTL". It's not possible not mix libs/executables with and without this setting, making any libs produced by cmake incompatible with executables that don't use this setting. Unfortunately it's not possible to turn this flag off with "-tR-" (as with some other bcc32 flags).
The offending file is "Modules/Platform/Windows-Embarcadero.cmake" The following lines set a variable later used on the commandline:
- https://gitlab.kitware.com/cmake/cmake/blob/v3.9.1/Modules/Platform/Windows-Embarcadero.cmake#L30
- https://gitlab.kitware.com/cmake/cmake/blob/v3.9.1/Modules/Platform/Windows-Embarcadero.cmake#L19
It's no problem defining this variable later, using add_compile_options for instance. So (apart from backward compatibility) it would not be an issue to remove this option entirely.
It might be better to add a configuration option for it though...
Workaround: add following lines to project CMakeLists.txt:
string(REPLACE "-tR " "" CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
string(REPLACE "-tR " "" CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_CXX_LINK_EXECUTABLE})
string(REPLACE "-tR " "" CMAKE_CXX_CREATE_PREPROCESSED_SOURCE ${CMAKE_CXX_CREATE_PREPROCESSED_SOURCE})
string(REPLACE "-tR " "" CMAKE_CXX_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE})
string(REPLACE "-tR " "" CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_CXX_CREATE_IMPORT_LIBRARY})
string(REPLACE "-tR " "" CMAKE_CXX_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY})
set(CMAKE_CXX_CREATE_SHARED_LIBRARY
${CMAKE_CXX_CREATE_SHARED_MODULE}
${CMAKE_CXX_CREATE_IMPORT_LIBRARY}
)