Hi Muhammad,
You need to add this code to a separate CTest script (CTestScript.cmake, for
example) and then run it using ctest -S CTestScript.cmake. Since the wiki page
I linked yesterday provides only some complex examples, I am sending the key
part of my CTest script. As you can see, its operation strongly depends on
environment variables (some of them are provided by Windows). You’ll probably
need to remove most of my if’s.
set(CTEST_SOURCE_DIRECTORY "$ENV{SCRIPT_FOLDER}")
set(CTEST_BINARY_DIRECTORY "$ENV{BINARY_PROJECT_FOLDER}")
set(CTEST_SITE $ENV{COMPUTERNAME})
set(CTEST_BUILD_NAME $ENV{TEST_CASE_NAME})
ctest_start()
ctest_configure(RETURN_VALUE configure_failed)
if($ENV{DO_UPDATE})
ctest_update()
endif($ENV{DO_UPDATE})
if($ENV{DO_BUILD})
ctest_build(RETURN_VALUE build_failed)
endif($ENV{DO_BUILD})
if (($ENV{DO_TEST}) AND NOT (configure_failed OR build_failed))
ctest_test(RETURN_VALUE test_failed)
endif(($ENV{DO_TEST}) AND NOT (configure_failed OR build_failed))
if($ENV{DO_DASHBOARD})
ctest_submit()
endif($ENV{DO_DASHBOARD})
if (configure_failed OR build_failed OR test_failed)
message(FATAL_ERROR "Test ${CTEST_BUILD_NAME} failed.") # sets return value
to -1
endif(configure_failed OR build_failed OR test_failed)
Best regards,
Miroslav
From: Muhammad Osama [mailto:[email protected]]
Sent: Monday, April 18, 2016 8:33 PM
To: Matějů Miroslav, Ing.
Cc: [email protected]
Subject: Re: [CMake] CMakeLists.txt: How to print a message if ctest fails?
Hi Miroslav,
Thank you for replying! I added this in my root CMakeLists.txt, purposely made
the ctest's test fail but didn't get the output message.
Is this script suppose to be added inside CMakeLists.txt? Or am I doing this
incorrectly?
Thanks again,
On Mon, Apr 18, 2016 at 6:30 AM, Matějů Miroslav, Ing.
<[email protected]<mailto:[email protected]>> wrote:
Hi Muhammad,
you can use a CTest script, see https://cmake.org/Wiki/CMake_Scripting_Of_CTest
for details. I use the following code in my CTest script:
if(configure_failed OR build_failed OR test_failed)
message(FATAL_ERROR "Test ${CTEST_BUILD_NAME} failed.")
endif()
Best regards,
Miroslav
From: CMake [mailto:[email protected]<mailto:[email protected]>] On
Behalf Of Muhammad Osama
Sent: Friday, April 15, 2016 8:53 PM
To: [email protected]<mailto:[email protected]>
Subject: [CMake] CMakeLists.txt: How to print a message if ctest fails?
Is there a way I can setup CMakeLists.txt to print a message if ctest tests
fail? For example:
cmake ..
make
ctest // fails
message output: Please contact [email protected]<mailto:[email protected]> to resolve
testing problems.
Note the message output is not for cmake but for ctest.
--
Muhammad
--
Muhammad
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake