Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 41 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,22 @@ message(STATUS "Library will be named lib${LIB_NAME}. Set LIB_NAME to modify.")
option(VERBOSE_LIB_NAME "Modify library name based on compilation configuration. Turned OFF by default." OFF)
message(STATUS "Verbose library naming is turned ${VERBOSE_LIB_NAME}. Set VERBOSE_LIB_NAME to modify.")

if (VERBOSE_LIB_NAME)
# Same headers will be used for several verbosely-named libraries
set(MULTI_LIB_HEADERS 1)
function(compile_option VAR VALUE)
target_compile_definitions(QuEST PUBLIC ${VAR}=${VALUE})
endfunction()
else()
# Headers will be used for a single library with a single valid configuration
set(MULTI_LIB_HEADERS 0)
function(compile_option VAR VALUE)
target_compile_definitions(QuEST PRIVATE ${VAR}=${VALUE})
set(${VAR} ${VALUE})
endfunction()
endif()


# Precision
set(FLOAT_PRECISION 2
CACHE
Expand Down Expand Up @@ -253,8 +269,8 @@ target_include_directories(QuEST
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/quest/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<INSTALL_INTERFACE:${ORG_INSTALL_PATH}>
)
set_target_properties(QuEST PROPERTIES
VERSION ${PROJECT_VERSION}
Expand Down Expand Up @@ -283,7 +299,7 @@ target_compile_options(QuEST


# Set user options
target_compile_definitions(QuEST PUBLIC FLOAT_PRECISION=${FLOAT_PRECISION})
compile_option(FLOAT_PRECISION ${FLOAT_PRECISION})

if (ENABLE_MULTITHREADING)

Expand All @@ -299,7 +315,7 @@ if (ENABLE_MULTITHREADING)
message(FATAL_ERROR ${ErrorMsg})
endif()

target_compile_definitions(QuEST PUBLIC COMPILE_OPENMP=1)
compile_option(COMPILE_OPENMP 1)
target_link_libraries(QuEST
PRIVATE
OpenMP::OpenMP_CXX
Expand All @@ -317,14 +333,14 @@ else()
target_compile_options(QuEST PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-unknown-pragmas>)
endif()

target_compile_definitions(QuEST PUBLIC COMPILE_OPENMP=0)
compile_option(COMPILE_OPENMP 0)
endif()

if (ENABLE_DISTRIBUTION)
find_package(MPI REQUIRED
COMPONENTS CXX
)
target_compile_definitions(QuEST PUBLIC COMPILE_MPI=1)
compile_option(COMPILE_MPI 1)
target_link_libraries(QuEST
PRIVATE
MPI::MPI_CXX
Expand All @@ -333,7 +349,7 @@ if (ENABLE_DISTRIBUTION)
string(CONCAT LIB_NAME ${LIB_NAME} "+mpi")
endif()
else()
target_compile_definitions(QuEST PUBLIC COMPILE_MPI=0)
compile_option(COMPILE_MPI 0)
endif()

if (ENABLE_CUDA)
Expand All @@ -357,14 +373,14 @@ endif()

if (ENABLE_CUQUANTUM)
find_package(CUQUANTUM REQUIRED)
target_compile_definitions(QuEST PUBLIC COMPILE_CUQUANTUM=1)
compile_option(COMPILE_CUQUANTUM 1)
target_link_libraries(QuEST PRIVATE CUQUANTUM::cuStateVec)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
if (VERBOSE_LIB_NAME)
string(CONCAT LIB_NAME ${LIB_NAME} "+cuquantum")
endif()
else()
target_compile_definitions(QuEST PUBLIC COMPILE_CUQUANTUM=0)
compile_option(COMPILE_CUQUANTUM 0)
endif()

if (ENABLE_HIP)
Expand All @@ -384,7 +400,7 @@ if (ENABLE_HIP)
find_package(HIP REQUIRED)
message(STATUS "Found HIP: " ${HIP_VERSION})

target_compile_definitions(QuEST PUBLIC COMPILE_CUQUANTUM=0)
compile_option(COMPILE_CUQUANTUM 0)
target_link_libraries(QuEST PRIVATE hip::host)

if (VERBOSE_LIB_NAME)
Expand All @@ -393,9 +409,9 @@ if (ENABLE_HIP)
endif()

if (ENABLE_CUDA OR ENABLE_HIP)
target_compile_definitions(QuEST PUBLIC COMPILE_CUDA=1)
compile_option(COMPILE_CUDA 1)
else()
target_compile_definitions(QuEST PUBLIC COMPILE_CUDA=0)
compile_option(COMPILE_CUDA 0)
endif()

if (ENABLE_DEPRECATED_API)
Expand Down Expand Up @@ -533,27 +549,36 @@ set(QuEST_INSTALL_CONFIGDIR "${CMAKE_INSTALL_LIBDIR}/cmake/QuEST")

# Write QuESTConfigVersion.cmake
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/QuESTConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)

# Configure QuESTConfig.cmake (from template)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/QuESTConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/QuESTConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}Config.cmake"
INSTALL_DESTINATION "${QuEST_INSTALL_CONFIGDIR}"
)

# Install them
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/QuESTConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/QuESTConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}ConfigVersion.cmake"
DESTINATION "${QuEST_INSTALL_CONFIGDIR}"
)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/quest.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/quest/include"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/quest"
FILES_MATCHING PATTERN "*.h"
)

