summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt75
1 files changed, 38 insertions, 37 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad7609d..794fc34 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,8 @@ else ()
message (WARNING "Compilation by ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} isn't tested")
endif ()
+include(cmake/options.cmake)
+
find_package(Threads REQUIRED) # POSIX Threads
find_path(PCAP_ROOT_DIR
@@ -31,38 +33,40 @@ endif ()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pedantic -Wall -Werror -Wextra -fPIC -fvisibility=hidden")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-dynamic")
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${INCLUDE_COVERAGE_INFO}")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage -O0")
endif ()
# Read version string from file
-file(STRINGS VERSION NST_VERSION)
+file (STRINGS VERSION NST_VERSION)
string (REPLACE "." ";" VERSION_LIST ${NST_VERSION})
-list(GET VERSION_LIST 0 NST_V_MAJOR)
-list(GET VERSION_LIST 1 NST_V_MINOR)
-list(GET VERSION_LIST 2 NST_V_PATCH)
+list (GET VERSION_LIST 0 NST_V_MAJOR)
+list (GET VERSION_LIST 1 NST_V_MINOR)
+list (GET VERSION_LIST 2 NST_V_PATCH)
set (NST_VERSION_FULL "${PROJECT_NAME} ${NST_VERSION} (${CMAKE_BUILD_TYPE})")
-string(TIMESTAMP COMPILATION_DATE "%Y-%m-%d")
+string (TIMESTAMP COMPILATION_DATE "%Y-%m-%d")
include_directories (src)
+
+# nfstrace executable ==========================================================
file (GLOB_RECURSE SRCS "src/*.cpp")
-set (LIBS ${CMAKE_DL_LIBS} # libdl with dlopen()
- ${CMAKE_THREAD_LIBS_INIT} # libpthread
- ${PCAP_LIBRARY} # libpcap
- )
+set (LIBS ${CMAKE_DL_LIBS} # libdl with dlopen()
+ ${CMAKE_THREAD_LIBS_INIT} # libpthread
+ ${PCAP_LIBRARY} # libpcap
+ )
-configure_file(docs/nfstrace.8.in ${PROJECT_SOURCE_DIR}/docs/nfstrace.8)
-configure_file(src/api/plugin_api.h.in ${PROJECT_SOURCE_DIR}/src/api/plugin_api.h)
-configure_file(src/controller/build_info.h.in ${PROJECT_SOURCE_DIR}/src/controller/build_info.h)
+configure_file (docs/nfstrace.8.in ${PROJECT_SOURCE_DIR}/docs/nfstrace.8)
+configure_file (src/api/plugin_api.h.in ${PROJECT_SOURCE_DIR}/src/api/plugin_api.h)
+configure_file (src/controller/build_info.h.in ${PROJECT_SOURCE_DIR}/src/controller/build_info.h)
-add_executable (${PROJECT_NAME} ${SRCS})
+add_executable (${PROJECT_NAME} ${SRCS})
target_link_libraries (${PROJECT_NAME} ${LIBS})
-# build watch analyzer==========================================================
-add_subdirectory(analyzers)
+# analyzer plugins =============================================================
+add_subdirectory (analyzers)
# testing ======================================================================
enable_testing ()
@@ -79,39 +83,36 @@ install (FILES ${headers} DESTINATION include/nfstrace/api)
install (FILES ${PROJECT_SOURCE_DIR}/docs/nfstrace.8 DESTINATION share/man/man8)
# build packages ===============================================================
-set (CPACK_PACKAGE_VERSION ${NST_VERSION})
-set (CPACK_PACKAGING_INSTALL_PREFIX "/usr")
-set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "NFS tracing/monitoring/capturing/statistic tool")
-set (CPACK_PACKAGE_CONTACT "Nfstrace developers <nfstrace@epam.com>")
-
-set (CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
-set (CPACK_RPM_PACKAGE_LICENSE "GPLv2")
-set (CPACK_RPM_PACKAGE_VENDOR "EPAM Systems")
-set (CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/share/man /usr/share/man/man8)
-set (CPACK_RPM_PACKAGE_REQUIRES "libpcap >= 1.3.0-1")
-
-set (CPACK_DEBIAN_PACKAGE_SECTION "admin")
-set (CPACK_DEBIAN_PACKAGE_DEPENDS "libpcap0.8 (>=1.3.0-1)")
-
-include (CPack)
+include ("cmake/packaging.cmake")
# coverage =====================================================================
-if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
+if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${INCLUDE_COVERAGE_INFO}")
find_program (GCOVR_PATH gcovr)
if (GCOVR_PATH)
add_custom_target (coverage
COMMAND ${GCOVR_PATH} --xml -r \"${CMAKE_SOURCE_DIR}\" --object-directory \"${CMAKE_BINARY_DIR}\" -o coverage.xml 2>&1 >/dev/null
- WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
+ add_custom_target (coverage-html
+ COMMAND ${GCOVR_PATH} --html --html-details -r \"${CMAKE_SOURCE_DIR}\" --object-directory \"${CMAKE_BINARY_DIR}\" -o coverage.html 2>&1 >/dev/null
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
+ else ()
+ message (WARNING "'gcovr' executable not found - coverage report is not available.")
endif ()
endif ()
# documentation ================================================================
+add_subdirectory (docs)
-find_program (DOXYGEN_PATH doxygen)
+# code style ===================================================================
+find_program (ASTYLE_PATH astyle)
-if (DOXYGEN_PATH)
- add_custom_target (documentation
- COMMAND ${DOXYGEN_PATH} Doxyfile
+if (ASTYLE_PATH)
+ add_custom_target (codestyle
+ COMMAND find analyzers src tests -name '*.h' -o -name '*.cpp' |
+ xargs ${ASTYLE_PATH} --options=${CMAKE_SOURCE_DIR}/astyle.cfg
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif ()
+
+# Runtime analysis reports
+include ("cmake/valgrind.cmake")