summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
blob: 2035eb4de2a570316b41ecfca273f8a1cc796807 (plain)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

include(RunCMake)

macro(run_cmake_target test subtest target)
  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
  set(RunCMake_TEST_NO_CLEAN 1)
  run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN})

  unset(RunCMake_TEST_BINARY_DIR)
  unset(RunCMake_TEST_NO_CLEAN)
endmacro()

if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
  # Intel compiler does not reject bad flags or objects!
  set(RunCMake_TEST_OUTPUT_MERGE TRUE)
  set(RunCMake_TEST_OPTIONS -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
  if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
    list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
  endif()

  run_cmake(LINK_OPTIONS)

  run_cmake_target(LINK_OPTIONS basic LinkOptions)
  run_cmake_target(LINK_OPTIONS interface LinkOptions_consumer)
  run_cmake_target(LINK_OPTIONS interface-static LinkOptions_consumer_static)
  run_cmake_target(LINK_OPTIONS static LinkOptions_static --config Release)
  run_cmake_target(LINK_OPTIONS shared LinkOptions_shared --config Release)
  run_cmake_target(LINK_OPTIONS mod LinkOptions_mod --config Release)
  run_cmake_target(LINK_OPTIONS exe LinkOptions_exe --config Release)


  run_cmake(genex_LINK_LANGUAGE)

  run_cmake_target(genex_LINK_LANGUAGE interface LinkOptions_shared_interface --config Release)
  run_cmake_target(genex_LINK_LANGUAGE shared_c LinkOptions_shared_c --config Release)
  run_cmake_target(genex_LINK_LANGUAGE LINKER_LANGUAGE LinkOptions_shared_cxx --config Release)
  run_cmake_target(genex_LINK_LANGUAGE mod LinkOptions_mod --config Release)
  run_cmake_target(genex_LINK_LANGUAGE exe LinkOptions_exe --config Release)

  run_cmake(genex_LINK_LANG_AND_ID)

  run_cmake_target(genex_LINK_LANG_AND_ID interface LinkOptions_shared_interface --config Release)
  run_cmake_target(genex_LINK_LANG_AND_ID shared_c LinkOptions_shared_c --config Release)
  run_cmake_target(genex_LINK_LANG_AND_ID LINKER_LANGUAGE LinkOptions_shared_cxx --config Release)
  run_cmake_target(genex_LINK_LANG_AND_ID mod LinkOptions_mod --config Release)
  run_cmake_target(genex_LINK_LANG_AND_ID exe LinkOptions_exe --config Release)

  run_cmake(genex_DEVICE_LINK)

  run_cmake_target(genex_DEVICE_LINK interface LinkOptions_shared_interface --config Release)
  run_cmake_target(genex_DEVICE_LINK private LinkOptions_private --config Release)
  if (CMake_TEST_CUDA)
    # Separable compilation is only supported on NVCC.
    if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
      run_cmake_target(genex_DEVICE_LINK CMP0105_UNSET LinkOptions_CMP0105_UNSET --config Release)
      run_cmake_target(genex_DEVICE_LINK CMP0105_OLD LinkOptions_CMP0105_OLD --config Release)
      run_cmake_target(genex_DEVICE_LINK CMP0105_NEW LinkOptions_CMP0105_NEW --config Release)
      run_cmake_target(genex_DEVICE_LINK device LinkOptions_device --config Release)
    endif()

    run_cmake_target(genex_DEVICE_LINK no_device LinkOptions_no_device --config Release)
  endif()

  unset(RunCMake_TEST_OPTIONS)
  unset(RunCMake_TEST_OUTPUT_MERGE)
endif()

run_cmake(bad_SHELL_usage)

if(RunCMake_GENERATOR MATCHES "(Ninja|Makefile)")
  run_cmake(LINKER_expansion)

  run_cmake_target(LINKER_expansion LINKER linker)
  run_cmake_target(LINKER_expansion LINKER_SHELL linker_shell)
endif()

run_cmake(empty_keyword_args)

if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
  # Intel compiler does not reject bad flags or objects!
  set(RunCMake_TEST_OUTPUT_MERGE TRUE)
  if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
    set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
  endif()

  run_cmake(CMP0099-NEW)
  run_cmake_target(CMP0099-NEW basic LinkOptions_exe)


  run_cmake(CMP0099-OLD)
  run_cmake_target(CMP0099-OLD basic LinkOptions_exe)

  unset(RunCMake_TEST_OPTIONS)
  unset(RunCMake_TEST_OUTPUT_MERGE)
endif()