osquery-1/third-party
Alessandro Gario 6481b34e23
Refactor third-party libraries to build from source on Linux (#5706)
Add a way to compile third-party libraries from source instead of downloading prebuilt ones.
Each library source code is downloaded with git into a submodule at configure time,
in response to the find_package(library_name) CMake call,
except for OpenSSL where the official source archive is used.
Each submodule is attached to a release tag on its own upstream repository.
All the libraries are built using CMake directly, except for OpenSSL which uses a formula system,
which permits to build libraries with a separate build system
when there's no easy way to integrate it directly with CMake.

This new dependency system determines which library is fetched from where using the concept of "layers".
Currently we have three of them: source, formula, facebook,
where the last layer represents the pre-built libraries.
The provided order will be used when looking for libraries.

A system to patch submodule source code has been added and it's currently used with googletest, libudev and util-linux.
Patches should be put under libraries/cmake/source/<library name>/patches/<submodule>,
where <submodule> is often one and is "src", but in other cases, like AWS,
there are multiple with a more specific name.
If for whatever reason the submodule cloning or the patching fails,
the submodule has to be unregistered and its folder should be cleared.
This should be achievable with "git submodule deinit -f <submodule path>"

Following some other changes on existing functionality:

- Changed the CMake variable BUILD_TESTING to OSQUERY_BUILD_TESTS
  to avoid enabling tests on third party libraries.
  Due to an issue with glog the BUILD_TESTING variable
  will be always forced to OFF.
- Moved compiler and linker flags to their own file cmake/flags.cmake
- Moved all the third-party CMakeLists.txt used for pre-built libraries under libraries/cmake/facebook
- Added the --exclude-folders option to tools/format-check.py and tools/git-clang-format.py,
  so that it's possible to ignore any third party library source code.
- The format and format_check target use the new --exclude-folders option
  to exclude libraries/cmake/source from formatting.
- The test and osquery binaries are properly compiled with PIE (osquery/osquery#5611)

Co-authored-by: Stefano Bonicatti <stefano.bonicatti@gmail.com>
Co-authored-by: Teddy Reed <teddy@casualhacking.io>
2019-08-30 16:25:19 +02:00
..
augeas Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
aws-sdk-cpp Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
berkeley-db Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
boost Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
bzip2 Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
gflags Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
glibc Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
glog Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
googletest Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
jinja2 Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libarchive Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libaudit Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libcryptsetup Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libdevmapper Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libdpkg Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libelfin Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libgcrypt Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libgpg-error Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libiptables Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libmagic Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
librdkafka Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
librpm Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libudev Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
libxml2 Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
linenoise-ng Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
lldpd Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
lzma Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
markupsafe Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
openssl Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
popt Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
rapidjson Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
rocksdb Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
sleuthkit Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
smartmontools Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
sqlite Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
ssdeep-cpp Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
thrift Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
util-linux Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
yara Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
zlib Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00
zstd Refactor third-party libraries to build from source on Linux (#5706) 2019-08-30 16:25:19 +02:00