22# Copyright 2018-2021, Intel Corporation
33
44cmake_minimum_required (VERSION 3.3 )
5+
56project (libpmemobj-cpp C CXX )
7+ set (LIBPMEMOBJCPP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
68
79# ----------------------------------------------------------------- #
810## Set required and useful variables
@@ -19,27 +21,11 @@ if(VERSION_PRERELEASE)
1921 set (VERSION ${VERSION} -${VERSION_PRERELEASE} )
2022endif ()
2123
22- set (LIBPMEMOBJCPP_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
23- set (LIBPMEMOBJ_REQUIRED_VERSION 1.9)
24- set (LIBPMEM_REQUIRED_VERSION 1.7)
25- # Only pmreorder in ver. >= 1.9 guarantees reliable output
26- set (PMREORDER_REQUIRED_VERSION 1.9)
27-
28- set (CMAKE_DISABLE_IN_SOURCE_BUILD ON )
24+ set (CXX_STANDARD 14 CACHE STRING "C++ language standard" )
2925
30- # Treat CMAKE_CXX_STANDARD as a requirement
3126set (CXX_STANDARD_REQUIRED ON )
32-
33- set (CXX_STANDARD 14 CACHE STRING "C++ language standard" )
3427set (CMAKE_CXX_STANDARD ${CXX_STANDARD} )
3528
36- # Do not treat include directories from the interfaces
37- # of consumed Imported Targets as SYSTEM by default.
38- set (CMAKE_NO_SYSTEM_FROM_IMPORTED 1)
39-
40- set (TEST_DIR ${CMAKE_CURRENT_BINARY_DIR} /test CACHE STRING "working directory for tests" )
41- message (STATUS "TEST_DIR set to: \" ${TEST_DIR} \" " )
42-
4329# Specify and print the build type
4430set (DEFAULT_BUILD_TYPE "RelWithDebInfo" )
4531set (predefined_build_types
@@ -59,7 +45,23 @@ else()
5945 endif ()
6046endif ()
6147
48+ include (${LIBPMEMOBJCPP_ROOT_DIR} /cmake/functions.cmake )
49+ # set SRCVERSION, it's more accurate and "current" than VERSION
50+ set_source_ver (SRCVERSION )
51+
6252set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LIBPMEMOBJCPP_ROOT_DIR} /cmake)
53+ set (CMAKE_DISABLE_IN_SOURCE_BUILD ON )
54+ set (LIBPMEMOBJ_REQUIRED_VERSION 1.9)
55+ set (LIBPMEM_REQUIRED_VERSION 1.7)
56+ # Only pmreorder in ver. >= 1.9 guarantees reliable output
57+ set (PMREORDER_REQUIRED_VERSION 1.9)
58+
59+ set (TEST_DIR ${CMAKE_CURRENT_BINARY_DIR} /test CACHE STRING "working directory for tests" )
60+ message (STATUS "TEST_DIR set to: \" ${TEST_DIR} \" " )
61+
62+ # Do not treat include directories from the interfaces
63+ # of consumed Imported Targets as SYSTEM by default.
64+ set (CMAKE_NO_SYSTEM_FROM_IMPORTED 1)
6365
6466# ----------------------------------------------------------------- #
6567## CMake build options
@@ -110,9 +112,11 @@ include(CheckCXXSourceCompiles)
110112include (CheckCXXCompilerFlag )
111113include (GNUInstallDirs )
112114
113- include (${LIBPMEMOBJCPP_ROOT_DIR} /cmake/functions.cmake )
114- # set SRCVERSION, it's more accurate and "current" than VERSION
115- set_source_ver (SRCVERSION )
115+ # Configure the ccache as compiler launcher
116+ find_program (CCACHE_FOUND ccache )
117+ if (USE_CCACHE AND CCACHE_FOUND)
118+ set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
119+ endif ()
116120
117121if (WIN32 )
118122 # Required for MSVC to correctly define __cplusplus
@@ -123,20 +127,16 @@ if(NOT WIN32)
123127 find_package (PkgConfig QUIET )
124128endif ()
125129
126- # Configure the ccache as compiler launcher
127- find_program (CCACHE_FOUND ccache )
128- if (USE_CCACHE AND CCACHE_FOUND)
129- set_property (GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache )
130- endif ()
131-
132- # Find Valgrind
130+ # Finds valgrind and checks for pmemcheck's availability
133131if (PKG_CONFIG_FOUND)
134132 pkg_check_modules (VALGRIND QUIET valgrind )
135133else ()
136134 find_package (VALGRIND QUIET )
137135endif ()
138136
139137if (VALGRIND_FOUND)
138+ message (STATUS "Found Valgrind in '${VALGRIND_LIBRARY_DIRS} ' (version: ${VALGRIND_VERSION} )" )
139+
140140 add_flag (-DLIBPMEMOBJ_CPP_VG_MEMCHECK_ENABLED=1 )
141141 add_flag (-DLIBPMEMOBJ_CPP_VG_DRD_ENABLED=1 )
142142 add_flag (-DLIBPMEMOBJ_CPP_VG_HELGRIND_ENABLED=1 )
@@ -314,7 +314,7 @@ endif()
314314if (BUILD_EXAMPLES AND NO_GCC_VARIADIC_TEMPLATE_BUG)
315315 add_subdirectory (examples )
316316elseif (BUILD_EXAMPLES)
317- message (WARNING "Skipping building of examples because of compiler issue " )
317+ message (WARNING "Skipping building of examples because of gcc variadic template bug " )
318318endif ()
319319
320320if (NOT "${CPACK_GENERATOR} " STREQUAL "" )
0 commit comments