Skip to content

Commit 85fa038

Browse files
committed
Emulate GNU Autotools make check
- Fixes #103 - Provide `check` target that will build tests - Tests are no longer included in the `all` target - `make check` will build in parallel: the static and dynamic library, all tests and run them with `ctest` - `make` will build the library and documentation if enabled
1 parent 48f0e05 commit 85fa038

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
matrix:
1212
# CMake build with unit tests, no documentation, no coverage analysis
1313
# Allow to fail for now until tests are fixed
14-
- BUILD_SCRIPT="mkdir cmake-build && cd cmake-build && cmake -DSKIP_DOC_GEN:BOOL=TRUE -DENABLE_UNICODE:BOOL=TRUE .. && make -j 4 && make test"
14+
- BUILD_SCRIPT="mkdir cmake-build && cd cmake-build && cmake -DSKIP_DOC_GEN:BOOL=TRUE -DENABLE_UNICODE:BOOL=TRUE .. && make -j 4 check"
1515
SPECIFIC_DEPENDS="cmake nodejs"
1616
JLINT="yes"
1717
DOCS="no"

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,9 @@ set ( ENABLE_TESTS TRUE CACHE BOOL
197197
if ( ENABLE_TESTS )
198198
enable_testing()
199199

200+
# emulate GNU Autotools `make check`
201+
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
202+
200203
find_program ( JSONLINT jsonlint )
201204
find_program ( DIFF diff )
202205
file ( COPY "${CMAKE_SOURCE_DIR}/files"
@@ -235,8 +238,9 @@ if ( ENABLE_TESTS )
235238
set ( UNIT_TESTS '' )
236239
foreach ( UNIT_TEST ${JF_TEST_SRCS} )
237240
get_filename_component ( TEST ${UNIT_TEST} NAME_WE )
238-
add_executable ( ${TEST} ${UNIT_TEST} )
241+
add_executable ( ${TEST} EXCLUDE_FROM_ALL ${UNIT_TEST} )
239242
target_link_libraries ( ${TEST} ${LIB_NAME} )
243+
add_dependencies ( check ${TEST} )
240244
set_target_properties ( ${TEST}
241245
PROPERTIES
242246
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )

0 commit comments

Comments
 (0)