-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
139 lines (112 loc) · 4.25 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
cmake_minimum_required(VERSION 3.3)
set(CMAKE_CXX_STANDARD 20)
project(mcp)
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif ()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g -fopenmp")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -fopenmp -DNDEBUG")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "") # Enable/Disable output of compile commands during generation
# find GUROBI is desired
option(GUROBI "Build Gurobi part of the project" OFF)
### This Project #####
add_subdirectory(src)
# NO hpp files needed here!
# Sort alphabetical (leave main at position 0)
set(SOURCES
src/auxiliary/graphs.cpp
src/auxiliary/small_ccs.cpp
src/auxiliary/statistics.cpp
src/auxiliary/cl_parser.cpp
src/prepro/weight_stable_reducer.cpp
src/prepro/similar_subgraph_reduction.cpp
src/prepro/spqr.cpp
src/prepro/weighted_reducer.cpp
src/solver/burer_solver.cpp
src/solver/enumeration_solver.cpp
src/solver/unit_weight_solver.cpp
src/solver/gurobi_quadratic_solver.cpp
)
### Extern Projects #####
if (GUROBI)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
find_package(GUROBI REQUIRED)
include_directories(SYSTEM ${GUROBI_INCLUDE_DIRS})
endif ()
# NetworKIT
if (NOT NETWORKIT_DIR)
add_subdirectory(extern/networkit)
else ()
add_library(networkit SHARED IMPORTED)
set_target_properties(networkit PROPERTIES
IMPORTED_LOCATION ${NETWORKIT_DIR}/lib/libnetworkit.so
INTERFACE_INCLUDE_DIRECTORIES ${NETWORKIT_DIR}/include
)
endif ()
# OGDF
if (NOT OGDF_DIR)
add_subdirectory(extern/ogdf)
else ()
find_package(OGDF CONFIG PATHS ${OGDF_DIR})
if (NOT OGDF_FOUND)
message(FATAL_ERROR "No OGDF configuration for CMake has been found. "
"Please set OGDF_CONFIG_SEARCH_PATH such that ogdf-config.cmake (generated by your OGDF build) can be found.")
endif ()
endif ()
# json
add_subdirectory(extern/json)
#cxxopts
add_subdirectory(extern/cxxopts)
#cxxopts
add_subdirectory(extern/MQLib)
# gtest
option(TESTS "Build the tests" ON)
if (TESTS)
enable_testing()
include(GoogleTest)
add_subdirectory("${PROJECT_SOURCE_DIR}/extern/gtest" "extern/googletest")
macro(package_add_test TESTNAME)
# create an executable in which the tests will be stored
add_executable(${TESTNAME} ${ARGN})
# link the Google test infrastructure, mocking library, and a default main function to
# the test executable. Remove g_test_main if writing your own main function.
target_include_directories(${TESTNAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(${TESTNAME} gtest gmock gtest_main networkit OGDF nlohmann_json::nlohmann_json cxxopts mqlib)
# gtest_discover_tests replaces gtest_add_tests,
# see https://cmake.org/cmake/help/v3.10/module/GoogleTest.html for more options to pass to it
gtest_discover_tests(${TESTNAME}
# set a working directory so your project root so that you can find test data via paths relative to the project root
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_DIR}"
)
set_target_properties(${TESTNAME} PROPERTIES FOLDER tests)
endmacro()
# ADD TEST DIRECTORIES HERE
add_subdirectory(${PROJECT_SOURCE_DIR}/src/auxiliary/test)
add_subdirectory(${PROJECT_SOURCE_DIR}/src/instance/test)
add_subdirectory(${PROJECT_SOURCE_DIR}/src/prepro/test)
add_subdirectory(${PROJECT_SOURCE_DIR}/src/solver/test)
endif ()
## This project links
## Gurobi binary
if (GUROBI)
add_executable(gurobi_quadratic
src/mains/gurobi_quadratic.cpp
src/solver/gurobi_quadratic_solver.cpp
${SOURCES})
target_include_directories(gurobi_quadratic
PRIVATE
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(gurobi_quadratic
optimized ${GUROBI_CXX_LIBRARY}
debug ${GUROBI_CXX_DEBUG_LIBRARY}
${GUROBI_LIBRARY}
networkit
cxxopts
OGDF
nlohmann_json::nlohmann_json
mqlib
)
endif ()