-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
124 lines (95 loc) · 5 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
# author: Ania Brown
# author: Jacob Wilkins
# author: Balint Koczor (Windows compatibility)
# CMake initialisation.
cmake_minimum_required(VERSION 3.1)
# Project name
project(QuEST_Project)
# -----------------------------------------------------------------------------
# ----- USER OPTIONS ----------------------------------------------------------
# -----------------------------------------------------------------------------
set(USER_SOURCE_1 "examples/workload-basic.cpp" CACHE STRING "Source to build with QuEST library")
set(OUTPUT_EXE_1 "basic" CACHE STRING "Executable to compile to")
set(USER_SOURCE_2 "examples/workload-medium.cpp" CACHE STRING "Source to build with QuEST library")
set(OUTPUT_EXE_2 "medium" CACHE STRING "Executable to compile to")
set(USER_SOURCE_3 "examples/workload-advance.cpp" CACHE STRING "Source to build with QuEST library")
set(OUTPUT_EXE_3 "advance" CACHE STRING "Executable to compile to")
option(TESTING "Enable test suite functionality -- requires test suite available" ON)
set(QuEST_UTIL_DIR_NAME "utilities" CACHE STRING
"Name of the directory containing the QuEST utilities.")
# -----------------------------------------------------------------------------
# ----- QuEST LIBRARY ---------------------------------------------------------
# -----------------------------------------------------------------------------
# Build the QuEST library if the path to libQuEST.so is not specified
if (NOT DEFINED ${QuEST_LIB_PATH})
# Build libQuEST.so
set(QuEST_DIR "QuEST" CACHE STRING
"Name of the directory containing the QuEST library sources. It must be located in the same directory as the root CMakeLists.txt")
add_subdirectory(${QuEST_DIR})
set(QuEST_LIB_PATH "${CMAKE_CURRENT_BINARY_DIR}/${QuEST_DIR}")
set(QuEST_LIB_EXACT "${QuEST_LIB_PATH}/libQuEST.so")
endif()
# -----------------------------------------------------------------------------
# ----- USER EXECUTABLE -------------------------------------------------------
# -----------------------------------------------------------------------------
message(STATUS "Compiling ${USER_SOURCE_1} to executable ${OUTPUT_EXE}")
# Create user executable
add_executable(${OUTPUT_EXE_1} ${USER_SOURCE_1})
# Link libraries to user executable, including QuEST library
if (WIN32)
target_link_libraries(${OUTPUT_EXE_1} QuEST)
else ()
target_link_libraries(${OUTPUT_EXE_1} QuEST m)
endif()
message(STATUS "Compiling ${USER_SOURCE_2} to executable ${OUTPUT_EXE}")
# Create user executable
add_executable(${OUTPUT_EXE_2} ${USER_SOURCE_2})
# Link libraries to user executable, including QuEST library
if (WIN32)
target_link_libraries(${OUTPUT_EXE_2} QuEST)
else ()
target_link_libraries(${OUTPUT_EXE_2} QuEST m)
endif()
message(STATUS "Compiling ${USER_SOURCE_3} to executable ${OUTPUT_EXE}")
# Create user executable
add_executable(${OUTPUT_EXE_3} ${USER_SOURCE_3})
# Link libraries to user executable, including QuEST library
if (WIN32)
target_link_libraries(${OUTPUT_EXE_3} QuEST)
else ()
target_link_libraries(${OUTPUT_EXE_3} QuEST m)
endif()
# -----------------------------------------------------------------------------
# ----- UTILS -----------------------------------------------------------------
# -----------------------------------------------------------------------------
set(QuEST_UTIL_DIR "${QuEST_Project_SOURCE_DIR}/${QuEST_UTIL_DIR_NAME}")
# Set dummy UTIL_ROOT location -- Temporary while transitioning to External Project
set(UTIL_ROOT ${QuEST_UTIL_DIR})
# Dummy targets for QuESTPy & QuESTTest due to later inclusion of Utils
add_custom_target( QuESTTest DEPENDS QuEST)
add_custom_target( QuESTPy DEPENDS QuEST)
# -----------------------------------------------------------------------------
# ----- TESTS -----------------------------------------------------------------
# -----------------------------------------------------------------------------
if (${TESTING})
set(Python_ADDITIONAL_VERSIONS 3.4;3.5;3.6;3.7;3.8)
find_package(PythonInterp)
if ((NOT PYTHONINTERP_FOUND) OR (PYTHON_VERSION_MAJOR LESS 3) OR (PYTHON_VERSION_MINOR LESS 4))
set(TESTING OFF CACHE BOOL "Enable test suite functionality -- requires test suite available" FORCE)
message(WARNING "Usable Python 3.4+ not found on system -- Disabling testing")
endif()
endif()
message(STATUS "Testing is ${TESTING}")
if (${TESTING})
enable_testing()
add_subdirectory(${QuEST_UTIL_DIR})
endif()
# -----------------------------------------------------------------------------
# ----- QuEST Python Interface ------------------------------------------------
# -----------------------------------------------------------------------------
set(QuESTPy_PATH "${QuEST_UTIL_DIR}/QuESTPy" CACHE STRING "Location of QuESTPy")
add_custom_target( update_QuEST_lib_loc
# Set QuESTPy default dir to this build
DEPENDS QuESTPy
COMMAND ${CMAKE_COMMAND} -DQuEST_ROOT=${PROJECT_SOURCE_DIR} -DQuESTPy_PATH=${QuESTPy_PATH} -DQuEST_LIB_EXACT=${QuEST_LIB_EXACT} -DQuEST_LIB_PATH=${QuEST_LIB_PATH} -P ${PROJECT_SOURCE_DIR}/cmake/QuESTPyLib.cmake
)