How to structure files

We will collect functions that generate these files in src/autogenerate.cmake, include this module, and call these functions in src/CMakeLists.txt before defining the executable target:

# generate config.h, pathdef.c, and osdef.hinclude(autogenerate.cmake)generate_config_h()generate_pathdef_c()generate_osdef_h()add_executable(vim  main.c  )# ...

The included src/autogenerate.cmake contains other includes for functionality that we will require to probe header files, functions, and libraries, as well as the three functions:

include(CheckTypeSize)include(CheckFunctionExists)include(CheckIncludeFiles)include(CheckLibraryExists)include(CheckCSourceCompiles)function(generate_config_h)  # ... to be writtenendfunction()function(generate_pathdef_c) ...

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.