forked from pmem/pmdk-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
148 lines (127 loc) · 5.25 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#
# Copyright 2017-2018, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# pmdk_tests - main CMakeLists.txt
if (WIN32)
cmake_minimum_required(VERSION 3.1)
else ()
cmake_minimum_required(VERSION 2.8.12)
endif()
project(pmdk_tests)
# check if 32-bit architecture
if (NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
message(FATAL_ERROR "----Building as 64-bit is required. Please set build to 64-bit----")
return()
endif ()
find_package(PkgConfig QUIET)
include(FindThreads)
include(functions.cmake) # Function definitions
option(DEVELOPER_MODE "enable developer checks" OFF)
include(style-format.cmake)
# Find and set GTest, PugiXML and PMDK libraries paths
download_gtest()
download_pugixml()
if (WIN32)
set(VARS_TO_SET "")
if (NOT DEFINED ENV{PMDK_ExecutablePath})
set(VARS_TO_SET "${VARS_TO_SET} PMDK_ExecutablePath")
endif ()
if (NOT DEFINED ENV{PMDK_ExecutablePath_Dbg})
set(VARS_TO_SET "${VARS_TO_SET} PMDK_ExecutablePath_Dbg")
endif ()
if (NOT DEFINED ENV{PMDK_IncludePath})
set(VARS_TO_SET "${VARS_TO_SET} PMDK_IncludePath")
endif ()
if (NOT DEFINED ENV{PMDK_LibraryPath})
set(VARS_TO_SET "${VARS_TO_SET} PMDK_LibraryPath")
endif ()
if (NOT DEFINED ENV{PMDK_LibraryPath_Dbg})
set(VARS_TO_SET "${VARS_TO_SET} PMDK_LibraryPath_Dbg")
endif ()
if (NOT VARS_TO_SET STREQUAL "")
message(FATAL_ERROR "Following environment variables need to be set to valid directories: ${VARS_TO_SET}")
endif ()
set(Libpmem_LIBRARIES
debug "$ENV{PMDK_LibraryPath_Dbg}\\libpmem.lib"
optimized "$ENV{PMDK_LibraryPath}\\libpmem.lib")
set(Libpmemblk_LIBRARIES
debug "$ENV{PMDK_LibraryPath_Dbg}\\libpmemblk.lib"
optimized "$ENV{PMDK_LibraryPath}\\libpmemblk.lib")
set(Libpmemlog_LIBRARIES
debug "$ENV{PMDK_LibraryPath_Dbg}\\libpmemlog.lib"
optimized "$ENV{PMDK_LibraryPath}\\libpmemlog.lib")
set(Libpmemobj_LIBRARIES
debug "$ENV{PMDK_LibraryPath_Dbg}\\libpmemobj.lib"
optimized "$ENV{PMDK_LibraryPath}\\libpmemobj.lib")
set(Libpmempool_LIBRARIES
debug "$ENV{PMDK_LibraryPath_Dbg}\\libpmempool.lib"
optimized "$ENV{PMDK_LibraryPath}\\libpmempool.lib")
else ()
option(PMDK_INSTALL_PATH "PMDK installation path" "")
if (PKG_CONFIG_FOUND)
pkg_check_modules(Libpmem REQUIRED libpmem)
pkg_check_modules(Libpmemblk REQUIRED libpmemblk)
pkg_check_modules(Libpmemlog REQUIRED libpmemlog)
pkg_check_modules(Libpmemobj REQUIRED libpmemobj)
pkg_check_modules(Libpmempool REQUIRED libpmempool)
include_directories(${Libpmem_INCLUDE_DIRS}
${Libpmemblk_INCLUDE_DIRS}
${Libpmemlog_INCLUDE_DIRS}
${Libpmemobj_INCLUDE_DIRS}
${Libpmempool_INCLUDE_DIRS})
link_directories(${Libpmem_LIBRARY_DIRS}
${Libpmemblk_LIBRARY_DIRS}
${Libpmemlog_LIBRARY_DIRS}
${Libpmemobj_LIBRARY_DIRS}
${Libpmempool_LIBRARY_DIRS})
else ()
set(CMAKE_PREFIX_PATH "${PMDK_INSTALL_PATH}")
find_library(Libpmem_LIBRARIES "pmem")
find_library(Libpmemblk_LIBRARIES "pmemblk")
find_library(Libpmemlog_LIBRARIES "pmemlog")
find_library(Libpmemobj_LIBRARIES "pmemobj")
find_library(Libpmempool_LIBRARIES "pmempool")
find_path(PMDK_INCLUDE_DIR NAMES "libpmem.h" "libpmemblk.h" "libpmemlog.h" "libpmemobj.h" "libpmempool.h")
include_directories(${PMDK_INCLUDE_DIR})
endif ()
endif ()
include_directories(src/utils)
# Set platform specific flags/includes/libs
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /D_CRT_SECURE_NO_WARNINGS /DNVML_UTF8_API /DGTEST_LANG_CXX11")
include_directories($ENV{PMDK_IncludePath})
else ()
# Sets WORKAROUND_FLAGS variable which contains flags required to build with current configuration
check_workaround_flags_required()
# Disable RPATH so LD_LIBRARY_PATH can be used
set(CMAKE_SKIP_RPATH ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Drestrict=__restrict__ -Werror -Wall -Wextra -pedantic-errors -Wpedantic -std=c++11 ${WORKAROUND_FLAGS}")
endif ()
include(src/CMakeLists.txt)