-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
151 lines (111 loc) · 4.57 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
149
150
151
# (2.8 has ExternalProject support)
cmake_minimum_required(VERSION 2.8)
include(ExternalProject)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
set(CMAKE_XCODE_ATTRIBUTE_GCC_VERSION "com.apple.compilers.clang.3_4")
project(RdmaExperiments)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
set(CMAKE_C_FLAGS_DEBUG "-O1 -DDEBUG -g")
set(CMAKE_CXX_FLAGS_DEBUG "-O1 -DDEBUG -g")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#enable_testing()
# set(CMAKE_BUILD_TYPE RelWithDebInfo)
site_name(MACHINENAME)
# global C++ flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
# TODO: use -stdlib=libc++ too?
#########################################
# Determine third party tools to build
if(NOT DEFINED THIRD_PARTY_ROOT)
set(THIRD_PARTY_ROOT "${CMAKE_BINARY_DIR}/third-party" CACHE TYPE PATH)
endif()
###########################
# Use RUNPATH if available
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# use final INSTALL_RPATH even in build tree (this lets us manually add things to CMAKE_INSTALL_RPATH)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
# set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif("${isSystemDir}" STREQUAL "-1")
## Not setting runpath because having MPI libs in LD_LIBRARY_PATH was messing up VampirTrace's ability to find its own libs. Maybe there's another way to fix this, but it just seems more robust (for now) to not allow LD_LIBRARY_PATH to affect our libs (after configure uses it to find them).
# set runpath, too
# if(NOT APPLE)
# set(CMAKE_EXE_LINKER_FLAGS "-Wl,--enable-new-dtags")
# endif()
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${THIRD_PARTY_ROOT}/lib")
# pre-compiled external dependencies
include_directories("${THIRD_PARTY_ROOT}/include")
link_directories("${THIRD_PARTY_ROOT}/lib")
list(APPEND RDMA_EXPERIMENT_LIBS
gflags
glog
)
# TODO: actually check if PMI is available for this platform, possibly build it
if(NOT APPLE)
list(APPEND RDMA_EXPERIMENT_LIBS pmi)
endif()
if(NOT APPLE)
list(APPEND RDMA_EXPERIMENT_LIBS pthread rt)
endif()
find_library(VERBS_LIB
NAMES ibverbs
HINTS "/usr/lib64")
if(NOT APPLE)
list(APPEND ROCEHAMMER_LIBS pthread rt)
endif()
# MPI (mostly for booting, but we also use MPI communication in some places now)
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
#####################################
# Boost
#####################################
set(BOOST_COMPONENTS filesystem system unit_test_framework)
# hint for sampa cluster
set(BOOST_ROOT /sampa/share/gcc-4.8.2/src/boost_1_55_0)
set(Boost_USE_MULTITHREADED OFF)
find_package(Boost 1.51 COMPONENTS ${BOOST_COMPONENTS} QUIET)
if(NOT Boost_FOUND)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.51 COMPONENTS ${BOOST_COMPONENTS} QUIET)
endif()
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIR})
link_directories(${Boost_LIBRARY_DIRS})
string(REGEX REPLACE "/include" "" BOOST_PREFIX ${Boost_INCLUDE_DIR} )
message("-- Boost found: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} -- ${BOOST_PREFIX}")
# Boost_LIBRARIES set with the libraries to link against
foreach(lib ${Boost_LIBRARY_DIRS})
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${lib}")
endforeach()
else()
message("-- Boost not found.")
message(" !! Will download and build Boost, which may take a while.")
endif()
macro(add_rdma_exe target exe )
add_executable(${target} EXCLUDE_FROM_ALL ${ARGN})
set_target_properties(${target} PROPERTIES RUNTIME_OUTPUT_NAME "${exe}")
target_link_libraries(${target}
RdmaExperiments
${MPI_CXX_LIBRARIES}
${Boost_LIBRARIES}
)
endmacro(add_rdma_exe)
macro(add_rdma_application name)
add_rdma_exe(${name} ${name} ${ARGN})
set_property(TARGET ${name} PROPERTY FOLDER "Applications") # For organization in Xcode project
endmacro(add_rdma_application)
## put RDMA experiment src directory on include path for everything following this
include_directories(src)
####################################
# subdirectories
add_subdirectory(third-party)
add_subdirectory(src)