[CMake] Check the existence of a header / ability to compile source file

Attila Krasznahorkay attila.krasznahorkay at gmail.com
Tue Apr 5 04:32:35 EDT 2016


Dear All,

I'm stumped on the following, seemingly simple issue.

I need to figure out in my configuration whether a given header file will be available when I'll try to build my library, or not. So that I could set a particular definition for the compiler according to whether the file is available or not.

The complication is that I use generator expressions very heavily in setting up the compilation flags of the library in question. So at configuration time I don't even know yet all the include directories that I should be looking in to find that header. That only becomes known after the generation step.

But as far as I can tell, check_include_files(...) can only run during the configuration step. So relying on generator expressions in setting up its include directories is not an option.

Is there any other possibility of making such a check, during the generation step? Or is there some other mechanism that I could use to do this check during the build itself? (After all, it could be a solution to generate a configuration header with this information during the build itself...)

Cheers,
          Attila


More information about the CMake mailing list