mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 07:08:38 -05:00
f53bd6f450
CMake 3.27 deprecates compatibility with CMake < 3.5. Update tests that do not cover older interfaces to avoid the deprecation warning. Follow the pattern from: * commit7b07ccdd2b(Tests/*Only: Update cmake_minimum_required versions, 2020-06-15, v3.19.0-rc1~629^2~1) * commit72e7c45e98(Tests: Bump CMake minimum required in tests to 2.8.12, 2020-12-22, v3.20.0-rc1~224^2) * commitf6b4db365a(Tests: bump cmake_minimum_required version to 2.8.12, 2021-04-04, v3.21.0-rc1~372^2) Also remove explicit `cmake_policy` settings made redundant by the version.
43 lines
1.5 KiB
CMake
43 lines
1.5 KiB
CMake
cmake_minimum_required(VERSION 3.5)
|
|
project(TestsWorkingDirectoryProj)
|
|
|
|
add_executable(WorkingDirectory main.c)
|
|
|
|
enable_testing()
|
|
|
|
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
|
|
|
|
add_test(NAME WorkingDirectory0 COMMAND WorkingDirectory "${CMAKE_BINARY_DIR}")
|
|
|
|
add_test(NAME WorkingDirectory1 COMMAND WorkingDirectory "${CMAKE_BINARY_DIR}")
|
|
set_tests_properties(WorkingDirectory1 PROPERTIES
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
|
)
|
|
|
|
string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_BINARY_DIR}")
|
|
|
|
add_test(NAME WorkingDirectory2 COMMAND WorkingDirectory "${_parent_dir}")
|
|
set_tests_properties(WorkingDirectory2 PROPERTIES
|
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/.."
|
|
)
|
|
|
|
set(_default_cwd "${CMAKE_BINARY_DIR}")
|
|
|
|
# FIXME: How to deal with /debug, /release, etc. with VS or Xcode?
|
|
if(${CMAKE_GENERATOR} MATCHES "Makefiles")
|
|
add_test(WorkingDirectory3 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd})
|
|
endif()
|
|
|
|
add_test(NAME WorkingDirectory4 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND WorkingDirectory ${CMAKE_BINARY_DIR})
|
|
|
|
string(REGEX REPLACE "/[^/]*$" "" _parent_dir "${CMAKE_BINARY_DIR}")
|
|
|
|
add_test(NAME WorkingDirectory5 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/.. COMMAND WorkingDirectory ${_parent_dir})
|
|
|
|
# FIXME: How to deal with /debug, /release, etc. with VS or Xcode?
|
|
if(${CMAKE_GENERATOR} MATCHES "Makefiles")
|
|
add_test(WorkingDirectory6 ${EXECUTABLE_OUTPUT_PATH}/WorkingDirectory ${_default_cwd} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..)
|
|
endif()
|
|
|
|
add_subdirectory(subdir)
|