summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCameron Cawley <ccawley2011@gmail.com>2022-04-17 13:12:57 +0100
committerBrad King <brad.king@kitware.com>2022-05-06 10:40:59 -0400
commit6a2b016bbd35f5843cc95e36431928fd0905a61c (patch)
treeb1d8b95203bb5729f2d8e025667d253cfe7c766a
parent33da5824acefcb4106ce89fc2278111dc3846c0a (diff)
downloadcmake-6a2b016bbd35f5843cc95e36431928fd0905a61c.tar.gz
OpenWatcom: Support CMAKE_WATCOM_RUNTIME_LIBRARY with Linux and OS/2 builds
-rw-r--r--Help/policy/CMP0136.rst3
-rw-r--r--Help/prop_tgt/WATCOM_RUNTIME_LIBRARY-VALUES.txt6
-rw-r--r--Help/prop_tgt/WATCOM_RUNTIME_LIBRARY.rst3
-rw-r--r--Help/variable/CMAKE_WATCOM_RUNTIME_LIBRARY.rst4
-rw-r--r--Modules/Platform/Linux-OpenWatcom-C.cmake1
-rw-r--r--Modules/Platform/Linux-OpenWatcom-CXX.cmake1
-rw-r--r--Modules/Platform/Linux-OpenWatcom.cmake13
-rw-r--r--Modules/Platform/OS2-OpenWatcom-C.cmake1
-rw-r--r--Modules/Platform/OS2-OpenWatcom-CXX.cmake1
-rw-r--r--Modules/Platform/OS2-OpenWatcom.cmake15
10 files changed, 42 insertions, 6 deletions
diff --git a/Help/policy/CMP0136.rst b/Help/policy/CMP0136.rst
index 4a718e968e..5414278f04 100644
--- a/Help/policy/CMP0136.rst
+++ b/Help/policy/CMP0136.rst
@@ -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
diff --git a/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY-VALUES.txt b/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY-VALUES.txt
index c29d73e983..cdf99d087e 100644
--- a/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY-VALUES.txt
+++ b/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY-VALUES.txt
@@ -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.
diff --git a/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY.rst b/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY.rst
index 9f031fab05..3752862b2e 100644
--- a/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY.rst
+++ b/Help/prop_tgt/WATCOM_RUNTIME_LIBRARY.rst
@@ -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::
diff --git a/Help/variable/CMAKE_WATCOM_RUNTIME_LIBRARY.rst b/Help/variable/CMAKE_WATCOM_RUNTIME_LIBRARY.rst
index 979a53349f..feb2a602ec 100644
--- a/Help/variable/CMAKE_WATCOM_RUNTIME_LIBRARY.rst
+++ b/Help/variable/CMAKE_WATCOM_RUNTIME_LIBRARY.rst
@@ -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::
diff --git a/Modules/Platform/Linux-OpenWatcom-C.cmake b/Modules/Platform/Linux-OpenWatcom-C.cmake
index 383349a217..7236c74326 100644
--- a/Modules/Platform/Linux-OpenWatcom-C.cmake
+++ b/Modules/Platform/Linux-OpenWatcom-C.cmake
@@ -1 +1,2 @@
include(Platform/Linux-OpenWatcom)
+__linux_open_watcom(C)
diff --git a/Modules/Platform/Linux-OpenWatcom-CXX.cmake b/Modules/Platform/Linux-OpenWatcom-CXX.cmake
index 383349a217..a5f386b838 100644
--- a/Modules/Platform/Linux-OpenWatcom-CXX.cmake
+++ b/Modules/Platform/Linux-OpenWatcom-CXX.cmake
@@ -1 +1,2 @@
include(Platform/Linux-OpenWatcom)
+__linux_open_watcom(CXX)
diff --git a/Modules/Platform/Linux-OpenWatcom.cmake b/Modules/Platform/Linux-OpenWatcom.cmake
index 5b4e995376..678d373a36 100644
--- a/Modules/Platform/Linux-OpenWatcom.cmake
+++ b/Modules/Platform/Linux-OpenWatcom.cmake
@@ -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()
diff --git a/Modules/Platform/OS2-OpenWatcom-C.cmake b/Modules/Platform/OS2-OpenWatcom-C.cmake
index 21a4d9e04a..a6a6b782eb 100644
--- a/Modules/Platform/OS2-OpenWatcom-C.cmake
+++ b/Modules/Platform/OS2-OpenWatcom-C.cmake
@@ -1 +1,2 @@
include(Platform/OS2-OpenWatcom)
+__os2_open_watcom(C)
diff --git a/Modules/Platform/OS2-OpenWatcom-CXX.cmake b/Modules/Platform/OS2-OpenWatcom-CXX.cmake
index 21a4d9e04a..846bb29179 100644
--- a/Modules/Platform/OS2-OpenWatcom-CXX.cmake
+++ b/Modules/Platform/OS2-OpenWatcom-CXX.cmake
@@ -1 +1,2 @@
include(Platform/OS2-OpenWatcom)
+__os2_open_watcom(CXX)
diff --git a/Modules/Platform/OS2-OpenWatcom.cmake b/Modules/Platform/OS2-OpenWatcom.cmake
index 998fb9fd6a..720b9530ef 100644
--- a/Modules/Platform/OS2-OpenWatcom.cmake
+++ b/Modules/Platform/OS2-OpenWatcom.cmake
@@ -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()