Skip to content

Commit

Permalink
Use cmake property to gather dependencies for test (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaraslaut authored Dec 20, 2023
1 parent f6f06cd commit 10198ac
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 10 deletions.
4 changes: 4 additions & 0 deletions runtime/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ set(COMMON_RUNTIME_SRC
# Create the cudaq-common library
add_library(${LIBRARY_NAME} SHARED ${COMMON_RUNTIME_SRC})

# Add into runtime_libs property
set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})

# Setup the includes
target_include_directories(${LIBRARY_NAME}
PRIVATE .
Expand Down Expand Up @@ -99,6 +102,7 @@ get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)

add_library(cudaq-mlir-runtime SHARED RuntimeMLIR.cpp)
set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS cudaq-mlir-runtime)

target_include_directories(cudaq-mlir-runtime
PRIVATE . ${CMAKE_SOURCE_DIR}/runtime)
Expand Down
4 changes: 3 additions & 1 deletion runtime/cudaq/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ add_library(${LIBRARY_NAME}
utils/cudaq_utils.cpp
distributed/mpi_plugin.cpp)

set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})

if (CUDA_FOUND)
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
Expand Down Expand Up @@ -71,4 +73,4 @@ install(
distributed/builtin/activate_custom_mpi.sh
DESTINATION distributed_interfaces
PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ set(BLA_STATIC ON)
find_package(BLAS REQUIRED)

add_library(${LIBRARY_NAME} SHARED ensmallen.cpp)
set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})
target_compile_definitions(${LIBRARY_NAME} PRIVATE -DARMA_DONT_USE_LAPACK)

set (ENSMALLEN_DEPENDENCIES "")
Expand Down
1 change: 1 addition & 0 deletions runtime/cudaq/algorithms/optimizers/nlopt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ set(LIBRARY_NAME cudaq-nlopt)
add_subdirectory(nlopt-src SYSTEM)

add_library(${LIBRARY_NAME} SHARED nlopt.cpp)
set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})
target_include_directories(${LIBRARY_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/runtime)
target_include_directories(${LIBRARY_NAME} SYSTEM PRIVATE nlopt-src/ nlopt-src/src/api)
target_link_libraries(${LIBRARY_NAME} PRIVATE nlopt)
Expand Down
1 change: 1 addition & 0 deletions runtime/cudaq/builder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
set(LIBRARY_NAME cudaq-builder)

add_library(cudaq-builder SHARED kernel_builder.cpp QuakeValue.cpp kernels.cpp)
set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})
target_include_directories(cudaq-builder PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/tpls/eigen>
Expand Down
1 change: 1 addition & 0 deletions runtime/cudaq/platform/default/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ set(CUDAQ_DEFAULTPLATFORM_SRC
)

add_library(${LIBRARY_NAME} SHARED ${CUDAQ_DEFAULTPLATFORM_SRC})
set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})
target_include_directories(${LIBRARY_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/runtime>
Expand Down
1 change: 1 addition & 0 deletions runtime/cudaq/qis/managers/default/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
set(LIBRARY_NAME cudaq-em-default)

add_library(${LIBRARY_NAME} SHARED DefaultExecutionManager.cpp)
set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})
target_include_directories(${LIBRARY_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/runtime>
Expand Down
1 change: 1 addition & 0 deletions runtime/cudaq/spin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(CUDAQ_SPIN_SRC
find_package(OpenMP)

add_library(${LIBRARY_NAME} SHARED ${CUDAQ_SPIN_SRC})
set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})
target_include_directories(${LIBRARY_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/runtime>
Expand Down
2 changes: 2 additions & 0 deletions runtime/nvqir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ target_include_directories(${LIBRARY_NAME}
$<INSTALL_INTERFACE:include>
PRIVATE .)

set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})

# Private link to nvqir-qpp, it will always be here,
# and by keeping it private, others can specify the
# backend library later on
Expand Down
2 changes: 2 additions & 0 deletions runtime/nvqir/qpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ set(INTERFACE_POSITION_INDEPENDENT_CODE ON)
macro (AddQppBackend LIBRARY_NAME SOURCE_FILE)
add_library(${LIBRARY_NAME} SHARED ${SOURCE_FILE})

set_property(GLOBAL APPEND PROPERTY CUDAQ_RUNTIME_LIBS ${LIBRARY_NAME})

set (EXTRA_LIBS "")
if(OpenMP_CXX_FOUND)
set(EXTRA_LIBS OpenMP::OpenMP_CXX)
Expand Down
11 changes: 2 additions & 9 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,15 @@ configure_lit_site_cfg(
set(NVQPP_TEST_PARAMS
nvqpp_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py)

# Gather all the runtime libraries to make sure they are up-to-date.
# FIXME: These libraries should self-register to a CMake property so here we
# can just use a macro instead of listing them.
set(TEST_CUDAQ_LIBRARIES
cudaq cudaq-common cudaq-mlir-runtime cudaq-builder cudaq-ensmallen
cudaq-nlopt cudaq-spin
cudaq-em-default cudaq-platform-default
nvqir nvqir-qpp nvqir-dm)
get_property(test_cudaq_libraries GLOBAL PROPERTY CUDAQ_RUNTIME_LIBS)

if (NOT CUDAQ_DISABLE_CPP_FRONTEND)
set(NVQPP_TEST_DEPENDS
cudaq-quake
cudaq-opt
cudaq-translate
fixup-linkage
${TEST_CUDAQ_LIBRARIES}
${test_cudaq_libraries}

CircuitCheck
FileCheck)
Expand Down

0 comments on commit 10198ac

Please sign in to comment.