How to do it

We start with a familiar CMakeLists.txt structure, with some additional steps, as follows:

  1. We prepare the now familiar infrastructure:
# set minimum cmake versioncmake_minimum_required(VERSION 3.5 FATAL_ERROR)# project nameproject(recipe-10 LANGUAGES NONE)# detect pythonfind_package(PythonInterp REQUIRED)# define testsenable_testing()
  1. Then, we define the four test steps and bind them with a fixture:
add_test(  NAME setup  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/setup.py  )set_tests_properties(  setup  PROPERTIES    FIXTURES_SETUP my-fixture  )add_test(  NAME feature-a  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/feature-a.py  )add_test(  NAME feature-b COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/feature-b.py ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.