summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CommandLine/P_working-dir.cmake
blob: e2c0378eba5b6cc34dfa110a593aa1c1f11c3a34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if(NOT IS_DIRECTORY "${EXPECTED_WORKING_DIR}")
  message(FATAL_ERROR "EXPECTED_WORKING_DIR is not a directory: ${EXPECTED_WORKING_DIR}")
endif()

foreach(d CMAKE_BINARY_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_SOURCE_DIR CMAKE_CURRENT_SOURCE_DIR)
  if(NOT DEFINED ${d})
    message(FATAL_ERROR "${d} is not defined")
  endif()
  if(EXPECTED_WORKING_DIR STREQUAL "${${d}}")
    message(STATUS "${d} is the expected working directory (${EXPECTED_WORKING_DIR})")
  else()
    get_filename_component(resolved "${EXPECTED_WORKING_DIR}" REALPATH)
    if(resolved STREQUAL "${${d}}")
      message(STATUS "${d} is the expected working directory (${resolved}) after symlink resolution")
    else()
      message(FATAL_ERROR "${d} = \"${${d}}\" is not the expected working directory (${EXPECTED_WORKING_DIR})")
    endif()
  endif()
endforeach()