Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
97 lines (82 loc) · 5.22 KB
/
Copy pathCMakeLists.txt
File metadata and controls
97 lines (82 loc) · 5.22 KB
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
# CMakeLists files in this project can
# refer to the root source directory of the project as ${PDC_SOURCE_DIR} and
# to the root binary directory of the project as ${PDC_BINARY_DIR}.
cmake_minimum_required (VERSION 3.5)
# Setup cmake policies.
foreach(p
CMP0012 # CMake 2.6; Full Path Libraries; When set to NEW, the full path is included when specifying a link library in the target_link_libraries command.
CMP0013 # CMake 2.6; Quoted Argument Expansion; When set to NEW, variables within quoted arguments are expanded, allowing variable substitution.
CMP0014 # CMake 2.8; Relative Path Libraries; When set to NEW, relative paths in link libraries are interpreted as relative to the current source directory.
CMP0022 # CMake 2.8.12; Same SONAME Overwrite; When set to NEW, shared libraries with the same SONAME are not overwritten during installation.
CMP0025 # CMake 3.0; Empty if Statement; When set to NEW, an empty if condition is treated as false, providing better control over conditionals.
CMP0053 # CMake 3.1; Find Package Version; When set to NEW, the VERSION option in find_package is interpreted as a version requirement rather than a version hint.
CMP0054 # CMake 3.1; Quoted Empty String; When set to NEW, a quoted empty string is treated as false in the if() command.
CMP0074 # CMake 3.12; Imported Target Usage Requirements; When set to NEW, the "PRIVATE" and "PUBLIC" keywords in target_link_libraries are treated as usage requirements for imported targets.
CMP0075 # CMake 3.12; GNU-Style Installation Paths on macOS; When set to NEW, the "GNUInstallDirs" module is enabled by default on macOS for "GNU-style" installation paths.
CMP0079 # Address sanitizer
CMP0083 # CMake 3.14; Imported Targets Visibility; When set to NEW, imported targets created by find_package with namespaced aliases are visible to other targets within the same directory scope.
CMP0093 # CMake 3.15; Compiler and Linker Flags Handling; When set to NEW, each option in a list of compiler and linker flags is interpreted separately, allowing better control over individual options.
)
if(POLICY ${p})
cmake_policy(SET ${p} NEW)
endif()
endforeach()
# Set a consistent MACOSX_RPATH default across all CMake versions.
# checks if the variable CMAKE_MACOSX_RPATH is not defined and sets it to 0 if it is not defined.
# The CMAKE_MACOSX_RPATH variable is used to control the behavior of the macOS-specific RPATH feature in CMake.
# RPATH is a linker option that specifies the runtime library search path for executables and shared libraries.
# By default, when CMAKE_MACOSX_RPATH is not defined, the code sets it to 0, indicating that the project does not use the macOS RPATH feature.
# This means that the runtime library search path will not be embedded in the executables or shared libraries produced by the project.
# This code snippet ensures a consistent default value for CMAKE_MACOSX_RPATH across different configurations of the project, even if the variable is not explicitly set before.
# When CMake 2.8.12 is required, change this default to 1.
# When CMake 3.0.0 is required, remove this block (see CMP0042).
if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH 0)
endif()
# Force g++ for linking, because RocksDB is C++
set(CMAKE_LINKER g++)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
# Project Name : Range Query, Programming Language : C
project(RangeQuery C)
# include CheckSymbolExists module
include(CheckSymbolExists)
# CMake will search for any header files under the project root directory.
include_directories(${PROJECT_SOURCE_DIR})
#------------------------------------------------------------------------------
# Find and configure MPI
#------------------------------------------------------------------------------
find_package(MPI REQUIRED)
if(MPI_FOUND)
message(STATUS "MPI found: ${MPI_C_COMPILER}")
message(STATUS "MPI include path: ${MPI_C_INCLUDE_PATH}")
message(STATUS "MPI libraries: ${MPI_C_LIBRARIES}")
else()
message(FATAL_ERROR "MPI not found. Please install MPI.")
endif()
# Add MPI include directories
include_directories(${MPI_C_INCLUDE_PATH})
# Set MPI-specific compile and link flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_C_LINK_FLAGS}")
#------------------------------------------------------------------------------
# Configure MPI
#------------------------------------------------------------------------------
# Set RocksDB root directory
set(ROCKSDB_ROOT "$ENV{HOME}/rocksdb")
include_directories(${ROCKSDB_ROOT}/include)
link_directories(${ROCKSDB_ROOT}/build)
include_directories($ENV{HOME}/snappy-install/include)
link_directories($ENV{HOME}/snappy-install/lib64)
#------------------------------------------------------------------------------
# Setup CMake Prefix Paths for searching external libraries.
#------------------------------------------------------------------------------
if(NOT CMAKE_PREFIX_PATH)
set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
endif()
set(CMAKE_C_FLAGS_DEBUG "-O0 -g")
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)
# Link MPI libraries to the test target
# target_link_libraries(test PRIVATE ${MPI_C_LIBRARIES})
target_compile_definitions(test PRIVATE PROJECT_ROOT_DIR="${CMAKE_SOURCE_DIR}")