11cmake_minimum_required (VERSION 3.5...3.10 )
22project (libfds)
33
4+ # Check if libfds is the main project or it is a part of another project
5+ # (e.g. included via add_subdirectory() or FetchContent)
6+ if (CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR )
7+ set (LIBFDS_TOP_LEVEL ON )
8+ else ()
9+ set (LIBFDS_TOP_LEVEL OFF )
10+ endif ()
11+
412# Description of the project
513set (PROJECT_DESCRIPTION
614 "Flow Data Storage library is set of tools for processing flow records."
@@ -25,7 +33,7 @@ include(CheckCCompilerFlag)
2533include (CheckCXXCompilerFlag )
2634
2735# Include custom FindXXX modules
28- list (APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR } /CMakeModules" )
36+ list (INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR } /CMakeModules" )
2937
3038CHECK_C_COMPILER_FLAG (-std=gnu11 COMPILER_SUPPORT_GNU11 )
3139if (NOT COMPILER_SUPPORT_GNU11)
@@ -50,13 +58,25 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
5058 "Debug" "Release" "MinSizeRel" "RelWithDebInfo" )
5159endif ()
5260
53- option (ENABLE_DOC "Enable documentation building" OFF )
54- option (ENABLE_TESTS "Build Unit tests (make test)" OFF )
55- option (ENABLE_TESTS_INTERNAL "Build Unit tests that don't use public API" OFF )
56- option (ENABLE_TESTS_VALGRIND "Build Unit tests with Valgrind Memcheck" OFF )
57- option (ENABLE_TESTS_COVERAGE "Enable support for code coverage" OFF )
58- option (PACKAGE_BUILDER_RPM "Enable RPM package builder (make rpm)" OFF )
59- option (PACKAGE_BUILDER_DEB "Enable DEB package builder (make deb)" OFF )
61+ if (LIBFDS_TOP_LEVEL)
62+ option (ENABLE_DOC "Enable documentation building" OFF )
63+ option (ENABLE_TESTS "Build Unit tests (make test)" OFF )
64+ option (ENABLE_TESTS_INTERNAL "Build Unit tests that don't use public API" OFF )
65+ option (ENABLE_TESTS_VALGRIND "Build Unit tests with Valgrind Memcheck" OFF )
66+ option (ENABLE_TESTS_COVERAGE "Enable support for code coverage" OFF )
67+ option (PACKAGE_BUILDER_RPM "Enable RPM package builder (make rpm)" OFF )
68+ option (PACKAGE_BUILDER_DEB "Enable DEB package builder (make deb)" OFF )
69+ else ()
70+ # Options of the same name in the parent project must not affect libfds.
71+ # Documentation, tests and packages are available only in standalone builds.
72+ set (ENABLE_DOC OFF )
73+ set (ENABLE_TESTS OFF )
74+ set (ENABLE_TESTS_INTERNAL OFF )
75+ set (ENABLE_TESTS_VALGRIND OFF )
76+ set (ENABLE_TESTS_COVERAGE OFF )
77+ set (PACKAGE_BUILDER_RPM OFF )
78+ set (PACKAGE_BUILDER_DEB OFF )
79+ endif ()
6080option (USE_SYSTEM_LZ4 "Use system-installed LZ4 library" ON )
6181option (USE_SYSTEM_ZSTD "Use system-installed ZSTD library" ON )
6282
0 commit comments