summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/Framework/RunCMakeTest.cmake
blob: 6ee61a30b732c8475ea4c73213f16f238254bab5 (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
include(RunCMake)

run_cmake(InstallBeforeFramework)

function(framework_layout_test Name Toolchain Type)
  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkLayout-build)
  set(RunCMake_TEST_NO_CLEAN 1)
  set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake")
  list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}")

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

  run_cmake(FrameworkLayout)
  run_cmake_command(${Name} ${CMAKE_COMMAND} --build .)
endfunction()

framework_layout_test(iOSFrameworkLayout-build ios SHARED)
framework_layout_test(iOSFrameworkLayout-build ios STATIC)
framework_layout_test(OSXFrameworkLayout-build osx SHARED)
framework_layout_test(OSXFrameworkLayout-build osx STATIC)

function(framework_type_test Toolchain Type UseProperty)
  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${Toolchain}${Type}FrameworkType-build)
  set(RunCMake_TEST_NO_CLEAN 1)
  set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/${Toolchain}.cmake")
  list(APPEND RunCMake_TEST_OPTIONS "-DFRAMEWORK_TYPE=${Type}")
  if(NOT UseProperty)
    list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FRAMEWORK=YES")
  endif()

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

  run_cmake(FrameworkLayout)
  run_cmake_command(FrameworkType${Type}-build ${CMAKE_COMMAND} --build .)
endfunction()

framework_type_test(ios SHARED NO)
framework_type_test(ios STATIC NO)
framework_type_test(osx SHARED NO)
framework_type_test(osx STATIC NO)

framework_type_test(ios SHARED YES)
framework_type_test(ios STATIC YES)
framework_type_test(osx SHARED YES)
framework_type_test(osx STATIC YES)

function(framework_multi_config_postfix_test)
    set(configure_name "FrameworkMultiConfigPostfix")
    set(build_name "${configure_name}-build-intermediate")
    set(build_name_final "${configure_name}-build-final")

    if(RunCMake_GENERATOR MATCHES "Ninja Multi-Config")
        set(RunCMake_TEST_OPTIONS
            "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_CROSS_CONFIGS=all")
    elseif(RunCMake_GENERATOR MATCHES "Xcode")
        set(RunCMake_TEST_OPTIONS
            "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release")
    else()
        set(RunCMake_TEST_OPTIONS "-DCMAKE_BUILD_TYPE=Debug")
    endif()

    set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${configure_name})
    set(RunCMake_TEST_NO_CLEAN 1)

    file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
    file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
    run_cmake(${configure_name})
    unset(RunCMake_TEST_OPTIONS)

    if(RunCMake_GENERATOR MATCHES "Ninja Multi-Config")
        run_cmake_command(${build_name_final} ${CMAKE_COMMAND} --build . --target all:all)
    elseif(RunCMake_GENERATOR MATCHES "Xcode")
        run_cmake_command(${build_name} ${CMAKE_COMMAND} --build . --config Release)
        run_cmake_command(${build_name} ${CMAKE_COMMAND} --build . --config Debug)
        run_cmake_command(${build_name_final} ${CMAKE_COMMAND} --build . --config Debug)
    else()
        run_cmake_command(${build_name_final} ${CMAKE_COMMAND} --build .)
    endif()
endfunction()

framework_multi_config_postfix_test()