-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
118 lines (108 loc) · 4.54 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
cmake_minimum_required(VERSION 3.13)
# Set up the project
option(maxflow_algos_build_bench "Build benchmark program" ON)
option(maxflow_algos_gridcut_available "GridCut implementation is available" OFF)
option(maxflow_algos_vtune_instrumentation "Enable Intel VTune instrumentation" OFF)
option(maxflow_algos_link_pard "Link P-ARD implementation" OFF)
# By default build as Release unless specified by the user
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE
STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.")
endif()
message("Build type: " ${CMAKE_BUILD_TYPE})
project("maxflow_algos" LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
# Set up paths and variables
if (maxflow_algos_vtune_instrumentation)
if (NOT DEFINED ENV{VTUNE_PROFILER_2020_DIR})
message(FATAL_ERROR "Environment variable for Intel VTune location not found")
endif()
file(TO_CMAKE_PATH "$ENV{VTUNE_PROFILER_2020_DIR}" VTUNE_PATH)
message("VTune path: " "${VTUNE_PATH}")
endif()
file(TO_CMAKE_PATH "~/oneapi-tbb-2021.1.1" TBB_PATH) # Change this to your path!
#file(TO_CMAKE_PATH "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2020.1.216/windows/tbb" TBB_PATH) # Change this to your path!
if (EXISTS ${TBB_PATH})
message("TBB path: " "${TBB_PATH}")
set(FOUND_TBB true)
else()
message(WARNING "Cannot find Intel Threading Building Blocks library. Some algorithms may not compile. Tried: " "${TBB_PATH}")
set(FOUND_TBB false)
endif()
# Add subdirectories
add_subdirectory(reimpls)
add_subdirectory(bk)
add_subdirectory(snappy)
add_subdirectory(hi_pr)
# add_subdirectory(sk)
add_subdirectory(sppr)
if (maxflow_algos_link_pard)
add_subdirectory(prd)
endif()
if (maxflow_algos_gridcut_available)
add_subdirectory(grid_cut)
endif()
# Add and configure targets
add_executable(demo "demo.cpp" "graph_io.cpp")
add_executable(bench_io "bench_io.cpp" "graph_io.cpp")
if (maxflow_algos_build_bench)
add_executable(bench "bench.cpp" "graph_io.cpp")
if (WIN32)
target_compile_options(bench PRIVATE /debug /Z7 /bigobj)
else()
target_compile_options(bench PRIVATE -g -O3 -fopenmp -fpermissive)
target_link_options(bench PRIVATE -g -O3 -lpthread -fopenmp)
endif()
if (FOUND_TBB)
if (WIN32)
target_link_directories(bench PRIVATE "${TBB_PATH}/lib/intel64_win/vc14")
else()
target_link_directories(bench PRIVATE "${TBB_PATH}/lib/intel64/gcc4.8")
endif()
target_include_directories(bench PUBLIC "${TBB_PATH}/include")
target_link_libraries(bench tbb)
endif()
target_compile_definitions(bench PRIVATE REIMPLS_NO_OVERFLOW_CHECKS NDEBUG)
target_link_libraries(bench snappy reimpls bk hi_pr sppr)
if (maxflow_algos_gridcut_available)
target_compile_definitions(bench PRIVATE GRIDCUT_IS_AVAILABLE)
target_link_libraries(bench grid_cut)
endif()
if (maxflow_algos_link_pard)
target_compile_definitions(bench PRIVATE PARD_IS_AVAILABLE)
target_link_libraries(bench d_maxflow_prd)
endif()
endif()
foreach(EXE demo bench_io)
if (WIN32)
target_compile_options(${EXE} PRIVATE /debug /Z7 /openmp)
target_link_options(${EXE} PRIVATE /profile)
else ()
target_compile_options(${EXE} PRIVATE -g -O3 -fopenmp -fpermissive)
target_link_options(${EXE} PRIVATE -g -O3 -lpthread -fopenmp)
endif()
if (FOUND_TBB)
if (WIN32)
target_link_directories(${EXE} PRIVATE "${TBB_PATH}/lib/intel64_win/vc14")
else()
target_link_directories(${EXE} PRIVATE "${TBB_PATH}/lib/intel64/gcc4.8")
endif()
target_include_directories(${EXE} PUBLIC "${TBB_PATH}/include")
target_link_libraries(${EXE} tbb)
endif()
target_compile_definitions(${EXE} PRIVATE REIMPLS_NO_OVERFLOW_CHECKS NDEBUG)
target_link_libraries(${EXE} snappy hi_pr reimpls bk sppr)
if (maxflow_algos_vtune_instrumentation)
target_include_directories(${EXE} PRIVATE "${VTUNE_PATH}/include")
target_link_directories(${EXE} PRIVATE "${VTUNE_PATH}/lib64")
target_link_libraries(${EXE} libittnotify)
target_compile_definitions(${EXE} PRIVATE REIMPLS_ENABLE_VTUNE)
else()
# If we don't use instrumentation make sure it is fully turned off
target_compile_definitions(${EXE} PRIVATE INTEL_NO_ITTNOTIFY_API)
endif()
if (maxflow_algos_gridcut_available)
target_compile_definitions(${EXE} PRIVATE GRIDCUT_IS_AVAILABLE)
target_link_libraries(${EXE} grid_cut)
endif()
endforeach()