forked from LLNL/Caliper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
197 lines (158 loc) · 5.39 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#
# Caliper
#
cmake_minimum_required(VERSION 3.0)
project (caliper)
# Version information
set(CALIPER_MAJOR_VERSION 1)
set(CALIPER_MINOR_VERSION 5)
set(CALIPER_PATCH_VERSION 0)
set(CALIPER_VERSION "${CALIPER_MAJOR_VERSION}.${CALIPER_MINOR_VERSION}.${CALIPER_PATCH_VERSION}")
# Add our module directory to the include path.
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
include(GNUInstallDirs)
# Optional Fortran
option(WITH_FORTRAN "Install Fortran interface and build test programs")
# Shared libs option
option(BUILD_SHARED_LIBS "Build shared libraries" TRUE)
if (NOT BUILD_SHARED_LIBS)
# Try to find static libs first for static builds
list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .a)
endif()
# RPATH setup. By default, rpath everything.
option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "Add rpath for all dependencies" TRUE)
option(WITH_TOOLS "Build Caliper tools" TRUE)
option(WITH_TEST_APPS "Build Caliper test apps" TRUE)
option(WITH_DOCS "Build Caliper documentation" FALSE)
option(WITH_CUDA "Enable Caliper CUDA services" FALSE)
option(WITH_NETOUT "Enable netout service (requires curl)" FALSE)
option(WITH_PAPI "Enable PAPI hardware counter service (requires papi)" TRUE)
option(WITH_CALLPATH "Enable callpath service (requires libunwind)" TRUE)
option(WITH_MPI "Enable MPI" TRUE)
option(WITH_SAMPLER "Enable sampler (x86 Linux only)" TRUE)
option(WITH_DYNINST "Enable dyninst (for symbollookup service" TRUE)
# configure testing explicitly rather than with include(CTest) - avoids some clutter
option(BUILD_TESTING "Build continuous integration app and unit tests" ON)
if (BUILD_TESTING)
enable_testing()
endif()
# 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_FULL_LIBDIR} isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
endif("${isSystemDir}" STREQUAL "-1")
if(WITH_CUDA)
find_package(CUDA)
include_directories(${CUDA_INCLUDE_DIRS})
find_library(NVVP_LIBRARY NAME libnvToolsExt.so PATHS ${CUDA_TOOLKIT_ROOT_DIR}/lib64 ${CUDA_TOOLKIT_ROOT_DIR}/lib)
set(CALIPER_HAVE_NVVP ON)
list(APPEND CALIPER_EXTERNAL_LIBS ${NVVP_LIBRARY})
endif()
if(CALIPER_HAVE_TAU)
find_library(tau_lib libTAU.so)
list(APPEND CALIPER_EXTERNAL_LIBS ${tau_lib})
endif()
# Find libunwind
if (WITH_CALLPATH)
include(FindLibunwind)
if (LIBUNWIND_FOUND)
set(CALIPER_HAVE_LIBUNWIND TRUE)
list(APPEND CALIPER_EXTERNAL_LIBS ${LIBUNWIND_LIBRARY})
endif()
endif()
if (WITH_NETOUT)
include(FindLibcurl)
if (LIBCURL_FOUND)
set(CALIPER_HAVE_LIBCURL TRUE)
list(APPEND CALIPER_EXTERNAL_LIBS ${LIBCURL_LIBRARY})
endif()
endif()
# Find PAPI
if (WITH_PAPI)
include(FindPAPI)
if (PAPI_FOUND)
set(CALIPER_HAVE_PAPI TRUE)
list(APPEND CALIPER_EXTERNAL_LIBS ${PAPI_LIBRARIES})
endif()
endif()
# Find Mitos
# find_package(Mitos QUIET)
# if(Mitos_FOUND)
# find_package(Dyninst REQUIRED SymtabAPI InstructionAPI ParseAPI)
# set(CALIPER_HAVE_MITOS TRUE)
# list(APPEND CALIPER_EXTERNAL_LIBS mitos hwloc symtabAPI instructionAPI parseAPI)
# message(STATUS "Mitos found")
# endif()
# Find dyninst
if (WITH_DYNINST)
find_package(Dyninst)
if (Dyninst_FOUND)
set(CALIPER_HAVE_DYNINST TRUE)
list(APPEND CALIPER_EXTERNAL_LIBS symtabAPI)
endif()
endif()
find_package(Threads)
# Find OMPT header
find_path(OMPT_INCLUDE_DIR ompt.h
PATH_SUFFIXES include
HINTS $ENV{OMPT_DIR} ${OMPT_DIR})
if (OMPT_INCLUDE_DIR)
set(OMPT_FOUND TRUE)
set(CALIPER_HAVE_OMPT TRUE)
message(STATUS "OpenMP tools interface header ompt.h found in " ${OMPT_INCLUDE_DIR})
else()
message(STATUS "OpenMP tools interface header ompt.h not found")
endif()
# Find MPI
if (WITH_MPI)
find_package(MPI)
if (MPI_C_FOUND)
set(CALIPER_HAVE_MPI TRUE)
endif()
endif()
# Find Python
find_package(PythonInterp REQUIRED)
if (WITH_SAMPLER)
# Sampler is currently Linux-specific: check for Linux
if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
set(CALIPER_HAVE_SAMPLER TRUE)
# Linux PC sampler needs -lrt
list(APPEND CALIPER_EXTERNAL_LIBS "-lrt")
message(STATUS "Linux detected, adding sampler service")
endif()
endif()
# Create a config header file
configure_file(
${PROJECT_SOURCE_DIR}/caliper-config.h.in
${PROJECT_BINARY_DIR}/caliper-config.h)
# Create pkg-confic .pc file
set(PKG_CONFIG_INCLUDEDIR "\${prefix}/include")
set(PKG_CONFIG_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(PKG_CONFIG_LIBS "-L\${libdir} -lcaliper")
set(PKG_CONFIG_CFLAGS "-I\${includedir}")
configure_file(
${PROJECT_SOURCE_DIR}/caliper.pc.in
${PROJECT_BINARY_DIR}/caliper.pc)
# Make caliper findable for cmake
configure_file(
${PROJECT_SOURCE_DIR}/caliper-config.cmake.in
${PROJECT_BINARY_DIR}/caliper-config.cmake
@ONLY)
install(FILES ${PROJECT_BINARY_DIR}/caliper-config.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/caliper)
install(EXPORT caliper
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/cmake/caliper)
install(FILES ${PROJECT_BINARY_DIR}/caliper-config.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/caliper)
install(FILES ${PROJECT_BINARY_DIR}/caliper.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
add_subdirectory(ext)
add_subdirectory(src)
if (WITH_TEST_APPS)
add_subdirectory(test)
endif()
if (WITH_DOCS)
add_subdirectory(doc)
endif()
# Install exports
#install(EXPORT caliper DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)