Skip to content

Commit 80047ed

Browse files
committed
Fixes #26 wherein CMake config fails if no jsonlint
- This bug has been present for quite some time - Thanks to @bruceravel for bringing it to my attention
1 parent 1f284f6 commit 80047ed

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

CMakeLists.txt

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,65 +185,78 @@ if ( JSONLINT )
185185
add_test ( NAME validate-test2
186186
WORKING_DIRECTORY ${DATA_DIR}
187187
COMMAND ${JSONLINT} test2.json )
188+
set ( OPTIONAL_TESTS2 ${OPTIONAL_TESTS2} validate-test2 )
188189
add_test ( NAME validate-test4
189190
WORKING_DIRECTORY ${DATA_DIR}
190191
COMMAND ${JSONLINT} test4.json )
192+
set ( OPTIONAL_TESTS4 ${OPTIONAL_TESTS4} validate-test4 )
191193
endif ( JSONLINT )
192194
# Check output for differences
193195
if ( DIFF )
194196
add_test ( NAME test2-regression
195197
WORKING_DIRECTORY ${DATA_DIR}
196198
COMMAND ${DIFF} -q test2.json ${CMAKE_SOURCE_DIR}/files/test2.json )
199+
set ( OPTIONAL_TESTS2 ${OPTIONAL_TESTS2} test2-regression )
197200
add_test ( NAME test4-regression
198201
WORKING_DIRECTORY ${DATA_DIR}
199202
COMMAND ${DIFF} -q test4.json ${CMAKE_SOURCE_DIR}/files/test4.json )
203+
set ( OPTIONAL_TESTS4 ${OPTIONAL_TESTS4} test4-regression )
200204
else ( DIFF )
201205
message ( WARNING
202206
"For full test coverage diff, or a similar tool must be present on your system" )
203207
endif ( DIFF )
204-
set_tests_properties ( validate-test2 test2-regression
205-
PROPERTIES
206-
DEPENDS test-${CMAKE_PROJECT_NAME}
207-
REQUIRED_FILES "${DATA_DIR}/test2.json"
208-
RESOURCE_LOCK "${DATA_DIR}/test2.json" )
209-
set_tests_properties ( validate-test4 test4-regression
210-
PROPERTIES
211-
DEPENDS test-${CMAKE_PROJECT_NAME}
212-
REQUIRED_FILES "${DATA_DIR}/test4.json"
213-
RESOURCE_LOCK "${DATA_DIR}/test4.json" )
214-
208+
if ( DIFF OR JSONLINT )
209+
set_tests_properties ( ${OPTIONAL_TESTS2}
210+
PROPERTIES
211+
DEPENDS test-${CMAKE_PROJECT_NAME}
212+
REQUIRED_FILES "${DATA_DIR}/test2.json"
213+
RESOURCE_LOCK "${DATA_DIR}/test2.json" )
214+
set_tests_properties ( ${OPTIONAL_TESTS4}
215+
PROPERTIES
216+
DEPENDS test-${CMAKE_PROJECT_NAME}
217+
REQUIRED_FILES "${DATA_DIR}/test4.json"
218+
RESOURCE_LOCK "${DATA_DIR}/test4.json" )
219+
endif ( DIFF OR JSONLINT )
215220
# Static lib
216221
add_test ( NAME test-${CMAKE_PROJECT_NAME}-static
217222
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
218223
COMMAND test-${CMAKE_PROJECT_NAME}-static )
224+
unset ( OPTIONAL_TESTS2 )
225+
unset ( OPTIONAL_TESTS4 )
219226
# Validate output
220227
if ( JSONLINT )
221228
add_test ( NAME validate-test2-static
222229
WORKING_DIRECTORY ${DATA_DIR}
223230
COMMAND ${JSONLINT} test2.json )
231+
set ( OPTIONAL_TESTS2 ${OPTIONAL_TESTS2} validate-test2-static )
224232
add_test ( NAME validate-test4-static
225233
WORKING_DIRECTORY ${DATA_DIR}
226234
COMMAND ${JSONLINT} test4.json )
235+
set ( OPTIONAL_TESTS4 ${OPTIONAL_TESTS4} validate-test4-static )
227236
endif ( JSONLINT )
228237
# Check output for differences
229238
if ( DIFF )
230239
add_test ( NAME test2-regression-static
231240
WORKING_DIRECTORY ${DATA_DIR}
232241
COMMAND ${DIFF} -q test2.json ${CMAKE_SOURCE_DIR}/files/test2.json )
242+
set ( OPTIONAL_TESTS2 ${OPTIONAL_TESTS2} test2-regression-static )
233243
add_test ( NAME test4-regression-static
234244
WORKING_DIRECTORY ${DATA_DIR}
235245
COMMAND ${DIFF} -q test4.json ${CMAKE_SOURCE_DIR}/files/test4.json )
246+
set ( OPTIONAL_TESTS4 ${OPTIONAL_TESTS4} test4-regression-static )
236247
endif ( DIFF )
237-
set_tests_properties ( validate-test2-static test2-regression-static
248+
if ( JSONLINT OR DIFF )
249+
set_tests_properties ( ${OPTIONAL_TESTS2}
238250
PROPERTIES
239251
DEPENDS test-${CMAKE_PROJECT_NAME}-static
240252
REQUIRED_FILES "${DATA_DIR}/test2.json"
241253
RESOURCE_LOCK "${DATA_DIR}/test2.json" )
242-
set_tests_properties ( validate-test4-static test4-regression-static
254+
set_tests_properties ( ${OPTIONAL_TESTS4}
243255
PROPERTIES
244256
DEPENDS test-${CMAKE_PROJECT_NAME}-static
245257
REQUIRED_FILES "${DATA_DIR}/test4.json"
246258
RESOURCE_LOCK "${DATA_DIR}/test4.json" )
259+
endif ( JSONLINT OR DIFF )
247260

248261
if ( JSONLINT )
249262
set_tests_properties ( test-${CMAKE_PROJECT_NAME} test-${CMAKE_PROJECT_NAME}-static

0 commit comments

Comments
 (0)