summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/ExportImport/RunCMakeTest.cmake
blob: d07fca2a1ac699ac71ddefa3278843ca60ba2045 (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
cmake_minimum_required(VERSION 3.23)
include(RunCMake)

function(run_ExportImport_test case)
  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-export-build)
  set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root)
  if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
    set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
  endif()
  run_cmake(${case}-export)
  unset(RunCMake_TEST_OPTIONS)
  set(RunCMake_TEST_NO_CLEAN 1)
  run_cmake_command(${case}-export-build ${CMAKE_COMMAND} --build . --config Debug)
  run_cmake_command(${case}-export-install ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -P cmake_install.cmake)
  unset(RunCMake_TEST_NO_CLEAN)

  set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-import-build)
  run_cmake_with_options(${case}-import
    -Dfoo_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/foo
    -Dbar_DIR=${CMAKE_INSTALL_PREFIX}/lib/cmake/bar
    )
endfunction()

run_ExportImport_test(SharedDep)