-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
106 lines (82 loc) · 3.43 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
# ============================================================================ #
# Copyright (c) 2024 NVIDIA Corporation & Affiliates. #
# All rights reserved. #
# #
# This source code and the accompanying materials are made available under #
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "" FORCE)
# We need 3.28 because of the `EXCLUDE_FROM_ALL` in FetchContent_Declare
cmake_minimum_required(VERSION 3.28 FATAL_ERROR)
project(CUDAQX
VERSION 0.0.0
LANGUAGES C CXX)
set(CUDAQX_ALL_LIBS "qec;solvers")
set(CUDAQX_ENABLE_LIBS "" CACHE STRING
"Semicolon-separated list of libs to build (${CUDAQX_ALL_LIBS}), or \"all\".")
# We don't want to handle "all" later, thus expand it here.
if(CUDAQX_ENABLE_LIBS STREQUAL "all" )
set(CUDAQX_ENABLE_LIBS ${CUDAQX_ALL_LIBS})
endif()
# Sanity check.
foreach(lib ${CUDAQX_ENABLE_LIBS})
if (NOT "${lib}" IN_LIST CUDAQX_ALL_LIBS)
message(FATAL_ERROR "${lib} isn't a known library: ${CUDAQX_ALL_LIBS}.")
endif()
endforeach()
# Project setup
# ==============================================================================
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Add our Modules to the path
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
# Include custom CUDA-QX modules
include(CUDA-QX)
# Options
# ==============================================================================
option(CUDAQX_INCLUDE_TESTS "Generate build targets for unit tests." OFF)
option(CUDAQX_INCLUDE_DOCS "Generate build targets for the docs." OFF)
option(CUDAQX_BINDINGS_PYTHON "Generate build targets for python bindings." OFF)
# Top-level External Dependencies
# ==============================================================================
# FIXME for now, we only use library mode
set(CUDAQ_LIBRARY_MODE ON)
find_package(CUDAQ REQUIRED)
# Top-level targets
# ==============================================================================
# Helper targets to collect libraries and python modules
add_custom_target(cudaqx-pymodules)
# Top-level testing
# ==============================================================================
if (CUDAQX_INCLUDE_TESTS)
include(CTest)
add_custom_target(CUDAQXUnitTests)
add_custom_target(run_tests
COMMAND ${CMAKE_COMMAND} -E env
PYTHONPATH="${CUDAQ_INSTALL_DIR}:${CMAKE_BINARY_DIR}/python"
${CMAKE_CTEST_COMMAND} --output-on-failure
DEPENDS CUDAQXUnitTests
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
if (CUDAQX_BINDINGS_PYTHON)
set(PYTHON_TEST_DIRS "")
foreach(lib ${CUDAQX_ENABLE_LIBS})
list(APPEND PYTHON_TEST_DIRS ../libs/${lib}/python/tests)
endforeach()
add_custom_target(run_python_tests
COMMAND ${CMAKE_COMMAND} -E env
PYTHONPATH="${CUDAQ_INSTALL_DIR}:${CMAKE_BINARY_DIR}/python"
pytest -v ${PYTHON_TEST_DIRS}
DEPENDS cudaqx-pymodules
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
endif()
# Directory setup
# ==============================================================================
add_subdirectory(libs/core)
if (CUDAQX_INCLUDE_DOCS)
add_subdirectory(docs)
endif()
foreach(lib ${CUDAQX_ENABLE_LIBS})
add_subdirectory(libs/${lib})
endforeach()