RunCMakeTest.cmake 2.1 KB

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