-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
48 lines (38 loc) · 1.69 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
cmake_minimum_required(VERSION 2.8)
project(apapi_plugin)
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/common;${CMAKE_MODULE_PATH}")
OPTION(BACKEND_SCOREP "Build plugin using scorep(ON) or vampirtrace(OFF)" ON)
set(PLUGIN_SOURCE apapi.c)
add_library(${PROJECT_NAME} SHARED ${PLUGIN_SOURCE})
target_link_libraries(${PROJECT_NAME} PRIVATE pthread m)
#additional c flags
set(CMAKE_C_FLAGS "-D_GNU_SOURCE -std=c11 -O2 -g")
#debugging c flags
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DHAVE_DEBUG -O0 -Wstrict-prototypes -Wall -Wundef -Wno-long-long -Wsign-compare -Wcomment -pedantic -finline-functions -fno-strict-aliasing")
#release c flags
set(CMAKE_C_FLAGS_RELEASE "-Os")
if(BACKEND_SCOREP)
include(common/FindScorep.cmake)
if(SCOREP_FOUND)
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${SCOREP_INCLUDE_DIRS})
target_compile_definitions(${PROJECT_NAME} PRIVATE "-DBACKEND_SCOREP")
else()
message("Score-P was not found, falling back to VampirTrace!")
endif()
endif()
if(NOT SCOREP_FOUND OR NOT BACKEND_SCOREP)
include(common/FindVampirTrace.cmake)
if(VT_FOUND)
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${VT_INCLUDE_DIRS})
target_compile_definitions(${PROJECT_NAME} PRIVATE "-DBACKEND_VTRACE")
else()
message(SEND_ERROR "Found neither Score-P nor VampirTrace backend!")
endif()
endif()
find_package(PAPI REQUIRED)
option(LINK_WITH_PAPI "Link this plugin directly with libpapi.so" ON)
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${PAPI_INCLUDE_DIRS})
if(LINK_WITH_PAPI)
target_link_libraries(${PROJECT_NAME} PRIVATE ${PAPI_LIBRARIES})
endif()
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib)