Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Tests / RunCMake / target_sources / RunCMakeTest.cmake
1 include(RunCMake)
2
3 if(RunCMake_GENERATOR STREQUAL "Xcode")
4   run_cmake(ConfigNotAllowed)
5 endif()
6
7 run_cmake(EmptyKeywordArgs)
8 run_cmake(OriginDebug)
9 run_cmake(CMP0026-LOCATION)
10 run_cmake(CMP0076-OLD)
11 run_cmake(CMP0076-WARN)
12 run_cmake(RelativePathInInterface)
13 run_cmake(RelativePathInSubdirGenEx)
14 run_cmake(RelativePathInSubdirInterface)
15 run_cmake(RelativePathInSubdirPrivate)
16 run_cmake(RelativePathInSubdirInclude)
17 run_cmake(ExportBuild)
18 run_cmake(AddCustomTargetPublicSources)
19 run_cmake(AddCustomTargetPrivateSources)
20 run_cmake(AddCustomTargetInterfaceSources)
21 run_cmake(AddCustomTargetSources)
22 run_cmake(AddCustomTargetCheckProperty)
23 run_cmake(AddCustomTargetGenx)
24
25 run_cmake(FileSetProperties)
26 run_cmake(FileSetNoType)
27 run_cmake(FileSetWrongType)
28 run_cmake(FileSetDefaultWrongType)
29 run_cmake(FileSetWrongTypeExperimental)
30 run_cmake(FileSetDefaultWrongTypeExperimental)
31 run_cmake(FileSetChangeScope)
32 run_cmake(FileSetChangeType)
33 run_cmake(FileSetWrongBaseDirs)
34 run_cmake(FileSetWrongBaseDirsRelative)
35 run_cmake(FileSetOverlappingBaseDirs)
36 run_cmake(FileSetInstallMissingSetsPrivate)
37 run_cmake(FileSetInstallMissingSetsInterface)
38 run_cmake(FileSetInstallMissingSetsInterfacePostInstall)
39 run_cmake(FileSetExportMissingSetsInterfacePostExport)
40 run_cmake(FileSetReadOnlyPrivate)
41 run_cmake(FileSetReadOnlyInterface)
42 run_cmake(FileSetNoExistInstall)
43 run_cmake(FileSetDirectories)
44 run_cmake(FileSetCustomTarget)
45 run_cmake(FileSetBadName)
46 if(APPLE)
47   run_cmake(FileSetFramework)
48 endif()
49
50 set(RunCMake_TEST_NO_CLEAN 1)
51 set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/FileSetGeneratedDependency-build")
52 file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
53 file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
54 run_cmake(FileSetGeneratedDependency)
55 run_cmake_command(FileSetGeneratedDependency-build ${CMAKE_COMMAND} --build . --config Debug)
56 unset(RunCMake_TEST_BINARY_DIR)
57 unset(RunCMake_TEST_NO_CLEAN)
58
59 set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0115=NEW)
60 run_cmake(FileSetFileNoExist)
61 unset(RunCMake_TEST_OPTIONS)
62
63 function(run_export_import name)
64   if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
65     set(_config_options "-DCMAKE_CONFIGURATION_TYPES=Debug\\\\;Release")
66   else()
67     set(_config_options -DCMAKE_BUILD_TYPE=Debug)
68   endif()
69
70   set(RunCMake_TEST_NO_CLEAN 1)
71   set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}Export-build")
72   set(RunCMake_TEST_OPTIONS "--install-prefix=${RunCMake_TEST_BINARY_DIR}/install" ${_config_options})
73   file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
74   file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
75   run_cmake(${name}Export)
76   run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --build . --config Debug)
77   run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --install . --config Debug)
78   if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
79     run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --build . --config Release)
80     run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --install . --config Release)
81   endif()
82   unset(RunCMake_TEST_OPTIONS)
83
84   set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}Import-build")
85   unset(RunCMake_TEST_OPTIONS)
86   file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
87   file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
88   run_cmake(${name}Import)
89   run_cmake_command(${name}Import-build ${CMAKE_COMMAND} --build . --config Debug)
90   if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
91     run_cmake_command(${name}Import-build ${CMAKE_COMMAND} --build . --config Release)
92   endif()
93
94   unset(RunCMake_TEST_BINARY_DIR)
95   unset(RunCMake_TEST_NO_CLEAN)
96 endfunction()
97
98 run_export_import(FileSet)