Using cmake with nginx

Maxim Dounin mdounin at mdounin.ru
Mon Dec 5 23:02:09 UTC 2022


Hello!

On Mon, Dec 05, 2022 at 03:16:50AM +0300, Dmitry Petrov wrote:

> >So, the issues you are talking about is the fact that nginx won't
> magically find out which header files you are using, but instead
> requires you to list them in the ngx_module_deps variable when
> calling the auto/module in the module config script, correct?
> 
> That's not magic. This is what make + gcc/clang/icc can do on *nix. The
> general pattern is simple:
> -include $dep
> $obj $dep: $src
>     $(CC) ... -MMD -MP -MT $obj -MT $dep ...
> This would make the compiler generate a dependency file together with an
> object file and make would include/update it when needed.
> I'm not aware if nginx supports compilers other than gcc/clang, but this
> trick would work for said compilers. icc mimics gcc on Linux, so generally
> it will work there too . I'm attaching objs/ngx_modules.d being
> automatically generated by this approach.

nginx supports a wide range of C compilers, not just gcc/clang, 
including ones very different form gcc, such as MSVC on Windows 
(used in practice to build nginx binaries for Windows) or Sun C on 
Solaris.  Further, nginx is expected to be buildable with any 
POSIX-complaint C compiler, which is assumed by default.

Summing the above, the gcc/clang feature in question certainly 
won't make it possible to bypass listing header files manually.

It might be a way to improve rebuild times on systems using 
gcc/clang, though I suspect it might not worth the effort (or 
might even increase build times in typical case due to additional 
work being done).  Especially given that building nginx with 
default modules on a cheap i7-4770 server takes less than 5 
seconds of real time, and less than 15 seconds on an old i5-8210Y 
laptop.

-- 
Maxim Dounin
http://mdounin.ru/



More information about the nginx-devel mailing list