CMakeLists.txt 5.04 KB
Newer Older
1
project(xacc LANGUAGES CXX)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
2
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
3
set(CMAKE_STANDARD_REQUIRED ON)
4
set(CMAKE_CXX_STANDARD 14)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
5
6
message(STATUS "C++ version ${CXX_STANDARD} configured.")

7
# Make sure all build libraries have reference to their dependents
Mccaskey, Alex's avatar
Mccaskey, Alex committed
8
9
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
10
11
12
set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage${CMAKE_INSTALL_PREFIX})

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

14
15
16
17
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  set (CMAKE_INSTALL_PREFIX "/usr/local/xacc" CACHE PATH "default install path" FORCE )
endif()

18
19
20
21
22
23
24
25
26
# 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)

27
28
29
30
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()

31
32
33
ExternalProject_Add(cppmicroservices
	GIT_REPOSITORY https://github.com/cppmicroservices/cppmicroservices
	GIT_TAG v3.1.0	
34
	CMAKE_ARGS -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
35
36
                   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
                   -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
37
		   -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
Mccaskey, Alex's avatar
Mccaskey, Alex committed
38
        INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install # DESTDIR=${CMAKE_BINARY_DIR}/cppus_install
39
)
40
41

set(CppMicroServices_BASE_DIR ${CMAKE_BINARY_DIR}/cppus_install/usr/local)
42
43
set(CppMicroServices_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/cppmicroservices3)
set(CppMicroServices_LIBRARY_DIR ${CMAKE_INSTALL_PREFIX}/lib)
44

45
# Look for OpenMP, add it we find it
Mccaskey, Alex's avatar
Mccaskey, Alex committed
46
47
48
49
50
find_package(OpenMP)
if (OPENMP_FOUND)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

51
52
53
54
55
56
57
58
59
60
61
62
ExternalProject_Add(xacc-core
   DEPENDS cppmicroservices
   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}
	      -DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
	      -DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
	      -DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
   CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
   BUILD_ALWAYS 1
Mccaskey, Alex's avatar
Mccaskey, Alex committed
63
   INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install # DESTDIR=${CMAKE_BINARY_DIR}/stage
64
65
66
67
68
69
70
   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}")
71
string (REPLACE ";" " " XACC_MPI_INCLUDE_PATHS "${MPI_CXX_INCLUDE_PATH}")
Mccaskey, Alex's avatar
Mccaskey, Alex committed
72

73
74
75
76
77
78
79
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}
80
	      -DXACC_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
81
82
              -DCPPUS_INCLUDE_DIR=${CppMicroServices_INCLUDE_DIR}
              -DCPPUS_LIBRARY_DIR=${CppMicroServices_LIBRARY_DIR}
83
84
	      -DXACC_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include/xacc #${XACC_INCLUDE_DIR}
	      -DXACC_LIBRARY_DIR=${CMAKE_INSTALL_PREFIX}/lib #${XACC_LIBRARY_DIR}
85
86
   CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
   BUILD_ALWAYS 1
Mccaskey, Alex's avatar
Mccaskey, Alex committed
87
   INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install #DESTDIR=${CMAKE_BINARY_DIR}/stage
88
89
   TEST_AFTER_INSTALL 1
   )
90
91
92
93
94

# 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
95
96
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
97
install(FILES "${CMAKE_SOURCE_DIR}/cmake/Modules/tests.cmake" DESTINATION share/xacc/)
Mccaskey, Alex's avatar
Mccaskey, Alex committed
98
INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/spdlog" DESTINATION include )
Mccaskey, Alex's avatar
Mccaskey, Alex committed
99
100
INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/eigen" DESTINATION include )
INSTALL( DIRECTORY "${CMAKE_SOURCE_DIR}/tpls/rapidjson" DESTINATION include )
101
102
103
104
105
#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 .) 
106
install(PROGRAMS "${CMAKE_SOURCE_DIR}/tools/plugins/xacc-install-plugins.py" DESTINATION bin)