summarylogtreecommitdiffstats
path: root/CMakeLists.txt.patch
blob: c5a955e9359ab7fcf759e323812ec92b20e68f43 (plain)
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
diff -ur dm-tree-0.1.8.orig/tree/CMakeLists.txt dm-tree-0.1.8/tree/CMakeLists.txt
--- dm-tree-0.1.8.orig/tree/CMakeLists.txt	2022-12-18 12:35:42.000000000 +0300
+++ dm-tree-0.1.8/tree/CMakeLists.txt	2023-06-15 16:56:39.291503035 +0300
@@ -11,8 +11,8 @@
     "Python found ${Python3_VERSION} < 3.6.0")
 endif()
 
-# Use C++14 standard.
-set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ version selection")
+# Use C++17 standard.
+set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ version selection")
 
 # Position-independent code is needed for Python extension modules.
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -27,17 +27,12 @@
 message("PROJECT_BINARY_DIR is: ${PROJECT_BINARY_DIR}")
 
 if (NOT (WIN32 OR MSVC))
-  if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
-    # Basic build for debugging (default).
-    # -Og enables optimizations that do not interfere with debugging.
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Og")
-  endif()
-
-  if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
-    # Optimized release build: turn off debug runtime checks
-    # and turn on highest speed optimizations.
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG -O3")
-  endif()
+  # Basic build for debugging (default).
+  # -Og enables optimizations that do not interfere with debugging.
+  set(CMAKE_CXX_FLAGS_DEBUG "-g -Og")
+  # Optimized release build: turn off debug runtime checks
+  # and turn on highest speed optimizations.
+  set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
 endif()
 
 if(APPLE)
@@ -67,54 +62,19 @@
 # Needed to disable Abseil tests.
 set (BUILD_TESTING OFF)
 
-# Include abseil-cpp.
-set(ABSEIL_VER 20210324.2)
-include(ExternalProject)
-set(ABSEIL_CMAKE_ARGS
-    "-DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/abseil-cpp"
-    "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
-    "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}"
-    "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}"
-    "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
-    "-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}"
-    "-DLIBRARY_OUTPUT_PATH=${CMAKE_SOURCE_DIR}/abseil-cpp/lib")
-if(DEFINED CMAKE_OSX_ARCHITECTURES)
-    set(ABSEIL_CMAKE_ARGS
-        ${ABSEIL_CMAKE_ARGS}
-        "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}")
-endif()
-ExternalProject_Add(abseil-cpp
-  GIT_REPOSITORY    https://github.com/abseil/abseil-cpp.git
-  GIT_TAG           ${ABSEIL_VER}
-  PREFIX            ${CMAKE_SOURCE_DIR}/abseil-cpp
-  CMAKE_ARGS        ${ABSEIL_CMAKE_ARGS}
+set(ABSEIL_LIBS int128 raw_hash_set raw_logging_internal strings throw_delegate)
+find_package(
+  absl
+  REQUIRED
+  COMPONENTS ${ABSEIL_LIBS}
 )
-ExternalProject_Get_Property(abseil-cpp install_dir)
-set(abseil_install_dir ${install_dir})
-include_directories (${abseil_install_dir}/include)
-
 
 # Define pybind11 tree module.
 pybind11_add_module(_tree tree.h tree.cc)
-add_dependencies(_tree abseil-cpp)
-
-if (WIN32 OR MSVC)
-    set(ABSEIL_LIB_PREF "absl")
-    set(LIB_SUFF "lib")
-else()
-    set(ABSEIL_LIB_PREF "libabsl")
-    set(LIB_SUFF "a")
-endif()
 
-# Link abseil static libs.
-# We don't use find_library here to force cmake to build abseil before linking.
-set(ABSEIL_LIBS int128 raw_hash_set raw_logging_internal strings throw_delegate)
 foreach(ABSEIL_LIB IN LISTS ABSEIL_LIBS)
-  target_link_libraries(_tree PRIVATE
-      "${abseil_install_dir}/lib/${ABSEIL_LIB_PREF}_${ABSEIL_LIB}.${LIB_SUFF}")
+  target_link_libraries(_tree PRIVATE "absl::${ABSEIL_LIB}")
 endforeach()
 
 # Make the module private to tree package.
 set_target_properties(_tree PROPERTIES OUTPUT_NAME tree/_tree)
-
-