Debian Codegraph @

Tests/RunCMake/RuntimePath/RunCMakeTest.cmake

raw
1 include(RunCMake)
2
3
4 function(run_RuntimePath name)
5 # Use a single build tree for a few tests without cleaning.
6 set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${name}-build)
7 set(RunCMake_TEST_NO_CLEAN 1)
8 if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
9 set(RunCMake_TEST_OPTIONS -Dcfg_dir= -DCMAKE_BUILD_TYPE=Debug)
10 else()
11 set(RunCMake_TEST_OPTIONS -Dcfg_dir=/$<CONFIG>)
12 endif()
13 file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
14 file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
15 run_cmake(${name})
16 run_cmake_command(${name}-build ${CMAKE_COMMAND} --build . --config Debug)
17 endfunction()
18
19 set(cfg_dir)
20 if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
21 set(cfg_dir /Debug)
22 endif()
23
24 if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")
25 run_RuntimePath(SymlinkImplicit)
26 run_cmake_command(SymlinkImplicitCheck
27 ${CMAKE_COMMAND} -Ddir=${RunCMake_BINARY_DIR}/SymlinkImplicit-build -Dcfg_dir=${cfg_dir} -P ${RunCMake_SOURCE_DIR}/SymlinkImplicitCheck.cmake)
28
29 run_RuntimePath(Relative)
30
31 run_RuntimePath(Genex)
32 run_cmake_command(GenexCheck
33 ${CMAKE_COMMAND} -Ddir=${RunCMake_BINARY_DIR}/Genex-build -P ${RunCMake_SOURCE_DIR}/GenexCheck.cmake)
34 endif()
35
36 block()
37 set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Stub-build)
38 if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
39 set(bin_dir "${RunCMake_TEST_BINARY_DIR}/Debug")
40 set(lib_dir "${RunCMake_TEST_BINARY_DIR}/lib/Debug")
41 else()
42 set(bin_dir "${RunCMake_TEST_BINARY_DIR}")
43 set(lib_dir "${RunCMake_TEST_BINARY_DIR}/lib")
44 endif()
45 run_cmake(Stub)
46 set(RunCMake_TEST_NO_CLEAN 1)
47 run_cmake_command(Stub-build ${CMAKE_COMMAND} --build . --config Debug)
48 if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|SunOS|GNU)$|BSD")
49 set(ldpath LD_LIBRARY_PATH)
50 elseif(CMAKE_SYSTEM_NAME MATCHES "^(Darwin)$")
51 set(ldpath DYLD_LIBRARY_PATH)
52 elseif(CMAKE_SYSTEM_NAME MATCHES "^(AIX)$")
53 set(ldpath LIBPATH)
54 endif()
55 if(ldpath)
56 run_cmake_command(Stub-fail ${CMAKE_COMMAND} -E env LANG=C ${bin_dir}/StubExe)
57 run_cmake_command(Stub-pass ${CMAKE_COMMAND} -E env --modify ${ldpath}=path_list_prepend:${lib_dir} ${bin_dir}/StubExe)
58 endif()
59 endblock()