forked from abs-tudelft/fletcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
123 lines (98 loc) · 4.32 KB
/
CMakeLists.txt
File metadata and controls
123 lines (98 loc) · 4.32 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
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
cmake_minimum_required(VERSION 3.10)
include(GNUInstallDirs)
########################################################################################################################
# LIBRARY
########################################################################################################################
option(FLETCHER_PYTHON
"Build Fletcher for use in building pyfletcher"
OFF)
#Only needed when building for Python
set(PYARROW_DIR "/usr/" CACHE STRING "pyarrow install directory")
set(FLETCHER fletcher)
project(${FLETCHER} VERSION 0.0.1 DESCRIPTION "Fletcher C++ runtime library")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "-Wall -Wextra -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast -march=native")
if (FLETCHER_PYTHON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0")
message("Building for Pyfletcher")
endif()
set(SOURCES
src/fletcher/platform.cc
src/fletcher/context.cc
src/fletcher/usercore.cc)
# CPP runtime library uses global C header
set(GLOBAL_C_HEADER
../../common/c/src/fletcher/fletcher.h)
set(HEADERS
src/fletcher/platform.h
src/fletcher/context.h
src/fletcher/usercore.h)
add_library(${FLETCHER} SHARED ${COMMON_HEADERS} ${HEADERS} ${SOURCES})
set_target_properties(${FLETCHER} PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(${FLETCHER} PROPERTIES SOVERSION 1)
set_target_properties(${FLETCHER} PROPERTIES PUBLIC_HEADER src/fletcher/api.h)
if (FLETCHER_PYTHON)
find_library(LIB_ARROW arrow PATHS ${PYARROW_DIR} NO_DEFAULT_PATH)
include_directories(${PYARROW_DIR}/include)
else()
find_library(LIB_ARROW arrow)
endif()
message(${LIB_ARROW})
# Common library (static), if not already built
if (NOT TARGET fletcher-common)
add_subdirectory(../../common/cpp fletcher-common)
endif()
# For now, we want to include all symbols from the common static library into the runtime shared library.
# At some point they should be exposed more programatically (in the api header, for example).
target_link_libraries(${FLETCHER} -Wl,-whole-archive fletcher-common -Wl,-no-whole-archive)
include_directories(../../common/cpp/src)
include_directories(../../common/c/src)
# Dynamically link the dynamically library linking library
target_link_libraries(${FLETCHER} ${CMAKE_DL_LIBS})
# Dynamically link Arrow
target_link_libraries(${FLETCHER} ${LIB_ARROW})
# Install .so
install(TARGETS ${FLETCHER}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${FLETCHER})
# Install headers from cpp runtime
install(FILES ${HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${FLETCHER}
)
# Headers from common library
set(COMMON_HEADERS
../../common/cpp/src/fletcher/common/status.h
../../common/cpp/src/fletcher/common/arrow-utils.h
../../common/cpp/src/fletcher/common/hex-view.h
../../common/cpp/src/fletcher/common/timer.h)
install(FILES ${COMMON_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${FLETCHER}/common
)
# Install C header
install(FILES ${GLOBAL_C_HEADER}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${FLETCHER}
)
########################################################################################################################
# TESTS
########################################################################################################################
if (FLETCHER_TESTS)
enable_testing()
if (FLETCHER_ECHO)
set(FLETCHER_ECHO_LIBDIR ${CMAKE_BINARY_DIR}/platforms/echo/runtime)
else ()
add_subdirectory(../../platforms/echo/runtime ${CMAKE_BINARY_DIR}/echo)
set(FLETCHER_ECHO_LIBDIR ${CMAKE_BINARY_DIR}/echo)
endif ()
# Include GoogleTest CMake functionality
include(GoogleTest)
find_package(GTest REQUIRED)
set(TEST_SOURCES test/test.cpp)
add_executable(${FLETCHER}-test ${TEST_HEADERS} ${TEST_SOURCES})
target_link_libraries(${FLETCHER}-test ${FLETCHER})
target_link_libraries(${FLETCHER}-test ${LIB_ARROW})
target_link_libraries(${FLETCHER}-test GTest::GTest GTest::Main)
target_include_directories(${FLETCHER}-test PUBLIC ../../platforms/echo/runtime/src)
gtest_discover_tests(${FLETCHER}-test PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${FLETCHER_ECHO_LIBDIR}")
endif (FLETCHER_TESTS)