-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
123 lines (88 loc) · 3.56 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
cmake_minimum_required(VERSION 3.0)
project(NPGI)
if(BUILD_TEST)
include(CTest)
if (CMAKE_VERSION VERSION_LESS 3.2)
set(UPDATE_DISCONNECTED_IF_AVAILABLE "")
else()
set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1")
endif()
include(DownloadProject.cmake)
download_project(PROJ googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG master
${UPDATE_DISCONNECTED_IF_AVAILABLE}
)
# Prevent GoogleTest from overriding our compiler/linker options
# when building with Visual Studio
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
# When using CMake 2.8.11 or later, header path dependencies
# are automatically added to the gtest and gmock targets.
# For earlier CMake versions, we have to explicitly add the
# required directories to the header search path ourselves.
if (CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include"
"${gmock_SOURCE_DIR}/include")
endif()
endif()
## MADP toolbox
if(MADPPATH)
set(MADP_INCLUDE_DIRECTORIES ${MADPPATH}/include)
set(MADP_LIBRARY_PATH ${MADPPATH}/lib)
else()
include(ExternalProject)
set(EXTERNALS_DIR ${CMAKE_CURRENT_BINARY_DIR}/external)
ExternalProject_Add(project_madp
URL https://github.com/MADPToolbox/MADP/archive/v0.4.1.tar.gz
URL_HASH MD5=b385c9d4c2b478c0b0611774ee7f26bf
PREFIX ${EXTERNALS_DIR}/madp
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
BUILD_COMMAND make -j12
INSTALL_COMMAND make install
)
ExternalProject_Get_Property(project_madp INSTALL_DIR)
set(MADP_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
set(MADP_LIBRARY_PATH ${INSTALL_DIR}/lib)
message(STATUS "MADP_INCLUDE_DIRECTORIES: ${MADP_INCLUDE_DIRECTORIES}")
add_library(MADP STATIC IMPORTED)
set_property(TARGET MADP PROPERTY IMPORTED_LOCATION ${MADP_LIBRARY_PATH}/libMADP-0.4.1.so)
add_dependencies(MADP project_madp)
endif()
include_directories(include
${EIGEN3_INCLUDE_DIR}
SYSTEM ${MADP_INCLUDE_DIRECTORIES})
link_directories(${MADP_LIBRARY_PATH})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
if(COMPILER_SUPPORTS_CXX14)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.")
endif()
add_definitions(
-Wfatal-errors
)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
FIND_PACKAGE(Boost 1.58 COMPONENTS program_options regex graph REQUIRED)
find_package(PkgConfig)
pkg_search_module(Eigen3 REQUIRED eigen3)
# Add warnings and errors
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
#################
add_subdirectory(pybind11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
#################
add_library(MADPWrapper src/MADPWrapper.cpp)
target_link_libraries(MADPWrapper MADP Threads::Threads ${Boost_LIBRARIES})
##############################################################################
target_link_libraries(MADPWrapper pybind11)
pybind11_add_module(madp_python3_wrapper src/mywrap.cpp)
target_link_libraries(madp_python3_wrapper PRIVATE MADP ${Boost_LIBRARIES} MADPWrapper)
##############################################################################