File: CMakeLists.txt

package info (click to toggle)
cmake 4.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 152,336 kB
  • sloc: ansic: 403,896; cpp: 303,920; sh: 4,105; python: 3,583; yacc: 3,106; lex: 1,279; f90: 538; asm: 471; lisp: 375; cs: 270; java: 266; fortran: 239; objc: 215; perl: 213; xml: 198; makefile: 111; javascript: 83; pascal: 63; tcl: 55; php: 25; ruby: 22
file content (49 lines) | stat: -rw-r--r-- 1,837 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
cmake_minimum_required(VERSION 3.23)
cmake_policy(SET CMP0136 NEW)
project(WatcomRuntimeLibrary)

function(verify_combinations threads lang src)
  set(verify_def_MultiThreaded -DVERIFY_MT)
  set(verify_def_DLL -DVERIFY_DLL)
  foreach(dll "" DLL)
    # Construct the name of this runtime library combination.
    set(rtl "${threads}${dll}")

    # Test that try_compile builds with this RTL.
    set(CMAKE_WATCOM_RUNTIME_LIBRARY "${rtl}")
    set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
    try_compile(${rtl}_COMPILES
      ${CMAKE_CURRENT_BINARY_DIR}/try_compile/${rtl}
      ${CMAKE_CURRENT_SOURCE_DIR}/${src}
      COMPILE_DEFINITIONS ${verify_def_${threads}} ${verify_def_${dll}}
      OUTPUT_VARIABLE ${rtl}_OUTPUT
      )
    if(${rtl}_COMPILES)
      message(STATUS "try_compile with ${rtl} worked")
    else()
      string(REPLACE "\n" "\n  " ${rtl}_OUTPUT "  ${${rtl}_OUTPUT}")
      message(SEND_ERROR "try_compile with ${rtl} failed:\n${${rtl}_OUTPUT}")
    endif()

    # Test that targets build with this RTL.
    set(CMAKE_WATCOM_RUNTIME_LIBRARY "$<$<BOOL:$<TARGET_PROPERTY:BOOL_TRUE>>:${rtl}>$<$<BOOL:$<TARGET_PROPERTY:BOOL_FALSE>>:BadContent>")
    add_library(${rtl}-${lang} ${src})
    set_property(TARGET ${rtl}-${lang} PROPERTY BOOL_TRUE TRUE)
    target_compile_definitions(${rtl}-${lang} PRIVATE ${verify_def_${threads}} ${verify_def_${dll}})
  endforeach()
endfunction()

function(verify lang src)
  add_library(default-${lang} ${src})
  target_compile_definitions(default-${lang} PRIVATE VERIFY_MT VERIFY_DLL)

  verify_combinations(SingleThreaded ${lang} ${src})
  verify_combinations(MultiThreaded ${lang} ${src})

  # Test known  default behavior when no flag is given.
  set(CMAKE_WATCOM_RUNTIME_LIBRARY "")
  add_library(empty-${lang} ${src})
endfunction()

verify(C verify.c)
verify(CXX verify.cxx)