forked from pmem/libpmemobj-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
283 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,20 +38,26 @@ set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}) | |
|
||
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) | ||
|
||
# Treat CMAKE_CXX_STANDARD as a requirement | ||
set(CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
include(FindPerl) | ||
include(FindThreads) | ||
include(CMakeDependentOption) | ||
include(CheckCXXSourceCompiles) | ||
include(CheckCXXCompilerFlag) | ||
include(GNUInstallDirs) | ||
include(${CMAKE_SOURCE_DIR}/cmake/functions.cmake) | ||
|
||
option(BUILD_EXAMPLES "build examples" ON) | ||
|
||
option(BUILD_TESTS "build tests" ON) | ||
|
||
option(BUILD_DOC "build documentation" ON) | ||
|
||
option(TRACE_TESTS | ||
"more verbose test outputs" OFF) | ||
|
||
option(COVERAGE "run coverage test" OFF) | ||
option(DEVELOPER_MODE "enable developer checks" OFF) | ||
option(TRACE_TESTS "more verbose test outputs" OFF) | ||
option(USE_ASAN "enable AddressSanitizer (debugging)" OFF) | ||
option(USE_UBSAN "enable UndefinedBehaviorSanitizer (debugging)" OFF) | ||
|
||
set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test | ||
CACHE STRING "working directory for tests") | ||
|
@@ -79,58 +85,37 @@ else() | |
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
endif() | ||
|
||
include(FindPerl) | ||
find_package(PkgConfig QUIET) | ||
|
||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) | ||
|
||
if(NOT PERL_FOUND) | ||
message(FATAL_ERROR "Perl not found") | ||
endif() | ||
if (PERL_VERSION_STRING VERSION_LESS 5.16) | ||
message(FATAL_ERROR "Too old Perl (<5.16)") | ||
endif() | ||
|
||
include(CheckCXXCompilerFlag) | ||
include(GNUInstallDirs) | ||
find_package(PkgConfig QUIET) | ||
|
||
include_directories(include) | ||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(PMEMOBJ REQUIRED libpmemobj>=1.4) | ||
else() | ||
find_package(PMEMOBJ REQUIRED 1.4) | ||
endif() | ||
|
||
# Treat CMAKE_CXX_STANDARD as a requirement | ||
set(CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_STANDARD 11) | ||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(VALGRIND QUIET valgrind) | ||
else() | ||
find_package(VALGRIND QUIET) | ||
endif() | ||
|
||
function(join SEP OUT VALUES) | ||
string(REPLACE ";" "${SEP}" JOIN_TMP "${VALUES}") | ||
set(${OUT} "${JOIN_TMP}" PARENT_SCOPE) | ||
endfunction() | ||
|
||
# prepends prefix to list of strings | ||
function(prepend var prefix) | ||
set(listVar "") | ||
foreach(f ${ARGN}) | ||
list(APPEND listVar "${prefix}/${f}") | ||
endforeach(f) | ||
set(${var} "${listVar}" PARENT_SCOPE) | ||
endfunction() | ||
|
||
# Checks whether flag is supported by current C++ compiler and appends | ||
# it to the relevant cmake variable. | ||
# 1st argument is a flag | ||
# 2nd (optional) argument is a build type (debug, release) | ||
macro(add_flag flag) | ||
string(REPLACE - _ flag2 ${flag}) | ||
string(REPLACE " " _ flag2 ${flag2}) | ||
string(REPLACE = "_" flag2 ${flag2}) | ||
set(check_name "CXX_HAS_${flag2}") | ||
|
||
check_cxx_compiler_flag(${flag} ${check_name}) | ||
|
||
if (${${check_name}}) | ||
if (${ARGC} EQUAL 1) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") | ||
else() | ||
set(CMAKE_CXX_FLAGS_${ARGV1} "${CMAKE_CXX_FLAGS_${ARGV1}} ${flag}") | ||
endif() | ||
endif() | ||
endmacro() | ||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(LIBUNWIND QUIET libunwind) | ||
else() | ||
find_package(LIBUNWIND QUIET) | ||
endif() | ||
if(NOT LIBUNWIND_FOUND) | ||
message(WARNING "libunwind not found. Stack traces from tests will not be reliable") | ||
endif() | ||
|
||
add_flag(-Wall) | ||
add_flag(-Wpointer-arith) | ||
|
@@ -147,24 +132,6 @@ add_flag(-DDEBUG DEBUG) | |
|
||
add_flag("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" RELEASE) | ||
|
||
option(USE_ASAN "enable AddressSanitizer (debugging)" OFF) | ||
option(USE_UBSAN "enable UndefinedBehaviorSanitizer (debugging)" OFF) | ||
|
||
macro(add_sanitizer_flag flag) | ||
set(SAVED_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) | ||
set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES} -fsanitize=${flag}") | ||
|
||
check_cxx_compiler_flag("-fsanitize=${flag}" CXX_HAS_ASAN_UBSAN) | ||
if(CXX_HAS_ASAN_UBSAN) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${flag}") | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${flag}") | ||
else() | ||
message("${flag} sanitizer not supported") | ||
endif() | ||
|
||
set(CMAKE_REQUIRED_LIBRARIES ${SAVED_CMAKE_REQUIRED_LIBRARIES}) | ||
endmacro() | ||
|
||
if(USE_ASAN) | ||
add_sanitizer_flag(address) | ||
endif() | ||
|
@@ -178,67 +145,6 @@ endif() | |
|
||
add_executable(check_license EXCLUDE_FROM_ALL utils/check_license/check-license.c) | ||
|
||
# Generates cppstyle-$name and cppformat-$name targets and attaches them | ||
# as dependencies of global "cppformat" target. | ||
# cppstyle-$name target verifies C++ style of files in current source dir. | ||
# cppformat-$name target reformats files in current source dir. | ||
# If more arguments are used, then they are used as files to be checked | ||
# instead. | ||
# ${name} must be unique. | ||
function(add_cppstyle name) | ||
if(NOT CLANG_FORMAT) | ||
return() | ||
endif() | ||
|
||
if(${ARGC} EQUAL 1) | ||
add_custom_target(cppstyle-${name} | ||
COMMAND ${PERL_EXECUTABLE} | ||
${CMAKE_SOURCE_DIR}/utils/cppstyle | ||
${CLANG_FORMAT} | ||
check | ||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/*.hpp | ||
) | ||
add_custom_target(cppformat-${name} | ||
COMMAND ${PERL_EXECUTABLE} | ||
${CMAKE_SOURCE_DIR}/utils/cppstyle | ||
${CLANG_FORMAT} | ||
format | ||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp | ||
${CMAKE_CURRENT_SOURCE_DIR}/*.hpp | ||
) | ||
else() | ||
add_custom_target(cppstyle-${name} | ||
COMMAND ${PERL_EXECUTABLE} | ||
${CMAKE_SOURCE_DIR}/utils/cppstyle | ||
${CLANG_FORMAT} | ||
check | ||
${ARGN} | ||
) | ||
add_custom_target(cppformat-${name} | ||
COMMAND ${PERL_EXECUTABLE} | ||
${CMAKE_SOURCE_DIR}/utils/cppstyle | ||
${CLANG_FORMAT} | ||
format | ||
${ARGN} | ||
) | ||
endif() | ||
|
||
add_dependencies(cppstyle cppstyle-${name}) | ||
add_dependencies(cppformat cppformat-${name}) | ||
endfunction() | ||
|
||
# Generates check-whitespace-$name target and attaches it as a dependency | ||
# of global "check-whitespace" target. | ||
# ${name} must be unique. | ||
function(add_check_whitespace name) | ||
add_custom_target(check-whitespace-${name} | ||
COMMAND ${PERL_EXECUTABLE} | ||
${CMAKE_SOURCE_DIR}/utils/check_whitespace ${ARGN}) | ||
|
||
add_dependencies(check-whitespace check-whitespace-${name}) | ||
endfunction() | ||
|
||
add_custom_target(checkers ALL) | ||
add_custom_target(cppstyle) | ||
add_custom_target(cppformat) | ||
|
@@ -261,7 +167,6 @@ add_dependencies(check-whitespace check-whitespace-main) | |
|
||
add_custom_target(tests) | ||
|
||
option(DEVELOPER_MODE "enable developer checks" OFF) | ||
if(DEVELOPER_MODE) | ||
# add_flag(-Werror) XXX : fix warnings | ||
find_program(CLANG_FORMAT NAMES clang-format-3.9 clang-format-3.8) | ||
|
@@ -282,10 +187,12 @@ if(DEVELOPER_MODE) | |
add_dependencies(checkers check-license) | ||
endif(DEVELOPER_MODE) | ||
|
||
add_cppstyle("include" ${CMAKE_CURRENT_SOURCE_DIR}/include/libpmemobj++/*.hpp) | ||
add_cppstyle("include-detail" ${CMAKE_CURRENT_SOURCE_DIR}/include/libpmemobj++/detail/*.hpp) | ||
add_check_whitespace("include" ${CMAKE_CURRENT_SOURCE_DIR}/include/libpmemobj++/*.hpp) | ||
add_check_whitespace("include-detail" ${CMAKE_CURRENT_SOURCE_DIR}/include/libpmemobj++/detail/*.hpp) | ||
add_cppstyle(include ${CMAKE_CURRENT_SOURCE_DIR}/include/libpmemobj++/*.hpp) | ||
add_cppstyle(include-detail ${CMAKE_CURRENT_SOURCE_DIR}/include/libpmemobj++/detail/*.hpp) | ||
add_check_whitespace(include ${CMAKE_CURRENT_SOURCE_DIR}/include/libpmemobj++/*.hpp) | ||
add_check_whitespace(include-detail ${CMAKE_CURRENT_SOURCE_DIR}/include/libpmemobj++/detail/*.hpp) | ||
add_check_whitespace(cmake-main ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt) | ||
add_check_whitespace(cmake-helpers ${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake) | ||
|
||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(PMEMOBJ REQUIRED libpmemobj>=1.4) | ||
|
@@ -313,27 +220,21 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} | |
install(DIRECTORY examples/ DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples | ||
FILES_MATCHING PATTERN "*.*pp") | ||
|
||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpmemobj++.pc.in | ||
configure_file(${CMAKE_SOURCE_DIR}/cmake/libpmemobj++.pc.in | ||
${CMAKE_CURRENT_BINARY_DIR}/libpmemobj++.pc @ONLY) | ||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpmemobj++.pc | ||
CONFIGURATIONS Release Debug | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) | ||
|
||
configure_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" | ||
"${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" | ||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" | ||
IMMEDIATE @ONLY) | ||
|
||
add_custom_target(uninstall | ||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) | ||
|
||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(VALGRIND QUIET valgrind) | ||
else() | ||
find_package(VALGRIND QUIET) | ||
endif() | ||
|
||
if(NOT WIN32) | ||
if(VALGRIND_FOUND) | ||
set(ENV{PATH} ${VALGRIND_PREFIX}/bin:$ENV{PATH}) | ||
|
@@ -349,14 +250,6 @@ if(NOT WIN32) | |
endif() | ||
endif() | ||
|
||
if(PKG_CONFIG_FOUND) | ||
pkg_check_modules(LIBUNWIND QUIET libunwind) | ||
else() | ||
find_package(LIBUNWIND QUIET) | ||
endif() | ||
if(NOT LIBUNWIND_FOUND) | ||
message(WARNING "libunwind not found. Stack traces from tests will not be reliable") | ||
endif() | ||
|
||
if(NOT WIN32) | ||
set(SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) | ||
|
@@ -381,15 +274,15 @@ else() | |
set(NO_GCC_VARIADIC_TEMPLATE_BUG TRUE) | ||
endif() | ||
|
||
include_directories(include) | ||
|
||
if(BUILD_TESTS) | ||
if(TEST_DIR) | ||
enable_testing() | ||
else() | ||
message(WARNING "TEST_DIR is empty - 'make test' will not work") | ||
endif() | ||
endif() | ||
|
||
if(BUILD_TESTS) | ||
add_subdirectory(tests) | ||
endif() | ||
|
||
|
@@ -404,57 +297,5 @@ elseif(BUILD_EXAMPLES) | |
endif() | ||
|
||
if(NOT "${CPACK_GENERATOR}" STREQUAL "") | ||
string(TOUPPER "${CPACK_GENERATOR}" CPACK_GENERATOR) | ||
|
||
if(NOT ("${CPACK_GENERATOR}" STREQUAL "DEB" OR | ||
"${CPACK_GENERATOR}" STREQUAL "RPM")) | ||
message(FATAL_ERROR "Wrong CPACK_GENERATOR value, valid generators are: DEB, RPM") | ||
endif() | ||
|
||
set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") | ||
set(CMAKE_INSTALL_TMPDIR /tmp CACHE PATH "Output dir for tmp") | ||
set(CPACK_COMPONENTS_ALL_IN_ONE) | ||
|
||
# Filter out some of directories from %dir section, which are expected | ||
# to exist in filesystem. Leaving them might lead to conflicts with other | ||
# packages (for example with 'filesystem' package on fedora which specify | ||
# /usr, /usr/local, etc.) | ||
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION | ||
${CPACK_PACKAGING_INSTALL_PREFIX} | ||
${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} | ||
${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig | ||
${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_INCDIR} | ||
${CPACK_PACKAGING_INSTALL_PREFIX}/share | ||
${CPACK_PACKAGING_INSTALL_PREFIX}/share/doc) | ||
|
||
set(CPACK_PACKAGE_NAME "libpmemobj++") | ||
set(CPACK_PACKAGE_VERSION ${VERSION}) | ||
set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR}) | ||
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR}) | ||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "c++ bindings to libpmemobj") | ||
set(CPACK_PACKAGE_VENDOR "Intel") | ||
|
||
set(CPACK_RPM_PACKAGE_NAME "libpmemobj++-devel") | ||
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries") | ||
set(CPACK_RPM_PACKAGE_LICENSE "BSD") | ||
set(CPACK_RPM_PACKAGE_ARCHITECTURE x86_64) | ||
set(CPACK_RPM_PACKAGE_REQUIRES "libpmemobj-devel >= 1.4") | ||
set(CPACK_RPM_CHANGELOG_FILE ${CMAKE_SOURCE_DIR}/ChangeLog) | ||
|
||
set(CPACK_DEBIAN_PACKAGE_NAME "libpmemobj++-dev") | ||
set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}) | ||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64) | ||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libpmemobj-dev (>= 1.4)") | ||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]") | ||
|
||
if("${CPACK_GENERATOR}" STREQUAL "RPM") | ||
set(CPACK_PACKAGE_FILE_NAME | ||
${CPACK_RPM_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}.${CPACK_RPM_PACKAGE_ARCHITECTURE}) | ||
elseif("${CPACK_GENERATOR}" STREQUAL "DEB") | ||
set(CPACK_PACKAGE_FILE_NAME | ||
${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}) | ||
endif() | ||
|
||
set(targetDestDir ${CMAKE_INSTALL_TMPDIR}) | ||
include(CPack) | ||
include(${CMAKE_SOURCE_DIR}/cmake/packages.cmake) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.