Skip to content

Commit 3e40a5e

Browse files
beneschfacebook-github-bot
authored andcommittedDec 1, 2017
add missing config checks to CMakeLists.txt
Summary: Bring CMakeLists.txt back up to parity with build_detect_platform. Closes #3211 Differential Revision: D6452908 Pulled By: ajkr fbshipit-source-id: 93f5f336ad7eff6ecf65dec47bfaf114dd24cfb2
1 parent fad1405 commit 3e40a5e

File tree

3 files changed

+85
-6
lines changed

3 files changed

+85
-6
lines changed
 

‎CMakeLists.txt

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,20 @@ if(WITH_UBSAN)
249249
endif()
250250
endif()
251251

252+
find_package(NUMA)
253+
if(NUMA_FOUND)
254+
add_definitions(-DNUMA)
255+
include_directories(${NUMA_INCLUDE_DIR})
256+
list(APPEND THIRDPARTY_LIBS ${NUMA_LIBRARIES})
257+
endif()
258+
259+
find_package(TBB)
260+
if(TBB_FOUND)
261+
add_definitions(-DTBB)
262+
include_directories(${TBB_INCLUDE_DIR})
263+
list(APPEND THIRDPARTY_LIBS ${TBB_LIBRARIES})
264+
endif()
265+
252266
# Used to run CI build and tests so we can run faster
253267
set(OPTIMIZE_DEBUG_DEFAULT 0) # Debug build is unoptimized by default use -DOPTDBG=1 to optimize
254268

@@ -316,11 +330,8 @@ if(NOT WIN32)
316330
endif()
317331

318332
option(WITH_FALLOCATE "build with fallocate" ON)
319-
320333
if(WITH_FALLOCATE)
321-
set(CMAKE_REQUIRED_FLAGS ${CMAKE_C_FLAGS})
322-
include(CheckCSourceCompiles)
323-
CHECK_C_SOURCE_COMPILES("
334+
CHECK_CXX_SOURCE_COMPILES("
324335
#include <fcntl.h>
325336
#include <linux/falloc.h>
326337
int main() {
@@ -333,12 +344,38 @@ int main() {
333344
endif()
334345
endif()
335346

336-
include(CheckFunctionExists)
337-
CHECK_FUNCTION_EXISTS(malloc_usable_size HAVE_MALLOC_USABLE_SIZE)
347+
CHECK_CXX_SOURCE_COMPILES("
348+
#include <fcntl.h>
349+
int main() {
350+
int fd = open(\"/dev/null\", 0);
351+
sync_file_range(fd, 0, 1024, SYNC_FILE_RANGE_WRITE);
352+
}
353+
" HAVE_SYNC_FILE_RANGE_WRITE)
354+
if(HAVE_SYNC_FILE_RANGE_WRITE)
355+
add_definitions(-DROCKSDB_RANGESYNC_PRESENT)
356+
endif()
357+
358+
CHECK_CXX_SOURCE_COMPILES("
359+
#include <pthread.h>
360+
int main() {
361+
(void) PTHREAD_MUTEX_ADAPTIVE_NP;
362+
}
363+
" HAVE_PTHREAD_MUTEX_ADAPTIVE_NP)
364+
if(HAVE_PTHREAD_MUTEX_ADAPTIVE_NP)
365+
add_definitions(-DROCKSDB_PTHREAD_ADAPTIVE_MUTEX)
366+
endif()
367+
368+
include(CheckCXXSymbolExists)
369+
check_cxx_symbol_exists(malloc_usable_size malloc.h HAVE_MALLOC_USABLE_SIZE)
338370
if(HAVE_MALLOC_USABLE_SIZE)
339371
add_definitions(-DROCKSDB_MALLOC_USABLE_SIZE)
340372
endif()
341373

374+
check_cxx_symbol_exists(sched_getcpu sched.h HAVE_SCHED_GETCPU)
375+
if(HAVE_SCHED_GETCPU)
376+
add_definitions(-DROCKSDB_SCHED_GETCPU_PRESENT)
377+
endif()
378+
342379
include_directories(${PROJECT_SOURCE_DIR})
343380
include_directories(${PROJECT_SOURCE_DIR}/include)
344381
include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/third-party/gtest-1.7.0/fused-src)

‎cmake/modules/FindNUMA.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# - Find NUMA
2+
# Find the NUMA library and includes
3+
#
4+
# NUMA_INCLUDE_DIR - where to find numa.h, etc.
5+
# NUMA_LIBRARIES - List of libraries when using NUMA.
6+
# NUMA_FOUND - True if NUMA found.
7+
8+
find_path(NUMA_INCLUDE_DIR
9+
NAMES numa.h numaif.h
10+
HINTS ${NUMA_ROOT_DIR}/include)
11+
12+
find_library(NUMA_LIBRARIES
13+
NAMES numa
14+
HINTS ${NUMA_ROOT_DIR}/lib)
15+
16+
include(FindPackageHandleStandardArgs)
17+
find_package_handle_standard_args(NUMA DEFAULT_MSG NUMA_LIBRARIES NUMA_INCLUDE_DIR)
18+
19+
mark_as_advanced(
20+
NUMA_LIBRARIES
21+
NUMA_INCLUDE_DIR)

‎cmake/modules/FindTBB.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# - Find TBB
2+
# Find the Thread Building Blocks library and includes
3+
#
4+
# TBB_INCLUDE_DIR - where to find tbb.h, etc.
5+
# TBB_LIBRARIES - List of libraries when using TBB.
6+
# TBB_FOUND - True if TBB found.
7+
8+
find_path(TBB_INCLUDE_DIR
9+
NAMES tbb/tbb.h
10+
HINTS ${TBB_ROOT_DIR}/include)
11+
12+
find_library(TBB_LIBRARIES
13+
NAMES tbb
14+
HINTS ${TBB_ROOT_DIR}/lib)
15+
16+
include(FindPackageHandleStandardArgs)
17+
find_package_handle_standard_args(TBB DEFAULT_MSG TBB_LIBRARIES TBB_INCLUDE_DIR)
18+
19+
mark_as_advanced(
20+
TBB_LIBRARIES
21+
TBB_INCLUDE_DIR)

0 commit comments

Comments
 (0)
Please sign in to comment.