summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake
blob: 5ec40187329eaa167e9b9e9fdbeb4792df33e07c (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
include(RunCMake)

run_cmake(BadSourceExpression1)
run_cmake(BadSourceExpression2)
run_cmake(BadSourceExpression3)
run_cmake(BadObjSource1)
run_cmake(BadObjSource2)
if(RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]")
  run_cmake(ImportNotSupported)
  run_cmake(InstallNotSupported)
else()
  run_cmake(Import)
  run_cmake(Install)
  run_cmake(InstallLinkedObj1)
  run_cmake(InstallLinkedObj2)
endif()
run_cmake(Export)

function (run_object_lib_build name)
  # Use a single build tree for a few tests without cleaning.
  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
  set(RunCMake_TEST_NO_CLEAN 1)
  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  run_cmake(${name})
  run_cmake_command(${name}-build ${CMAKE_COMMAND} --build .)
endfunction ()

function (run_object_lib_build2 name)
  # Use a single build tree for a few tests without cleaning.
  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
  set(RunCMake_TEST_NO_CLEAN 1)
  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  run_cmake(${name})
  set(RunCMake_TEST_OUTPUT_MERGE 1)
  run_cmake_command(${name}-build ${CMAKE_COMMAND} --build .)
endfunction ()

if(NOT (RunCMake_GENERATOR STREQUAL "Xcode" AND "$ENV{CMAKE_OSX_ARCHITECTURES}" MATCHES "[;$]"))
  run_object_lib_build(CheckTargetObjects)
endif()

run_object_lib_build(LinkObjLHSShared)
run_object_lib_build(LinkObjLHSStatic)
run_object_lib_build(LinkObjRHSShared)
run_object_lib_build(LinkObjRHSStatic)
run_object_lib_build2(LinkObjRHSObject)
run_object_lib_build(LinkObjRHSShared2)
run_object_lib_build(LinkObjRHSStatic2)
run_object_lib_build2(LinkObjRHSObject2)
run_object_lib_build(TransitiveDependencies)

run_cmake(MissingSource)
run_cmake(ObjWithObj)
run_cmake(OwnSources)
run_cmake(PostBuild)
run_cmake(PreBuild)
run_cmake(PreLink)


function(run_Dependencies)
  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Dependencies-build)
  set(RunCMake_TEST_NO_CLEAN 1)

  file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")

  if(RunCMake_GENERATOR STREQUAL "Borland Makefiles" OR
      RunCMake_GENERATOR STREQUAL "Watcom WMake")
    set(fs_delay 3)
  else()
    set(fs_delay 1.125)
  endif()

  run_cmake_command(Dependencies-build ${CMAKE_COMMAND} -E copy ${RunCMake_SOURCE_DIR}/depends_obj1.c ${RunCMake_TEST_BINARY_DIR}/depends_obj.c)
  run_cmake(Dependencies)
  run_cmake_command(Dependencies-build ${CMAKE_COMMAND} --build . --config Debug)
  run_cmake_command(Dependencies-build ${CMAKE_COMMAND} -E sleep ${fs_delay})
  run_cmake_command(Dependencies-build ${CMAKE_COMMAND} -E copy ${RunCMake_SOURCE_DIR}/depends_obj0.c ${RunCMake_TEST_BINARY_DIR}/depends_obj.c)
  run_cmake_command(Dependencies-build ${CMAKE_COMMAND} --build . --config Debug)
  run_cmake_command(Dependencies-build ${CMAKE_CTEST_COMMAND} -C Debug -V)
endfunction()

run_Dependencies()