My company keeps certain header files and libraries in non-standard (but not changing) location.
I'm trying to add the header path to the build. If I define the environment variable CPPFLAGS, I can add header search paths, and the headers are found. But all attempts to set the search path from within configure.ac or src/Makefile.am have failed.
In src/Makefile.am I have tried
AM_CPPFLAGS = -I/path/to/headers
But the headers are not found. I've tried to set CPPFLAGS in configure.ac and Makefile.am, and that doesn't work. I've tried
AC_SUBST(CPPFLAGS, ['-I/path/to/headers'])
with and without the single quotes, also no luck
I've tried in src/Makefile.am
main_CPPFLAGS = -I/path/to/headers
I'd rather not have to set an environment variable. That would require an extra instruction and extra step to the build sequence (and documentation). Any idea what I am missing?
Addendum
I neglected to mention that I'm cross-compiling on MacOS for an ARM host (not iOS).
Here's a sanitized version of src/Makefile.am. It's got several of the possibilities in it at the moment. None of them get the -I flag to the compiler. Setting the CPPFLAGS environment variable does get the -I flag to the compiler.
SUBDIRS = .
bin_PROGRAMS = main
main_SOURCES = first.h second.h main.cpp
main_LDADD = -lone -ltwo
main_CPPFLAGS = -I/path/to/headers
AM_CPPFLAGS = -I/path/to/headers
INCLUDES = -I/path/to/headers
AM_CPPFLAGS = -I/path/to/headers
is correct, it should pass that -I option to your compiler. The only reason I can think of that it doesn't is when either your automake version is very old, or because something with the cross compiling causes it to behave different from what I'm used to (I didn't use autotools for cross compiling yet). – Carlo Wood