OpenWatcom: Support CMAKE_WATCOM_RUNTIME_LIBRARY with Linux and OS/2 builds

This commit is contained in:
Cameron Cawley
2022-04-17 13:12:57 +01:00
committed by Brad King
parent 33da5824ac
commit 6a2b016bbd
10 changed files with 42 additions and 6 deletions

View File

@@ -22,7 +22,8 @@ out of the default :variable:`CMAKE_<LANG>_FLAGS_<CONFIG>` values and instead
offer a first-class abstraction. The :variable:`CMAKE_WATCOM_RUNTIME_LIBRARY`
variable and :prop_tgt:`WATCOM_RUNTIME_LIBRARY` target property may be set to
select the Watcom runtime library. If they are not set then CMake uses the
default value ``MultiThreadedDLL`` which is equivalent to the original flags.
default value ``MultiThreadedDLL`` on Windows and ``SingleThreaded`` on other
platforms, which is equivalent to the original flags.
This policy provides compatibility with projects that have not been updated
to be aware of the abstraction. The policy setting takes effect as of the

View File

@@ -3,13 +3,15 @@
statically-linked runtime library.
``SingleThreadedDLL``
Compile with ``-br`` or equivalent flag(s) to use a single-threaded
dynamically-linked runtime library.
dynamically-linked runtime library. This is not available for Linux
targets.
``MultiThreaded``
Compile with ``-bm`` or equivalent flag(s) to use a multi-threaded
statically-linked runtime library.
``MultiThreadedDLL``
Compile with ``-bm -br`` or equivalent flag(s) to use a multi-threaded
dynamically-linked runtime library.
dynamically-linked runtime library. This is not available for Linux
targets.
The value is ignored on non-Watcom compilers but an unsupported value will
be rejected as an error when using a compiler targeting the Watcom ABI.

View File

@@ -24,7 +24,8 @@ selects for the target ``foo`` a multi-threaded statically-linked runtime
library.
If this property is not set then CMake uses the default value
``MultiThreadedDLL`` to select a Watcom runtime library.
``MultiThreadedDLL`` on Windows and ``SingleThreaded`` on other
platforms to select a Watcom runtime library.
.. note::

View File

@@ -26,8 +26,8 @@ library.
If this variable is not set then the :prop_tgt:`WATCOM_RUNTIME_LIBRARY` target
property will not be set automatically. If that property is not set then
CMake uses the default value ``MultiThreadedDLL`` to select a Watcom runtime
library.
CMake uses the default value ``MultiThreadedDLL`` on Windows and
``SingleThreaded`` on other platforms to select a Watcom runtime library.
.. note::

View File

@@ -1 +1,2 @@
include(Platform/Linux-OpenWatcom)
__linux_open_watcom(C)

View File

@@ -1 +1,2 @@
include(Platform/Linux-OpenWatcom)
__linux_open_watcom(CXX)

View File

@@ -10,6 +10,14 @@ string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " system linux opt noextension")
string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " system linux")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " system linux")
cmake_policy(GET CMP0136 __LINUX_WATCOM_CMP0136)
if(__LINUX_WATCOM_CMP0136 STREQUAL "NEW")
set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "SingleThreaded")
else()
set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "")
endif()
unset(__LINUX_WATCOM_CMP0136)
# single/multi-threaded /-bm
# default is setup for single-threaded libraries
string(APPEND CMAKE_C_FLAGS_INIT " -bt=linux")
@@ -23,3 +31,8 @@ if(CMAKE_CROSSCOMPILING)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES $ENV{WATCOM}/lh)
endif()
endif()
macro(__linux_open_watcom lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_SingleThreaded "")
set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_MultiThreaded -bm)
endmacro()

View File

@@ -1 +1,2 @@
include(Platform/OS2-OpenWatcom)
__os2_open_watcom(C)

View File

@@ -1 +1,2 @@
include(Platform/OS2-OpenWatcom)
__os2_open_watcom(CXX)

View File

@@ -16,6 +16,14 @@ endif()
set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated string.
cmake_policy(GET CMP0136 __OS2_WATCOM_CMP0136)
if(__OS2_WATCOM_CMP0136 STREQUAL "NEW")
set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "SingleThreaded")
else()
set(CMAKE_WATCOM_RUNTIME_LIBRARY_DEFAULT "")
endif()
unset(__OS2_WATCOM_CMP0136)
string(APPEND CMAKE_C_FLAGS_INIT " -bt=os2")
string(APPEND CMAKE_CXX_FLAGS_INIT " -bt=os2 -xs")
@@ -33,3 +41,10 @@ if(NOT CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES $ENV{WATCOM}/h $ENV{WATCOM}/h/os2)
endif()
endif()
macro(__os2_open_watcom lang)
set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_SingleThreaded "")
set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_SingleThreadedDLL -br)
set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_MultiThreaded -bm)
set(CMAKE_${lang}_COMPILE_OPTIONS_WATCOM_RUNTIME_LIBRARY_MultiThreadedDLL -bm -br)
endmacro()