install(EXPORT QuESTTargets
FILE QuESTTargets.cmake
FILE "${LIB_NAME}Targets.cmake"
NAMESPACE QuEST::
DESTINATION "${QuEST_INSTALL_CONFIGDIR}"
)
2 changes: 1 addition & 1 deletion cmake/QuESTConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# @author Erich Essmann

@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/QuESTTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/@LIB_NAME@Targets.cmake")
5 changes: 1 addition & 4 deletions quest/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# @author Oliver Thomson Brown
# @author Erich Essmann

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DESTINATION "${CMAKE_INSTALL_PREFIX}"
FILES_MATCHING PATTERN "*.h"
)
configure_file(quest.h.in "${CMAKE_BINARY_DIR}/include/quest.h" @ONLY)
2 changes: 1 addition & 1 deletion quest/include/deprecated.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#ifndef DEPRECATED_H
#define DEPRECATED_H

#include "quest/include/quest.h"
#include "quest.h"

#include "stdlib.h"

Expand Down
11 changes: 10 additions & 1 deletion quest/include/quest.h → quest/include/quest.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
#define QUEST_H


#if !@MULTI_LIB_HEADERS@
#cmakedefine FLOAT_PRECISION @FLOAT_PRECISION@
#cmakedefine01 COMPILE_MPI
#cmakedefine01 COMPILE_OPENMP
#cmakedefine01 COMPILE_CUDA
#cmakedefine01 COMPILE_CUQUANTUM
#endif


// include version first so it is accessible to
// debuggers in case a subsequent include fails
#include "quest/include/version.h"
Expand Down Expand Up @@ -60,4 +69,4 @@



#endif // QUEST_H
#endif // QUEST_H
2 changes: 1 addition & 1 deletion tests/deprecated/test_calculations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// warnings issued by its compilation
#define INCLUDE_DEPRECATED_FUNCTIONS 1
#define DISABLE_DEPRECATION_WARNINGS 1
#include "quest/include/quest.h"
#include "quest.h"

#include "test_utilities.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/deprecated/test_data_structures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// warnings issued by its compilation
#define INCLUDE_DEPRECATED_FUNCTIONS 1
#define DISABLE_DEPRECATION_WARNINGS 1
#include "quest/include/quest.h"
#include "quest.h"

#include "test_utilities.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/deprecated/test_gates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// warnings issued by its compilation
#define INCLUDE_DEPRECATED_FUNCTIONS 1
#define DISABLE_DEPRECATION_WARNINGS 1
#include "quest/include/quest.h"
#include "quest.h"

#include "test_utilities.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/deprecated/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define INCLUDE_DEPRECATED_FUNCTIONS 1
#define DISABLE_DEPRECATION_WARNINGS 1

#include "quest/include/quest.h"
#include "quest.h"
#include "test_utilities.hpp"

#include <stdexcept>
Expand Down
2 changes: 1 addition & 1 deletion tests/deprecated/test_operators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// warnings issued by its compilation
#define INCLUDE_DEPRECATED_FUNCTIONS 1
#define DISABLE_DEPRECATION_WARNINGS 1
#include "quest/include/quest.h"
#include "quest.h"

#include "test_utilities.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/deprecated/test_state_initialisations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#define INCLUDE_DEPRECATED_FUNCTIONS 1
#define DISABLE_DEPRECATION_WARNINGS 1
#include "quest/include/quest.h"
#include "quest.h"

#include "test_utilities.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/deprecated/test_unitaries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// warnings issued by its compilation
#define INCLUDE_DEPRECATED_FUNCTIONS 1
#define DISABLE_DEPRECATION_WARNINGS 1
#include "quest/include/quest.h"
#include "quest.h"

#include "test_utilities.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/deprecated/test_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#define INCLUDE_DEPRECATED_FUNCTIONS 1
#define DISABLE_DEPRECATION_WARNINGS 1
#include "quest/include/quest.h"
#include "quest.h"

#include "test_utilities.hpp"

Expand Down
2 changes: 1 addition & 1 deletion tests/deprecated/test_utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#ifndef QUEST_TEST_UTILS_H
#define QUEST_TEST_UTILS_H

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/generators/catch_generators.hpp>

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/densitymatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @author Tyson Jones
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include <iostream>
#include <string>

#include "quest/include/quest.h"
#include "quest.h"
#include "tests/utils/cache.hpp"
#include "tests/utils/macros.hpp"
#include "tests/utils/random.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/calculations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators_range.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/channels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/decoherence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/initialisations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/matrices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/catch_template_test_macros.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/paulis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/qureg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @ingroup unittests
*/

#include "quest/include/quest.h"
#include "quest.h"

#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
Expand Down
Loading