-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
129 lines (106 loc) · 3.79 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
cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 17)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C CXX)
set(3RD_PARTY_DIR ${PROJECT_SOURCE_DIR}/3rd_party)
option(PARLA_BUILD_TESTS "Enables building of C++ tests" OFF)
option(PARLA_DEBUG "Enables all debugging flags" ON)
option(PARLA_ENABLE_LOGGING "Enable binlog logging" OFF)
option(PARLA_ENABLE_NVTX "Enable tracing with nvtx" OFF)
option(PARLA_ENABLE_CUDA "Enable compilation for CUDA architectures" OFF)
message(STATUS "PARLA_BUILD_TESTS: " ${PARLA_BUILD_TESTS})
message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
message(STATUS "PARLA_ENABLE_LOGGING: " ${PARLA_ENABLE_LOGGING})
message(STATUS "PARLA_ENABLE_NVTX: " ${PARLA_ENABLE_NVTX})
message(STATUS "PARLA_ENABLE_CUDA: " ${PARLA_ENABLE_CUDA})
set(CMAKE_VERBOSE_MAKEFILE ON)
include(CTest)
find_package(
Python
COMPONENTS Interpreter Development.Module
REQUIRED
)
set(CYTHON cython)
message(STATUS "Cython: " ${CYTHON})
#Test if cython is installed
if(NOT CYTHON)
message(
FATAL_ERROR
"Cython is required to build Parla. Please install cython and try again."
)
endif()
#Test if cython exists
execute_process(COMMAND ${CYTHON} --version ERROR_QUIET OUTPUT_VARIABLE CYTHON_VERSION)
if(NOT CYTHON_VERSION)
message(
FATAL_ERROR
"Cython is required to build Parla. Please install cython and try again."
)
endif()
message(STATUS "Python: " ${Python_EXECUTABLE})
include_directories(${NUMPY_INCLUDE})
set(CYTHON_FLAGS "--cplus;--fast-fail")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PARLA_DEBUG_C_COMPILE_FLAGS "-fno-omit-frame-pointer")
set(PARLA_DEBUG_CYTHON_FLAGS "--line-directives;-p;--gdb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PARLA_DEBUG_C_COMPILE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PARLA_DEBUG_C_COMPILE_FLAGS}")
list(APPEND CYTHON_FLAGS ${PARLA_DEBUG_CYTHON_FLAGS})
list(APPEND CYTHON_FLAGS "-X;linetrace=True")
endif()
if(UNIX)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else(NOT APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
else(NOT UNIX)
message(
ERROR
"Windows is not supported. Please raise an issue if you need Windows support."
)
endif()
if(PARLA_ENABLE_NVTX)
set(NVTX_INCLUDE ${3RD_PARTY_DIR}/nvtx/c/include)
endif(PARLA_ENABLE_NVTX)
if(PARLA_ENABLE_CUDA)
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
endif(PARLA_ENABLE_CUDA)
if(PARLA_ENABLE_HIP)
enable_language(HIP)
endif(PARLA_ENABLE_HIP)
if(PARLA_ENABLE_LOGGING)
# TODO: figure out binlog cmake support
message(STATUS "Finding binlog...")
list(APPEND CMAKE_PREFIX_PATH "${3RD_PARTY_DIR}/binlog/install")
find_package(binlog 0.1.0)
if(binlog_FOUND)
install(IMPORTED_RUNTIME_ARTIFACTS binlog::bread binlog::brecovery
DESTINATION ${SKBUILD_SCRIPTS_DIR})
install(RUNTIME_DEPENDENCY_SET binlog::binlog DESTINATION lib)
endif(binlog_FOUND)
if(NOT binlog_FOUND)
message(
STATUS "Logging library `binlog` not found. Building binlog from source")
set(BINLOG_BUILD_EXAMPLES
OFF
CACHE BOOL "Build binlog examples" FORCE)
set(BINLOG_BUILD_UNIT_TESTS
OFF
CACHE BOOL "Build binlog unit tests" FORCE)
set(BINLOG_BUILD_INTEGRATION_TESTS
OFF
CACHE BOOL "Build binlog integration tests" FORCE)
add_subdirectory(${3RD_PARTY_DIR}/binlog)
# find_package(binlog 0.1.0)
endif(NOT binlog_FOUND)
endif(PARLA_ENABLE_LOGGING)
add_subdirectory(src/c/backend)
add_subdirectory(src/python/parla)
# if(PARLA_BUILD_TESTS)
# add_subdirectory(testing)
# endif(PARLA_BUILD_TESTS)
# set(test_path_file ${CMAKE_SOURCE_DIR}/testing/run_tests.sh)
# file(WRITE ${test_path_file} "export PARLA_TESTS=${CMAKE_BINARY_DIR}/testing\n")
# file(APPEND ${test_path_file} "py.test $PARLA_TESTS\n")
# file(APPEND ${test_path_file} "ctest --test-dir $PARLA_TESTS\n")