-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
84 lines (70 loc) · 2.78 KB
/
CMakeLists.txt
File metadata and controls
84 lines (70 loc) · 2.78 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
# Top-level CMake for libdop (header-only)
cmake_minimum_required(VERSION 3.16)
project(libdop VERSION 0.1.0 LANGUAGES CXX)
# Use C++20
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Add ThirdParty subdirectory for external dependencies (TaskFlow)
add_subdirectory(ThirdParty)
# If enable TaskFlow as backend, add USE_TASKFLOW
option(USE_TASKFLOW "Enable TaskFlow as backend for libdop" ON)
# Create a header-only interface library. All public headers live in `Source/`.
add_library(libdop INTERFACE
Source/Container/DenseTensor.h
Source/Container/PlainObject.h
Source/Container/Span.h
Source/Container/TypedContainer.h
Source/Container/Vector.h
Source/Dispatcher/Dispatch.h
Source/Dispatcher/DispatcherParam.h
Source/Dispatcher/ParallelRangeFor.h
Source/Dispatcher/RangeFor.h
Source/Dispatcher/Reduction.h
Source/Dispatcher/Scan.h
Source/Dispatcher/TaskHandle.h
Source/Dispatcher/TypeConverter.h
Source/Operator/IParallelRangeForOperator.h
Source/Operator/ISimpleOperator.h
Source/Operator/Tickable.h
Source/Container/Tileable.h
Source/Dispatcher/DispatcherDebugger.h)
# Add TaskFlow backend headers if enabled
if(USE_TASKFLOW)
target_sources(libdop INTERFACE
Source/Backend/TaskFlow/TaskFlowBackend.h
Source/Backend/TaskFlow/BackendTask.h)
target_compile_definitions(libdop INTERFACE USE_TASKFLOW)
target_link_libraries(libdop INTERFACE TaskFlow)
endif()
target_include_directories(libdop INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Source>
$<INSTALL_INTERFACE:include>
)
target_compile_features(libdop INTERFACE cxx_std_20)
# Provide a namespaced alias for consumers
add_library(libdop::libdop ALIAS libdop)
# Tests: optional subdirectory `Tests/` which should contain standalone test executables
option(BUILD_TESTS "Build tests located in Tests/ directory" ON)
if(BUILD_TESTS)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Tests/CMakeLists.txt")
enable_testing()
add_subdirectory(Tests)
else()
message(STATUS "BUILD_TESTS=ON but no Tests/CMakeLists.txt found in `${CMAKE_CURRENT_SOURCE_DIR}/Tests`.")
endif()
endif()
# TODO:
# Usage notes (short):
# - To use this project from another CMake project in-tree:
# add_subdirectory(path/to/libdop)
# target_link_libraries(your_target PUBLIC libdop::libdop)
#
# - To use it as an installed package, you may install this project and provide
# a package config file; then use `find_package(libdop REQUIRED)`
# and link to `libdop::libdop`.
#
# This CMake file intentionally defines only a header-only INTERFACE library
# and does not create any library or executable from sources. Tests should be
# standalone executables placed under `Tests/` and linked against
# `libdop::libdop`.