How to do it

The following is a detailed breakdown of the contents of our CMakeLists.txt:

  1. We start out with a relatively compact CMakeLists.txt, which defines the six tests:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)# project nameproject(recipe-09 LANGUAGES NONE)# detect pythonfind_package(PythonInterp REQUIRED)# define testsenable_testing()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  )add_test(  NAME feature-c  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/feature-c.py  )add_test(  NAME feature-d COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/feature-d.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.