78 set(oneValueArgs REASON
80 set(multiValueArgs TESTS)
81 cmake_parse_arguments(CAMITK_TESTS_REQUIREMENT
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
83 # -- analyze requirements
84 #
transform statement to list in order to access left/middle/right value
if the requirement is
a test
85 string(REPLACE
" " "" REQUIRES_STATEMENT ${CAMITK_TESTS_REQUIREMENT_REQUIRES})
86 list(LENGTH REQUIRES_STATEMENT REQUIRES_STATEMENT_LENGTH)
88 if(REQUIRES_STATEMENT_LENGTH EQUAL 3)
89 # Requirement is a test, separate into parts and evaluate the requirement
90 list(GET REQUIRES_STATEMENT 0 REQUIRES_STATEMENT_LEFT_VALUE)
91 list(GET REQUIRES_STATEMENT 1 REQUIRES_STATEMENT_TEST)
92 list(GET REQUIRES_STATEMENT 2 REQUIRES_STATEMENT_RIGHT_VALUE)
93 # check the test statement. Can be either VERSION_LESS, VERSION_EQUAL or VERSION_GREATER
94 if(REQUIRES_STATEMENT_TEST STREQUAL
"VERSION_LESS")
95 if (${REQUIRES_STATEMENT_LEFT_VALUE} VERSION_LESS ${REQUIRES_STATEMENT_RIGHT_VALUE})
96 set(REQUIRES_EVAL TRUE)
98 set(REQUIRES_EVAL FALSE)
100 elseif(REQUIRES_STATEMENT_TEST STREQUAL
"VERSION_EQUAL")
101 if (${REQUIRES_STATEMENT_LEFT_VALUE} VERSION_EQUAL ${REQUIRES_STATEMENT_RIGHT_VALUE})
102 set(REQUIRES_EVAL TRUE)
104 set(REQUIRES_EVAL FALSE)
106 elseif(REQUIRES_STATEMENT_TEST STREQUAL
"VERSION_GREATER")
107 if (${REQUIRES_STATEMENT_LEFT_VALUE} VERSION_GREATER ${REQUIRES_STATEMENT_RIGHT_VALUE})
108 set(REQUIRES_EVAL TRUE)
110 set(REQUIRES_EVAL FALSE)
113 message(FATAL_ERROR
"\n Unknown three-parts requirement test: \"${CAMITK_TESTS_REQUIREMENT_REQUIRES}\"\n Use one of VERSION_LESS, VERSION_EQUAL or VERSION_GREATER.\n Check call stack below to fix this error.")
116 if(REQUIRES_STATEMENT_LENGTH EQUAL 2)
117 list(GET REQUIRES_STATEMENT 0 REQUIRES_STATEMENT_NOT)
118 list(GET REQUIRES_STATEMENT 1 REQUIRES_STATEMENT_TEST)
119 # REQUIRES_STATEMENT_NOT should be "NOT"
120 if(NOT REQUIRES_STATEMENT_NOT STREQUAL
"NOT")
121 message(FATAL_ERROR
"\n Unknown two-parts requirement test: \"${CAMITK_TESTS_REQUIREMENT_REQUIRES}\"\n Only NOT is supported.\n Check call stack below to fix this error.")
124 list(GET REQUIRES_STATEMENT 0 REQUIRES_STATEMENT_TEST)
127 # possible statement are WIN32, WIN64, MSVC, APPLE or UNIX
128 if(REQUIRES_STATEMENT_TEST STREQUAL
"WIN32")
130 set(REQUIRES_EVAL TRUE)
132 set(REQUIRES_EVAL FALSE)
134 elseif(REQUIRES_STATEMENT_TEST STREQUAL
"WIN64")
136 set(REQUIRES_EVAL TRUE)
138 set(REQUIRES_EVAL FALSE)
140 elseif(REQUIRES_STATEMENT_TEST STREQUAL
"MSVC")
142 set(REQUIRES_EVAL TRUE)
144 set(REQUIRES_EVAL FALSE)
146 elseif(REQUIRES_STATEMENT_TEST STREQUAL
"APPLE")
148 set(REQUIRES_EVAL TRUE)
150 set(REQUIRES_EVAL FALSE)
152 elseif(REQUIRES_STATEMENT_TEST STREQUAL
"UNIX")
154 set(REQUIRES_EVAL TRUE)
156 set(REQUIRES_EVAL FALSE)
161 if(REQUIRES_STATEMENT_NOT STREQUAL
"NOT")
162 if(REQUIRES_EVAL STREQUAL
"TRUE")
163 set(REQUIRES_EVAL FALSE)
165 set(REQUIRES_EVAL TRUE)
170 # -- disable tests if the requirement is not met
171 string(REPLACE
"" " " CAMITK_TESTS_REQUIREMENT_TESTS_STRING
"${CAMITK_TESTS_REQUIREMENT_TESTS}")
172 if(NOT ${REQUIRES_EVAL})
173 foreach(TEST_NAME ${CAMITK_TESTS_REQUIREMENT_TESTS})
174 # CMake < 3.9 did not have the DISABLED test property. Use WILL_FAIL instead
175 if(${CMAKE_VERSION} VERSION_LESS
"3.9")
176 set_tests_properties(${TEST_NAME} PROPERTIES WILL_FAIL
true)
178 set_tests_properties(${TEST_NAME} PROPERTIES DISABLED
true)
181 set(DISABLE_MESSAGE
"Test requirement \"${CAMITK_TESTS_REQUIREMENT_REQUIRES}\": Failed\n Disabled tests: ${CAMITK_TESTS_REQUIREMENT_TESTS_STRING}\n")
182 if(${CMAKE_VERSION} VERSION_LESS
"3.9")
183 set(DISABLE_MESSAGE ${DISABLE_MESSAGE}
" (using WILL_FAIL property because CMake < 3.9)\n")
185 set(DISABLE_MESSAGE ${DISABLE_MESSAGE}
" Reason: ${CAMITK_TESTS_REQUIREMENT_REASON}\n")
186 set(DISABLE_MESSAGE ${DISABLE_MESSAGE}
" Requirement statement unmet: ${CAMITK_TESTS_REQUIREMENT_REQUIRES}")
187 message(STATUS ${DISABLE_MESSAGE})
189 message(STATUS
"Test requirement \"${CAMITK_TESTS_REQUIREMENT_REQUIRES}\": Passed\n Enabled tests: ${CAMITK_TESTS_REQUIREMENT_TESTS_STRING}")
cmake modules macros camitk test endif() add_custom_target(camitk-ce-iwyu COMMAND $
Definition: CamiTKIncludeWhatYouUse.h:37
iwyu out CACHE PATH Output filename for include what you use set(CMAKE_CXX_INCLUDE_WHAT_YOU_USE ${IWYU_EXECUTABLE}) if(NOT EXISTS $
Definition: CamiTKIncludeWhatYouUse.h:22
camitk_tests_requirement()
camitk_tests_requirement is a macro to disable one or more tests.
Definition: CamiTKTestsRequirement.h:76
vtkSmartPointer< vtkTransform > transform
Definition: RendererWidget.cpp:416