aiq
aiq

Reputation: 51

(How) can I generate with cmake a header file that include header files?

i have a project that has several header files. I want now to generate a header file that includes all project header files.

For example we have the following headers:

Now I want to generate a header file that includes all header files and looks approximately like that:

#include "a.h"
#include "b.h"
#include "c.h"
#include "ext/d.h"

Thanks for any kind of help.

Upvotes: 1

Views: 602

Answers (1)

Peter Petrik
Peter Petrik

Reputation: 10195

file(GLOB_RECURSE header_files "include/*.h")
foreach(f ${header_files})
  message("processing ${f}")
  file(RELATIVE_PATH fr "${CMAKE_CURRENT_SOURCE_DIR}/include" ${f})
  list(APPEND incls "#include \"${fr}\"\n")
endforeach()
file(WRITE mylibheader.h ${incls})

Description:

Upvotes: 3

Related Questions