CMakeLists.txt 2.72 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(xacc-python LANGUAGES CXX)

set(CMAKE_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
message(STATUS "C++ version ${CXX_STANDARD} configured.")

# Make sure all build libraries have reference to their dependents
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

set(CppMicroServices_DIR "${CPPUS_LIBRARY_DIR}/../share/cppmicroservices3/cmake")

# Modify our CMAKE_MODULE_PATH
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${XACC_ROOT}/cmake/Modules")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CppMicroServices_DIR}")
include(tests)
include(CppMicroServicesConfig)
include(tests)
include(CppMicroServicesConfig)

22
find_package(Boost COMPONENTS system program_options filesystem chrono REQUIRED)
23
24
25
26
27
28
29
30
31

include_directories(${XACC_INCLUDE_DIR}/xacc)
include_directories(${XACC_INCLUDE_DIR}/quantum/gate)
include_directories(${XACC_INCLUDE_DIR}/quantum/aqc)
include_directories(${CPPUS_INCLUDE_DIR})

include_directories(${Boost_INCLUDE_DIRS})
include_directories(${XACC_ROOT}/tpls/rapidjson/include)
include_directories(${XACC_ROOT}/tpls/eigen)
32
include_directories(${XACC_ROOT}/tpls/exprtk)
33
34
include_directories(${XACC_ROOT}/tpls/pybind11/include)
include_directories(${XACC_ROOT}/tpls/spdlog)
35
include_directories(${XACC_PYTHON_INCLUDE_DIR})
36
37
link_directories(${XACC_LIBRARY_DIR})

38
39
40
41
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -O2 -g -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wformat -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv")
if(APPLE)
   set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
endif(APPLE)
42

43
44
add_library(pyxacc SHARED xacc-py.cpp)
set_target_properties(pyxacc PROPERTIES PREFIX "")
45
link_directories(${CPPUS_LIBRARY_DIR})
Mccaskey, Alex's avatar
Mccaskey, Alex committed
46
link_directories(${Boost_LIBRARY_DIR})
47
48
49
50
#find_library(cppus_has_d_suffix CppMicroServicesd)
#if (NOT cppus_has_d_suffix)
#	set(CppUsLib CppMicroServices)
#endif()
51
target_link_libraries(pyxacc xacc xacc-quantum-gate xacc-quantum-aqc CppMicroServices ${Boost_LIBRARIES} restclient-cpp) #cpprest ${OPENSSL_LIBRARIES})
Mccaskey, Alex's avatar
Mccaskey, Alex committed
52

53
54
55
56
57
58
if (APPLE)
add_custom_command(TARGET pyxacc
    POST_BUILD COMMAND 
    ${CMAKE_INSTALL_NAME_TOOL} -change "${CMAKE_INSTALL_PREFIX}/lib/librestclient-cpp.1.dylib" "@rpath/librestclient-cpp.1.dylib" $<TARGET_FILE:pyxacc>)
endif()

59
60
if(APPLE)
   set_target_properties(pyxacc PROPERTIES INSTALL_RPATH "@loader_path/lib")
61
   set_target_properties(pyxacc PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
Mccaskey, Alex's avatar
Mccaskey, Alex committed
62
else()
63
   set_target_properties(pyxacc PROPERTIES INSTALL_RPATH "$ORIGIN/lib;$ORIGIN/plugins")
64
   set_target_properties(pyxacc PROPERTIES LINK_FLAGS "-shared")
Mccaskey, Alex's avatar
Mccaskey, Alex committed
65
endif()
66

67
install(TARGETS pyxacc DESTINATION ${CMAKE_INSTALL_PREFIX})