2010-10-26 14:06:15 +04:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
2010-12-17 01:29:19 +03:00
|
|
|
project(TestsWorkingDirectoryProj)
|
2010-10-26 14:06:15 +04:00
|
|
|
|
2010-12-17 20:28:33 +03:00
|
|
|
add_executable(WorkingDirectory main.c)
|
2010-10-26 14:06:15 +04:00
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
|
2010-12-17 18:23:54 +03:00
|
|
|
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
|
|
|
|
|
2010-10-26 14:06:15 +04:00
|
|
|
add_test(NAME WorkingDirectory1 COMMAND WorkingDirectory)
|
|
|
|
set_tests_properties(WorkingDirectory1 PROPERTIES
|
|
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
2010-12-17 18:23:24 +03:00
|
|
|
PASS_REGULAR_EXPRESSION "Working directory: -->${CMAKE_BINARY_DIR}<--"
|
2010-10-26 14:06:15 +04:00
|
|
|
)
|
|
|
|
|
|
|
|
string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_BINARY_DIR}")
|
|
|
|
|
2010-12-17 19:06:59 +03:00
|
|
|
add_test(NAME WorkingDirectory2 COMMAND WorkingDirectory)
|
2010-10-26 14:06:15 +04:00
|
|
|
set_tests_properties(WorkingDirectory2 PROPERTIES
|
|
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.."
|
2010-12-17 18:23:24 +03:00
|
|
|
PASS_REGULAR_EXPRESSION "Working directory: -->${_parent_dir}<--"
|
2010-10-26 14:06:15 +04:00
|
|
|
)
|
|
|
|
|
2010-12-17 18:23:54 +03:00
|
|
|
get_filename_component(_default_cwd "${EXECUTABLE_OUTPUT_PATH}" PATH)
|
2010-10-26 14:06:15 +04:00
|
|
|
|
2010-12-17 18:24:14 +03:00
|
|
|
# FIXME: How to deal with /debug, /release, etc. with VS or XCode?
|
|
|
|
if(${CMAKE_GENERATOR} MATCHES "Makefiles")
|
2010-12-17 19:07:19 +03:00
|
|
|
add_test(WorkingDirectory3 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory)
|
2010-10-26 14:06:15 +04:00
|
|
|
set_tests_properties(WorkingDirectory3 PROPERTIES
|
2010-12-17 18:23:24 +03:00
|
|
|
PASS_REGULAR_EXPRESSION "Working directory: -->${_default_cwd}<--"
|
2010-10-26 14:06:15 +04:00
|
|
|
)
|
2010-12-17 18:24:14 +03:00
|
|
|
endif()
|
2010-12-17 00:50:34 +03:00
|
|
|
|
|
|
|
add_test(NAME WorkingDirectory4 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND WorkingDirectory)
|
|
|
|
set_tests_properties(WorkingDirectory4 PROPERTIES
|
2010-12-17 18:23:24 +03:00
|
|
|
PASS_REGULAR_EXPRESSION "Working directory: -->${CMAKE_BINARY_DIR}<--"
|
2010-12-17 00:50:34 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_BINARY_DIR}")
|
|
|
|
|
2010-12-17 19:06:59 +03:00
|
|
|
add_test(NAME WorkingDirectory5 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/.. COMMAND WorkingDirectory)
|
2010-12-17 00:50:34 +03:00
|
|
|
set_tests_properties(WorkingDirectory5 PROPERTIES
|
2010-12-17 18:23:24 +03:00
|
|
|
PASS_REGULAR_EXPRESSION "Working directory: -->${_parent_dir}<--"
|
2010-12-17 00:50:34 +03:00
|
|
|
)
|
|
|
|
|
2010-12-17 18:24:14 +03:00
|
|
|
# FIXME: How to deal with /debug, /release, etc. with VS or XCode?
|
|
|
|
if(${CMAKE_GENERATOR} MATCHES "Makefiles")
|
2010-12-17 19:07:19 +03:00
|
|
|
add_test(WorkingDirectory6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..)
|
2010-12-17 00:50:34 +03:00
|
|
|
set_tests_properties(WorkingDirectory6 PROPERTIES
|
2010-12-17 18:23:24 +03:00
|
|
|
PASS_REGULAR_EXPRESSION "Working directory: -->${_default_cwd}<--"
|
2010-12-17 00:50:34 +03:00
|
|
|
)
|
2010-12-17 18:24:14 +03:00
|
|
|
endif()
|