2008-03-25 18:27:18 +03:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
2012-08-13 21:47:32 +04:00
|
|
|
project(CommandLineTest)
|
2003-07-24 18:58:40 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(CMAKE_BIN_DIR ${CMAKE_COMMAND} PATH)
|
|
|
|
macro(EXEC_CMAKE_COMMAND CMAKE_ARGS)
|
|
|
|
exec_program("${CMAKE_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
|
|
|
|
if(${RET})
|
|
|
|
message(SEND_ERROR "CMake command failed with arguments \"${CMAKE_ARGS}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
2003-07-24 18:58:40 +04:00
|
|
|
|
2005-02-17 15:53:03 +03:00
|
|
|
EXEC_CMAKE_COMMAND("-E chdir \"${CMAKE_CURRENT_SOURCE_DIR}\" \"${CMAKE_COMMAND}\" -E echo \"Hello World\"")
|
2005-02-16 21:15:25 +03:00
|
|
|
EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -L ${CommandLineTest_SOURCE_DIR}\"")
|
|
|
|
EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LA ${CommandLineTest_SOURCE_DIR}\"")
|
|
|
|
EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LH ${CommandLineTest_SOURCE_DIR}\"")
|
|
|
|
EXEC_CMAKE_COMMAND("-E time \"${CMAKE_COMMAND} -N -LAH ${CommandLineTest_SOURCE_DIR}\"")
|
|
|
|
EXEC_CMAKE_COMMAND("--help")
|
|
|
|
EXEC_CMAKE_COMMAND("--help-command-list")
|
2007-10-10 19:47:43 +04:00
|
|
|
EXEC_CMAKE_COMMAND("--help add_executable")
|
|
|
|
EXEC_CMAKE_COMMAND("--help-command add_executable")
|
2005-02-16 21:15:25 +03:00
|
|
|
EXEC_CMAKE_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/cmake.txt\"")
|
|
|
|
EXEC_CMAKE_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/cmake.man\"")
|
|
|
|
EXEC_CMAKE_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/cmake.html\"")
|
|
|
|
EXEC_CMAKE_COMMAND("--copyright \"${CMAKE_CURRENT_BINARY_DIR}/Copyright.txt\"")
|
|
|
|
EXEC_CMAKE_COMMAND("--version \"${CMAKE_CURRENT_BINARY_DIR}/version.txt\"")
|
2003-07-24 18:58:40 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(CommandLineTest CommandLineTest.cxx)
|
2004-04-28 18:52:20 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(CMAKE_COMMAND_PATH "${CMAKE_COMMAND}" PATH)
|
|
|
|
set(CTEST_COMMAND "${CMAKE_COMMAND_PATH}/ctest")
|
|
|
|
macro(EXEC_CTEST_COMMAND CMAKE_ARGS)
|
|
|
|
exec_program("${CTEST_COMMAND}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
|
|
|
|
if(${RET})
|
|
|
|
message(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
2012-08-13 21:47:32 +04:00
|
|
|
macro(EXEC_CTEST_COMMAND_WITH_DIR DIR CMAKE_ARGS)
|
|
|
|
exec_program("${CTEST_COMMAND}" "${DIR}" ARGS "${CMAKE_ARGS}" RETURN_VALUE RET)
|
|
|
|
if(${RET})
|
|
|
|
message(SEND_ERROR "CTest command failed with arguments \"${CMAKE_ARGS}\"")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endmacro()
|
2004-05-11 02:06:11 +04:00
|
|
|
|
2005-02-16 21:15:25 +03:00
|
|
|
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N")
|
|
|
|
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-R complex -N")
|
|
|
|
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-E Simple -N")
|
|
|
|
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-E Simple -N")
|
|
|
|
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I -10")
|
|
|
|
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I 10-")
|
|
|
|
EXEC_CTEST_COMMAND_WITH_DIR("${CMAKE_CURRENT_BINARY_DIR}/../.." "-N -I 3,4")
|
|
|
|
EXEC_CTEST_COMMAND("--help")
|
|
|
|
EXEC_CTEST_COMMAND("--copyright")
|
|
|
|
EXEC_CTEST_COMMAND("--help-full \"${CMAKE_CURRENT_BINARY_DIR}/ctest.txt\"")
|
|
|
|
EXEC_CTEST_COMMAND("--help-man \"${CMAKE_CURRENT_BINARY_DIR}/ctest.man\"")
|
|
|
|
EXEC_CTEST_COMMAND("--help-html \"${CMAKE_CURRENT_BINARY_DIR}/ctest.html\"")
|
|
|
|
EXEC_CTEST_COMMAND("--version")
|
2004-05-11 02:06:11 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(THIS_SHOULD_BE_SET)
|
|
|
|
message(STATUS "***************************")
|
|
|
|
message(STATUS "PreLoad.cmake works fine.")
|
|
|
|
message(STATUS "***************************")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message("***************************")
|
|
|
|
message(FATAL_ERROR "PreLoad.cmake does not work.")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2005-06-03 22:42:05 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(DEFINED ENV{TEST_ENVIRONMENT_VARIABLE_NOTSET})
|
|
|
|
message(SEND_ERROR "Environment variable definition test broken!")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2006-02-10 23:45:27 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(ENV{TEST_ENVIRONMENT_VARIABLE} "Environment variable set")
|
|
|
|
if("$ENV{TEST_ENVIRONMENT_VARIABLE}" STREQUAL "Environment variable set")
|
|
|
|
message(STATUS "Environment variable set to: $ENV{TEST_ENVIRONMENT_VARIABLE}")
|
|
|
|
if(NOT DEFINED ENV{TEST_ENVIRONMENT_VARIABLE})
|
|
|
|
message(SEND_ERROR "Environment variable definition test failed!")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
message(SEND_ERROR "Environment variable setting is broken")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|