Windows-OpenWatcom.cmake 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # This module is shared by multiple languages; use include blocker.
  4. if(__WINDOWS_OPENWATCOM)
  5. return()
  6. endif()
  7. set(__WINDOWS_OPENWATCOM 1)
  8. set(CMAKE_LIBRARY_PATH_FLAG "libpath ")
  9. set(CMAKE_LINK_LIBRARY_FLAG "library ")
  10. set(CMAKE_LINK_LIBRARY_FILE_FLAG "library ")
  11. if(CMAKE_VERBOSE_MAKEFILE)
  12. set(CMAKE_WCL_QUIET)
  13. set(CMAKE_WLINK_QUIET)
  14. set(CMAKE_LIB_QUIET)
  15. else()
  16. set(CMAKE_WCL_QUIET "-zq")
  17. set(CMAKE_WLINK_QUIET "option quiet")
  18. set(CMAKE_LIB_QUIET "-q")
  19. endif()
  20. string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ")
  21. set(CMAKE_CREATE_WIN32_EXE "system nt_win" )
  22. set(CMAKE_CREATE_CONSOLE_EXE "system nt" )
  23. string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " system nt_dll")
  24. string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " system nt_dll")
  25. foreach(type SHARED MODULE EXE)
  26. string(APPEND CMAKE_${type}_LINKER_FLAGS_DEBUG_INIT " debug all opt map")
  27. string(APPEND CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO_INIT " debug all opt map")
  28. endforeach()
  29. set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list
  30. set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated string.
  31. set(CMAKE_RC_COMPILER "rc" )
  32. set(CMAKE_BUILD_TYPE_INIT Debug)
  33. # single/multi-threaded /-bm
  34. # static/DLL run-time libraries /-br
  35. # default is setup for multi-threaded + DLL run-time libraries
  36. string(APPEND CMAKE_C_FLAGS_INIT " -bt=nt -w3 -dWIN32 -br -bm")
  37. string(APPEND CMAKE_CXX_FLAGS_INIT " -bt=nt -xs -w3 -dWIN32 -br -bm")
  38. foreach(lang C CXX)
  39. string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -d2")
  40. string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -s -os -d0 -dNDEBUG")
  41. string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -s -ot -d0 -dNDEBUG")
  42. string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -s -ot -d1 -dNDEBUG")
  43. endforeach()
  44. foreach(type CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE)
  45. set(CMAKE_C_${type}_USE_WATCOM_QUOTE 1)
  46. set(CMAKE_CXX_${type}_USE_WATCOM_QUOTE 1)
  47. endforeach()
  48. set(CMAKE_C_CREATE_IMPORT_LIBRARY
  49. "wlib -c -q -n -b <TARGET_IMPLIB> +<TARGET_QUOTED>")
  50. set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY})
  51. set(CMAKE_C_LINK_EXECUTABLE
  52. "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
  53. set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE})
  54. # compile a C++ file into an object file
  55. set(CMAKE_CXX_COMPILE_OBJECT
  56. "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ <DEFINES> <INCLUDES> <FLAGS> -fo<OBJECT> -c -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
  57. # compile a C file into an object file
  58. set(CMAKE_C_COMPILE_OBJECT
  59. "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ <DEFINES> <INCLUDES> <FLAGS> -fo<OBJECT> -c -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
  60. # preprocess a C source file
  61. set(CMAKE_C_CREATE_PREPROCESSED_SOURCE
  62. "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ <DEFINES> <INCLUDES> <FLAGS> -fo<PREPROCESSED_SOURCE> -pl -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
  63. # preprocess a C++ source file
  64. set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE
  65. "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} -d+ <DEFINES> <INCLUDES> <FLAGS> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
  66. set(CMAKE_CXX_CREATE_SHARED_LIBRARY
  67. "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
  68. string(REPLACE " option implib=<TARGET_IMPLIB>" ""
  69. CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
  70. # create a C shared library
  71. set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
  72. # create a C shared module
  73. set(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE})
  74. # create a C++ static library
  75. set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b <TARGET_QUOTED> <LINK_FLAGS> <OBJECTS> ")
  76. # create a C static library
  77. set(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY})
  78. if(NOT _CMAKE_WATCOM_VERSION)
  79. set(_CMAKE_WATCOM_VERSION 1)
  80. if(CMAKE_C_COMPILER_VERSION)
  81. set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
  82. set(_compiler_id ${CMAKE_C_COMPILER_ID})
  83. else()
  84. set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
  85. set(_compiler_id ${CMAKE_CXX_COMPILER_ID})
  86. endif()
  87. set(WATCOM16)
  88. set(WATCOM17)
  89. set(WATCOM18)
  90. set(WATCOM19)
  91. if("${_compiler_id}" STREQUAL "OpenWatcom")
  92. if("${_compiler_version}" VERSION_LESS 1.7)
  93. set(WATCOM16 1)
  94. endif()
  95. if("${_compiler_version}" VERSION_EQUAL 1.7)
  96. set(WATCOM17 1)
  97. endif()
  98. if("${_compiler_version}" VERSION_EQUAL 1.8)
  99. set(WATCOM18 1)
  100. endif()
  101. if("${_compiler_version}" VERSION_EQUAL 1.9)
  102. set(WATCOM19 1)
  103. endif()
  104. endif()
  105. endif()