-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
169 lines (142 loc) · 6 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
cmake_minimum_required (VERSION 3.10 FATAL_ERROR)
project (parmcb CXX)
set(VERSION "0.1")
set(PACKAGE_VERSION "0.1")
set(DESCRIPTION "Parallel Minimum Cycle Basis Library")
set(LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
message(STATUS "We are on a ${CMAKE_SYSTEM_NAME} system")
message(STATUS "The host processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}")
message(STATUS "Building PARMCB library version: ${VERSION}")
## Add custom path with cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/etc/cmake/")
## ensure out-of-source build
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "Requires an out-of-source build. Please create a separate build directory and run 'cmake path/to/parmcb [options]' there.")
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
## additional user-defined library directories
foreach(library ${CMAKE_EXTRA_LIBRARIES})
link_directories(${library})
endforeach(library)
# Boost Libraries
set(Boost_DEBUG OFF)
set(Boost_USE_MULTITHREADED ON)
find_package (Boost REQUIRED COMPONENTS timer program_options thread mpi)
if(Boost_FOUND)
message(STATUS "Will link against the following boost libraries: ${Boost_LIBRARIES}")
message(STATUS "Boost includes: ${Boost_INCLUDE_DIRS}")
endif()
# Intel TBB
find_package(TBB)
if(TBB_FOUND)
message(STATUS "Found TBB ${TBB_VERSION}")
endif()
# MPI
find_package(MPI COMPONENTS CXX)
# Use classic install dirs
include(GNUInstallDirs)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
add_subdirectory(include/parmcb)
add_subdirectory(include/parmcb/detail)
add_subdirectory(include/parmcb/mpi)
set(GENERATED_INCLUDE_DIR ${PROJECT_BINARY_DIR}/include/parmcb)
include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include)
option(PARMCB_LOGGING "PARMCB_LOGGING" OFF)
option(PARMCB_INVARIANTS_CHECK "PARMCB_INVARIANTS_CHECK" ON)
set(PARMCB_HAVE_BOOST ${Boost_FOUND})
set(PARMCB_HAVE_TBB ${TBB_FOUND})
set(PARMCB_HAVE_MPI ${MPI_FOUND})
# If you have ABI problems, try this one
#add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
add_library(parmcb INTERFACE)
target_include_directories(parmcb INTERFACE ${PROJECT_SOURCE_DIR}/include/)
configure_file(${PROJECT_SOURCE_DIR}/include/parmcb/config.hpp.in ${GENERATED_INCLUDE_DIR}/config.hpp)
install(FILES ${GENERATED_INCLUDE_DIR}/config.hpp DESTINATION include/parmcb)
set(
DEMO_SOURCES
"mcb-dimacs.cpp"
"approx-mcb-dimacs.cpp"
"collection-stats-dimacs.cpp"
)
foreach(demosourcefile ${DEMO_SOURCES})
string(REPLACE ".cpp" "" demoname ${demosourcefile})
add_executable(${demoname} ${PROJECT_SOURCE_DIR}/src/${demosourcefile})
target_include_directories(${demoname} PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(${demoname} PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(${demoname} Boost::timer Boost::program_options Boost::thread)
target_include_directories(${demoname} PUBLIC ${TBB_INCLUDE_DIRS})
target_compile_definitions(${demoname} PUBLIC ${TBB_DEFINITIONS})
target_link_libraries(${demoname} ${TBB_LIBRARIES})
endforeach(demosourcefile ${DEMO_SOURCES})
if (PARMCB_HAVE_TBB AND PARMCB_HAVE_MPI)
set(
DEMO_MPI_SOURCES
"mcb-dimacs-mpi.cpp"
)
foreach(demosourcefile ${DEMO_MPI_SOURCES})
string(REPLACE ".cpp" "" demoname ${demosourcefile})
add_executable(${demoname} ${PROJECT_SOURCE_DIR}/src/${demosourcefile})
target_include_directories(${demoname} PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(${demoname} PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(${demoname} Boost::timer Boost::program_options Boost::thread Boost::mpi)
target_include_directories(${demoname} PUBLIC ${TBB_INCLUDE_DIRS})
target_compile_definitions(${demoname} PUBLIC ${TBB_DEFINITIONS})
target_link_libraries(${demoname} ${TBB_LIBRARIES})
target_include_directories(${demoname} PUBLIC ${MPI_C_INCLUDE_PATH})
target_link_libraries(${demoname} MPI::MPI_CXX)
endforeach(demosourcefile ${DEMO_MPI_SOURCES})
endif()
enable_testing()
include(CTest)
set(
TEST_SOURCES
"test_fp.cpp"
"test_forest_index.cpp"
"test_spvecfp.cpp"
"test_fvs.cpp"
"test_mcb.cpp"
"test_mcb1.cpp"
"test_mcb2.cpp"
"test_mcb_multiple_edges.cpp"
"test_mcb_self_loops.cpp"
"test_approx_mcb.cpp"
"test_approx_mcb1.cpp"
)
foreach(testsourcefile ${TEST_SOURCES})
string(REPLACE ".cpp" "" testname ${testsourcefile})
add_executable(${testname} ${PROJECT_SOURCE_DIR}/test/${testsourcefile})
target_include_directories(${testname} PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories(${testname} PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(${testname} Boost::timer)
target_include_directories(${testname} PUBLIC ${TBB_INCLUDE_DIRS})
target_compile_definitions(${testname} PUBLIC ${TBB_DEFINITIONS})
target_link_libraries(${testname} ${TBB_LIBRARIES})
add_test(NAME ${testname} COMMAND ${testname})
endforeach(testsourcefile ${TEST_SOURCES})
if(PARMCB_HAVE_TBB AND PARMCB_HAVE_MPI)
set(INSTALL_TARGETS "parmcb" "mcb-dimacs" "mcb-dimacs-mpi")
else()
set(INSTALL_TARGETS "parmcb" "mcb-dimacs")
endif()
install(TARGETS ${INSTALL_TARGETS}
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
# Packaging support
set(CPACK_PACKAGE_VENDOR "Dimitrios Michail")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Minimum Cycle Basis Library")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE)
set(CPACK_RESOURCE_FILE_README ${PROJECT_SOURCE_DIR}/README.md)
set(CPACK_GENERATOR "DEB;TGZ")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "DM")
include(CPack)