Add CMakeLists.txt#122
Conversation
indutny
left a comment
There was a problem hiding this comment.
LGTM with a question. Thanks for submitting it!
| @@ -0,0 +1,53 @@ | |||
| cmake_minimum_required(VERSION 3.5.1) | |||
| cmake_policy(SET CMP0069 NEW) | |||
There was a problem hiding this comment.
Could you elaborate on why this policy is used here?
There was a problem hiding this comment.
We don't really need this, it could go but is a nice to have. This policy allows to use the cmake variable to enable Link Time Optimization easily, by passing the -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON option. Those options help the compiler generated better code (usually smarter inlining) when there are multiple compilation units, so here potentially the http.c and api.c and llhttp.c files would produce better code when optimized in an 'inter-proceduraled' way.
https://www.llvm.org/docs/LinkTimeOptimization.html
https://cmake.org/cmake/help/latest/policy/CMP0069.html
There was a problem hiding this comment.
Ah, so when this policy is present - cmake will detect the compiler support and use -flto if it might?
There was a problem hiding this comment.
Yes, if -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON is passed on.
|
FYI I added a gist with 2 files showing how to use this. |
|
Thanks a lot! Merged. |
PR-URL: nodejs/llhttp#122 Reviewed-By: Fedor Indutny <[email protected]>
This will make it easier for cmake users (which is a bunch of C++ users those days) to use llhttp.
This is an example cmake snippet to bring in your library in a CMake project.