Skip to content

Commit

Permalink
build: replace CMARK_TESTS with BUILD_TESTING
Browse files Browse the repository at this point in the history
`BUILD_TESTING` is the CMake sanctioned option for the control of tests
(c.f. https://cmake.org/cmake/help/latest/module/CTest.html).  Use the
standard option to control the build of test targets.
  • Loading branch information
compnerd committed Dec 21, 2023
1 parent cd960cc commit c86f281
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "Do not build in-source.\nPlease remove CMakeCache.txt and the CMakeFiles/ directory.\nThen: mkdir build ; cd build ; cmake .. ; make")
endif()

option(CMARK_TESTS "Build cmark tests and enable testing" ON)
option(CMARK_STATIC "Build static libcmark library" ON)
option(CMARK_SHARED "Build shared libcmark library" ON)
option(CMARK_LIB_FUZZER "Build libFuzzer fuzzing harness" OFF)
Expand Down Expand Up @@ -60,16 +59,18 @@ function(cmark_add_compile_options target)
endfunction()

add_subdirectory(src)
if(CMARK_TESTS AND (CMARK_SHARED OR CMARK_STATIC))
add_subdirectory(api_test)
if(BUILD_TESTING)
endif()
# TODO(compnerd) should this be enabled for MinGW, which sets CMAKE_SYSTEM_NAME
# to Windows, but defines `MINGW`.
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
add_subdirectory(man)
endif()
if(CMARK_TESTS)
if(BUILD_TESTING)
enable_testing()
if(CMARK_SHARED OR CMARK_STATIC)
add_subdirectory(api_test)
endif()
add_subdirectory(test testdir)
endif()

Expand Down
3 changes: 3 additions & 0 deletions api_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ if(CMARK_SHARED)
else()
target_link_libraries(api_test cmark_static)
endif()

add_test(NAME api_test COMMAND api_test)

8 changes: 1 addition & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ else()
IMPORTED_LOCATION ${PYTHON_EXECUTABLE})
endif()

if (CMARK_SHARED OR CMARK_STATIC)
add_test(NAME api_test COMMAND api_test)
endif()

if (WIN32)
file(TO_NATIVE_PATH ${CMAKE_BINARY_DIR}/src WIN_DLL_DIR)
set(NEWPATH "${WIN_DLL_DIR};$ENV{PATH}")
Expand Down Expand Up @@ -82,9 +78,7 @@ IF (Python_Interpreter_FOUND)

ELSE(Python_Interpreter_FOUND)

message("\n*** A python 3 interpreter is required to run the spec tests.\n")
add_test(skipping_spectests
echo "Skipping spec tests, because no python 3 interpreter is available.")
message(WARNING "A Python 3 Interpreter is required to run the spec tests")

ENDIF(Python_Interpreter_FOUND)

0 comments on commit c86f281

Please sign in to comment.