CMakeLists.txt 7.84 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
# *******************************************************************************
# Copyright (c) 2017 UT-Battelle, LLC.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# and Eclipse Distribution License v.10 which accompany this distribution. 
# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html 
# and the Eclipse Distribution License is available at 
# https://eclipse.org/org/documents/edl-v10.php
#
# Contributors:
#   Alexander J. McCaskey - initial API and implementation 
# *******************************************************************************/
13
project(xacc LANGUAGES CXX)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
14
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
15
set(CMAKE_STANDARD_REQUIRED ON)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
16
set(CMAKE_CXX_STANDARD 11)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
17
18
message(STATUS "C++ version ${CXX_STANDARD} configured.")

19
# Make sure all build libraries have reference to their dependents
Mccaskey, Alex's avatar
Mccaskey, Alex committed
20
21
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
22
23

include(ExternalProject)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
24

25
26
27
28
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set (CMAKE_INSTALL_PREFIX "/usr/local/xacc" CACHE PATH "default install path" FORCE )
endif()

29
30
31
32
33
34
35
36
37
# Setup Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
  add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen" 
    VERBATIM)
endif(DOXYGEN_FOUND)

38
39
40
41
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0.0")
        set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-Wimplicit-fallthrough=0")
endif()

42
43
44
ExternalProject_Add(cppmicroservices
	GIT_REPOSITORY https://github.com/cppmicroservices/cppmicroservices
	GIT_TAG v3.1.0	
45
	CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
46
47
48
49
50
51
52
53
54
55
56
               -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
               -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
		       -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
        INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install 
)

find_package(OpenSSL 1.0.2 REQUIRED)

message(STATUS "Found OpenSSL version ${OPENSSL_VERSION}")

ExternalProject_Add(cpprestsdk
57
    DEPENDS cppmicroservices
58
	GIT_REPOSITORY https://github.com/Microsoft/cpprestsdk
59
	GIT_TAG master
60
61
62
63
64
	CONFIGURE_COMMAND ${CMAKE_COMMAND} ../cpprestsdk/Release/ -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
               -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
               -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
		   	   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
		   	   -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
65
		   	   -DBUILD_TESTS=OFF
66
    INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install 
67
)
68

69
70
set(CppMicroServices_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/cppmicroservices3)
set(CppMicroServices_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)
71

72
73
74
set(CppRSDK_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
set(CppRSDK_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)

75
# Look for OpenMP, add it we find it
Mccaskey, Alex's avatar
Mccaskey, Alex committed
76
77
78
79
80
find_package(OpenMP)
if (OPENMP_FOUND)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

81
ExternalProject_Add(xacc-core
82
   DEPENDS cppmicroservices cpprestsdk
83
84
85
86
87
   SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xacc
   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
              -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
              -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
              -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
88
              -DBOOST_ROOT=${BOOST_ROOT}
89
90
91
92
	      	  -DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
	          -DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
	          -DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
	          -DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
Mccaskey, Alex's avatar
Mccaskey, Alex committed
93
		  -DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
94
95
	          -DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
	          -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
96
97
   CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
   BUILD_ALWAYS 1
Mccaskey, Alex's avatar
Mccaskey, Alex committed
98
   INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install # DESTDIR=${CMAKE_BINARY_DIR}/stage
99
100
101
102
103
104
105
   TEST_BEFORE_INSTALL 1
   )

set(XACC_BASE_DIR ${CMAKE_BINARY_DIR}/stage${CMAKE_INSTALL_PREFIX})
set(XACC_INCLUDE_DIR ${XACC_BASE_DIR}/include/xacc)
set(XACC_LIBRARY_DIR ${XACC_BASE_DIR}/lib)
string (REPLACE ";" " " XACC_Boost_LIBRARIES "${Boost_LIBRARIES}")
106
string (REPLACE ";" " " XACC_MPI_INCLUDE_PATHS "${MPI_CXX_INCLUDE_PATH}")
Mccaskey, Alex's avatar
Mccaskey, Alex committed
107

108
109
110
111
112
113
114
ExternalProject_Add(xacc-quantum
   DEPENDS xacc-core
   SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/quantum
   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
              -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
              -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
              -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
115
116
	          -DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
	          -DBOOST_ROOT=${BOOST_ROOT}
117
118
              -DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
              -DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
119
120
121
122
123
	          -DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include/xacc
	          -DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib
	          -DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
	          -DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
	          -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
   CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
   BUILD_ALWAYS 1
   INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install #DESTDIR=${CMAKE_BINARY_DIR}/stage
   TEST_AFTER_INSTALL 1
   )

ExternalProject_Add(xacc-python
   DEPENDS xacc-core xacc-quantum
   SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/python
   CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
              -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
              -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
              -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
	   	      -DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
	          -DBOOST_ROOT=${BOOST_ROOT}
	          -DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
              -DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
	          -DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include #${XACC_INCLUDE_DIR}
	          -DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib #${XACC_LIBRARY_DIR}
143
	          -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
144
145
146
	          -DCppRSDK_INCLUDE_DIR=${CppRSDK_INCLUDE_DIR}
	          -DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
	          -DOPENSSL_LIBRARIES=${OPENSSL_LIBRARIES}
147
148
   CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
   BUILD_ALWAYS 1
Mccaskey, Alex's avatar
Mccaskey, Alex committed
149
   INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install #DESTDIR=${CMAKE_BINARY_DIR}/stage
150
151
   TEST_AFTER_INSTALL 1
   )
152
153
154
155
156

# Install the config file for external projects to use
# This is cool, users just add find_package(XACC REQUIRED) to 
# their CMake builds, and pass -DXACC_DIR=/path/to/install/xacc
# and CMake loads include paths, libs, etc
157
158
configure_file("${CMAKE_SOURCE_DIR}/cmake/xacc-config.cmake.in" "${CMAKE_BINARY_DIR}/xacc-config.cmake")
install(FILES "${CMAKE_BINARY_DIR}/xacc-config.cmake" DESTINATION .)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
159
install(FILES "${CMAKE_SOURCE_DIR}/cmake/Modules/tests.cmake" DESTINATION share/xacc/)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
160
INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/spdlog" DESTINATION include )
Mccaskey, Alex's avatar
Mccaskey, Alex committed
161
162
INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/eigen" DESTINATION include )
INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/rapidjson" DESTINATION include )
163
INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/pybind11" DESTINATION include )
164
165
166
167
168
#install( DIRECTORY "${CMAKE_BINARY_DIR}/cppus_install/usr/local/bin/" DESTINATION bin PATTERN "bin/*" PERMISSIONS OWNER_EXECUTE) 
#install( DIRECTORY "${CMAKE_BINARY_DIR}/cppus_install/usr/local/include/" DESTINATION include) 
#install( DIRECTORY "${CMAKE_BINARY_DIR}/cppus_install/usr/local/lib/" DESTINATION lib) 
#install( DIRECTORY "${CMAKE_BINARY_DIR}/cppus_install/usr/local/share/" DESTINATION share) 
#install( DIRECTORY "${CMAKE_BINARY_DIR}/stage/${CMAKE_INSTALL_PREFIX}" DESTINATION .) 
169
install(PROGRAMS "${CMAKE_SOURCE_DIR}/tools/plugins/xacc-install-plugins.py" DESTINATION bin)