]> granicus.if.org Git - gc/commitdiff
Enable CMake-based build for Borland and Watcom compilers
authorIvan Maidanski <ivmai@mail.ru>
Wed, 17 Jul 2019 07:08:12 +0000 (10:08 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 17 Jul 2019 07:44:29 +0000 (10:44 +0300)
Issue #105 (bdwgc).

* CMakeLists.txt [BORLAND] (add_compile_options): Specify /a4 and
/w /w-pro /w-aus /w-par /w-ccc /w-inl /w-rch; add comment.
* CMakeLists.txt [WATCOM] (add_compile_options): Specify /zp4 and /wx.
* CMakeLists.txt [enable_werror && BORLAND] (add_compile_options):
Specify /w!.
* CMakeLists.txt [enable_werror && WATCOM] (add_compile_options):
Specify /we.
* CMakeLists.txt [!enable_single_obj_compilation && !BUILD_SHARED_LIBS
&& BORLAND] (add_compile_options): Specify /w-use; add comment.
* CMakeLists.txt [build_tests && WATCOM] (gctest): Specify /wcd=13
/wcd=201 /wcd=367 /wcd=368 /wcd=726 target compile options; add comment.
* doc/README.win32 (Watcom compiler): Mention that OpenWatcom 2.0 is
tested on; remove note that cord is not ported; add note about the
new way to build the collector using CMake script.

CMakeLists.txt
doc/README.win32

index 4fef247f2a527b37fe5fc4dbf35c903a78555ef7..a8806602dcb2ab37490a4afd074b82e25f050f78 100644 (file)
@@ -66,14 +66,26 @@ if (APPLE AND ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL ""))
         CACHE STRING "Build architectures for Mac OS X" FORCE)
 endif()
 
+# Set struct packing alignment to word (instead of 1-byte).
+if (BORLAND)
+  add_compile_options(/a4)
+elseif (WATCOM)
+  add_compile_options(/zp4)
+endif()
+
 # Output all warnings.
-if (MSVC)
+if (BORLAND)
+  # All warnings except for particular ones.
+  add_compile_options(/w /w-pro /w-aus /w-par /w-ccc /w-inl /w-rch)
+elseif (MSVC)
   # All warnings but ignoring "unreferenced formal parameter" and
   # "conditional expression is constant" ones.
   add_compile_options(/W4 /wd4100 /wd4127)
   # Disable crt security warnings, since unfortunately they warn about all
   # sorts of safe uses of strncpy.
   add_definitions("-D_CRT_SECURE_NO_DEPRECATE")
+elseif (WATCOM)
+  add_compile_options(/wx)
 else()
   # TODO add -[W]pedantic -Wno-long-long
   add_compile_options(-Wall -Wextra)
@@ -252,8 +264,12 @@ if (enable_checksums)
 endif(enable_checksums)
 
 if (enable_werror)
-  if (MSVC)
+  if (BORLAND)
+    add_compile_options(/w!)
+  elseif (MSVC)
     add_compile_options(/WX)
+  elseif (WATCOM)
+    add_compile_options(/we)
   else()
     add_compile_options(-Werror)
     if (APPLE)
@@ -269,6 +285,9 @@ if (enable_single_obj_compilation OR BUILD_SHARED_LIBS)
     add_definitions("-DGC_PTHREAD_START_STANDALONE")
     set(SRC ${SRC} pthread_start.c)
   endif(CMAKE_USE_PTHREADS_INIT)
+elseif (BORLAND)
+  # Suppress "GC_push_contents_hdr() is declared but never used" warning.
+  add_compile_options(/w-use)
 endif()
 
 if (BUILD_SHARED_LIBS)
@@ -367,6 +386,12 @@ if (build_tests)
   add_executable(gctest WIN32 tests/test.c)
   target_link_libraries(gctest PRIVATE gc)
   add_test(NAME gctest COMMAND gctest)
+  if (WATCOM)
+    # Suppress "conditional expression in if statement is always true/false"
+    # and "unreachable code" warnings in GC_MALLOC_[ATOMIC_]WORDS.
+    target_compile_options(gctest PRIVATE
+                           /wcd=13 /wcd=201 /wcd=367 /wcd=368 /wcd=726)
+  endif()
 
   add_executable(hugetest tests/huge_test.c)
   target_link_libraries(hugetest PRIVATE gc)
index 67b14763d5a7b25d4ccef9c974954d6736e08273..f05fb9c625a61879740df2afab8f08ecb485f1c2 100644 (file)
@@ -106,7 +106,7 @@ Watcom compiler
 
 Ivan V. Demakov's README for the Watcom port:
 
-The collector has been compiled with Watcom C 10.6 and 11.0.
+The collector has been tested with Watcom C 10.6, 11.0 and OpenWatcom 2.0.
 It runs under win32, win32s, and even under msdos with dos4gw
 dos-extender. It should also run under OS/2, though this isn't
 tested. Under win32 the collector can be built either as dll
@@ -118,8 +118,6 @@ attempt has been made) leads to broken executables.
 
 Incremental collection is supported (except for MSDOS and OS/2).
 
-cord is not ported.
-
 Before compiling you may need to edit WCC_MAKEFILE to set target
 platform, library type (dynamic or static), calling conventions, and
 optimization options.
@@ -134,6 +132,10 @@ If the gc is compiled as dll, the macro "GC_DLL" should be defined before
 including "gc.h" (for example, with -DGC_DLL compiler option). It's
 important, otherwise resulting programs will not run.
 
+The alternate way to compile the collector is to use cmake build system:
+    cmake -G "Watcom WMake" .
+    cmake --build .
+
 Special note for OpenWatcom users: the C (unlike the C++) compiler (of the
 latest stable release, not sure for older ones) doesn't force pointer global
 variables (i.e. not struct fields, not sure for locals) to be aligned unless