forked from LLNL/Caliper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
157 lines (123 loc) · 4.12 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
#
# 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(FindLibunwind)
include(FindPAPI)
include(FindLibcurl)
# Optional Fortran
option(WITH_FORTRAN "Install Fortran interface and build test programs")
# Shared libs option
option(BUILD_SHARED_LIBS "Build shared libraries" TRUE)
# 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_TESTS "Build Caliper test apps" TRUE)
option(WITH_DOCS "Build Caliper documentation" FALSE)
option(WITH_CUDA "Enable Caliper CUDA services" FALSE)
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()
# 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")
# Find libunwind
if (LIBUNWIND_FOUND)
set(CALIPER_HAVE_LIBUNWIND TRUE)
list(APPEND CALIPER_EXTERNAL_LIBS ${LIBUNWIND_LIBRARY})
endif()
if (LIBCURL_FOUND)
set(CALIPER_HAVE_LIBCURL TRUE)
list(APPEND CALIPER_EXTERNAL_LIBS ${LIBCURL_LIBRARY})
endif()
# Find PAPI
if (PAPI_FOUND)
set(CALIPER_HAVE_PAPI TRUE)
list(APPEND CALIPER_EXTERNAL_LIBS ${PAPI_LIBRARIES})
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_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
find_package(MPI QUIET)
if (MPI_C_FOUND)
set(CALIPER_HAVE_MPI TRUE)
endif()
# Find Python
find_package(PythonLibs)
# 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()
# 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}/lib")
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 share/cmake/caliper)
install(EXPORT caliper
DESTINATION share/cmake/caliper)
install(FILES ${PROJECT_BINARY_DIR}/caliper-config.h
DESTINATION include/caliper)
install(FILES ${PROJECT_BINARY_DIR}/caliper.pc
DESTINATION share/pkgconfig)
add_subdirectory(src)
if (WITH_TESTS)
add_subdirectory(test)
endif()
if (WITH_DOCS)
add_subdirectory(doc)
endif()
# Install exports
#install(EXPORT caliper DESTINATION lib/cmake)