<commit_before>cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")

############################################################
# Compiler flags
############################################################

# compiler flags that are common across debug/release builds
#  - msse4.2: Enable sse4.2 compiler intrinsics.
#  - Wall: Enable all warnings.
#  - Wno-sign-compare: suppress warnings for comparison between signed and unsigned 
#    integers
#  -Wno-deprecated: some of the gutil code includes old things like ext/hash_set, ignore that
#  - pthread: enable multithreaded malloc
#  - DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG: enable nanosecond precision for boost
SET(CXX_COMMON_FLAGS "-msse4.2 -Wall -Wno-sign-compare -Wno-deprecated -pthread")
SET(CXX_COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage")
# compiler flags for different build types (run 'cmake -DCMAKE_BUILD_TYPE=<type> .')
# For all builds:
# For CMAKE_BUILD_TYPE=Debug
#   -ggdb: Enable gdb debugging
# For CMAKE_BUILD_TYPE=Release
#   -O3: Enable all compiler optimizations
#   -g: Enable symbols for profiler tools (TODO: remove for shipping)
#   -DNDEBUG: Turn off dchecks/asserts/debug only code.
#   -Wno-strict-aliasing: Suppress warnings for potential issues with pointer aliasing.  Code
#       generated by -O3 causes these warnings.
# For profile guided optimization (PGO) builds, in addition to the flags for release builds:
#   1. Build first with CMAKE_BUILD_TYPE_PROFILE_GEN:
#     -fprofile-generate: Indicates compiler should insert profile guided optimization events
#   2. Run the benchmarks (generates *.gcda profiling data).
#   3. Build again with CMAKE_BUILD_TYPE_PROFILE_BUILD
#     -fprofile-use: Compiler will use the profile outputs for optimizations
SET(CXX_FLAGS_DEBUG "-ggdb")
SET(CXX_FLAGS_RELEASE "-O3 -g -DNDEBUG -Wno-strict-aliasing")

if (NOT "${KUDU_USE_LTO}" STREQUAL "")
  SET(CXX_FLAGS_RELEASE "${CXX_FLAGS_RELEASE} flto -fno-use-linker-plugin")
endif()

SET(CXX_FLAGS_PROFILE_GEN "${CXX_FLAGS_RELEASE} -fprofile-generate")
SET(CXX_FLAGS_PROFILE_BUILD "${CXX_FLAGS_RELEASE} -fprofile-use")

# if no build build type is specified, default to debug builds
if (NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Debug)
endif(NOT CMAKE_BUILD_TYPE)

STRING (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)

# Set compile flags based on the build type.
message("Configured for ${CMAKE_BUILD_TYPE} build (set with cmake -DCMAKE_BUILD_TYPE={release,debug,...})")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
  SET(CMAKE_CXX_FLAGS ${CXX_FLAGS_DEBUG})
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
  SET(CMAKE_CXX_FLAGS ${CXX_FLAGS_RELEASE})
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "PROFILE_GEN")
  SET(CMAKE_CXX_FLAGS ${CXX_FLAGS_PROFILE_GEN})
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "PROFILE_BUILD")
  SET(CMAKE_CXX_FLAGS ${CXX_FLAGS_PROFILE_BUILD})
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "CODE_COVERAGE_DEBUG")
  SET(CMAKE_CXX_FLAGS "${CXX_FLAGS_DEBUG} ${CXX_COVERAGE_FLAGS}")
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "CODE_COVERAGE_RELEASE")
  SET(CMAKE_CXX_FLAGS "${CXX_FLAGS_RELEASE} ${CXX_COVERAGE_FLAGS}")
else()
  message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
endif ()

# Add common flags
SET(CMAKE_CXX_FLAGS "${CXX_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}")

# Flag to enable clang address sanitizer
# This will only build if clang is the chosen compiler
if (${KUDU_USE_ASAN})
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g -fno-omit-frame-pointer")
endif ()

INCLUDE_DIRECTORIES(src)

############################################################
# Testing
############################################################
FUNCTION(ADD_KUDU_TEST TEST_NAME)
  ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
  ADD_TEST(${TEST_NAME} ${TEST_NAME})
  TARGET_LINK_LIBRARIES(${TEST_NAME} ${KUDU_TEST_LINK_LIBS})
ENDFUNCTION()

ENABLE_TESTING()

############################################################
# Dependencies
############################################################
set(THIRDPARTY_PREFIX ${CMAKE_SOURCE_DIR}/thirdparty/installed)

set(LIBS ${LIBS} -lrt)

## Boost
### Workaround for http://stackoverflow.com/questions/9948375/cmake-find-package-succeeds-but-returns-wrong-path
set(Boost_NO_BOOST_CMAKE ON)

if (${KUDU_STATIC_LINK})
  set(Boost_USE_STATIC_LIBS ON)
endif()

find_package(Boost COMPONENTS thread system REQUIRED)
include_directories( ${Boost_INCLUDE_DIR} )
set(LIBS ${LIBS} ${Boost_LIBRARIES})

## GLog
find_package(GLog REQUIRED)
include_directories(${GLOG_INCLUDE_DIR})
if (${KUDU_STATIC_LINK})
  set(LIBS ${LIBS} ${GLOG_STATIC_LIB})
else()
  set(LIBS ${LIBS} ${GLOG_LIBS}/libglog.so)
endif()

## GFlags
find_package(GFlags REQUIRED)
INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE_DIR})
if (${KUDU_STATIC_LINK})
  add_library(gflags STATIC IMPORTED)
  set_target_properties(gflags PROPERTIES IMPORTED_LOCATION "${GFLAGS_STATIC_LIB}")
else()
  add_library(gflags SHARED IMPORTED)
  set_target_properties(gflags PROPERTIES IMPORTED_LOCATION "${GFLAGS_LIBS}/libgflags.so")
endif()
SET(LIBS ${LIBS} gflags)

## GTest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIR})
add_library(gtest STATIC IMPORTED)
set_target_properties(gtest PROPERTIES IMPORTED_LOCATION "${GTEST_LIBRARY}")
set(LIBS ${LIBS} ${GTEST_LIBRARIES})

## Protobuf
SET(PROTO_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src)
SET(PROTO_DST_ROOT ${CMAKE_CURRENT_BINARY_DIR}/src)
find_package( Protobuf REQUIRED )
include_directories(${PROTOBUF_INCLUDE_DIR})
set(LIBS ${LIBS} ${PROTOBUF_LIBRARY})

## Google PerfTools
find_package( GPerf REQUIRED )
if (NOT ${KUDU_USE_ASAN})
  set(LIBS ${LIBS} ${TCMALLOC_LIBRARY})
endif()

############################################################
# Linker setup
############################################################
SET(KUDU_DEP_LIBS ${LIBS})
SET(KUDU_LINK_LIBS tablet cfile kudu_common kudu_util gutil ${LIBS})
SET(KUDU_TEST_LINK_LIBS ${KUDU_LINK_LIBS} gtest)

############################################################
# Subdirectories
############################################################
<commit_msg>cmake: fix tcmalloc to get included again<commit_after>cmake_minimum_required(VERSION 2.8)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")

############################################################
# Compiler flags
############################################################

# compiler flags that are common across debug/release builds
#  - msse4.2: Enable sse4.2 compiler intrinsics.
#  - Wall: Enable all warnings.
#  - Wno-sign-compare: suppress warnings for comparison between signed and unsigned 
#    integers
#  -Wno-deprecated: some of the gutil code includes old things like ext/hash_set, ignore that
#  - pthread: enable multithreaded malloc
#  - DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG: enable nanosecond precision for boost
SET(CXX_COMMON_FLAGS "-msse4.2 -Wall -Wno-sign-compare -Wno-deprecated -pthread")
SET(CXX_COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage")
# compiler flags for different build types (run 'cmake -DCMAKE_BUILD_TYPE=<type> .')
# For all builds:
# For CMAKE_BUILD_TYPE=Debug
#   -ggdb: Enable gdb debugging
# For CMAKE_BUILD_TYPE=Release
#   -O3: Enable all compiler optimizations
#   -g: Enable symbols for profiler tools (TODO: remove for shipping)
#   -DNDEBUG: Turn off dchecks/asserts/debug only code.
#   -Wno-strict-aliasing: Suppress warnings for potential issues with pointer aliasing.  Code
#       generated by -O3 causes these warnings.
# For profile guided optimization (PGO) builds, in addition to the flags for release builds:
#   1. Build first with CMAKE_BUILD_TYPE_PROFILE_GEN:
#     -fprofile-generate: Indicates compiler should insert profile guided optimization events
#   2. Run the benchmarks (generates *.gcda profiling data).
#   3. Build again with CMAKE_BUILD_TYPE_PROFILE_BUILD
#     -fprofile-use: Compiler will use the profile outputs for optimizations
SET(CXX_FLAGS_DEBUG "-ggdb")
SET(CXX_FLAGS_RELEASE "-O3 -g -DNDEBUG -Wno-strict-aliasing")

if (NOT "${KUDU_USE_LTO}" STREQUAL "")
  SET(CXX_FLAGS_RELEASE "${CXX_FLAGS_RELEASE} flto -fno-use-linker-plugin")
endif()

SET(CXX_FLAGS_PROFILE_GEN "${CXX_FLAGS_RELEASE} -fprofile-generate")
SET(CXX_FLAGS_PROFILE_BUILD "${CXX_FLAGS_RELEASE} -fprofile-use")

# if no build build type is specified, default to debug builds
if (NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE Debug)
endif(NOT CMAKE_BUILD_TYPE)

STRING (TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)

# Set compile flags based on the build type.
message("Configured for ${CMAKE_BUILD_TYPE} build (set with cmake -DCMAKE_BUILD_TYPE={release,debug,...})")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG")
  SET(CMAKE_CXX_FLAGS ${CXX_FLAGS_DEBUG})
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
  SET(CMAKE_CXX_FLAGS ${CXX_FLAGS_RELEASE})
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "PROFILE_GEN")
  SET(CMAKE_CXX_FLAGS ${CXX_FLAGS_PROFILE_GEN})
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "PROFILE_BUILD")
  SET(CMAKE_CXX_FLAGS ${CXX_FLAGS_PROFILE_BUILD})
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "CODE_COVERAGE_DEBUG")
  SET(CMAKE_CXX_FLAGS "${CXX_FLAGS_DEBUG} ${CXX_COVERAGE_FLAGS}")
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "CODE_COVERAGE_RELEASE")
  SET(CMAKE_CXX_FLAGS "${CXX_FLAGS_RELEASE} ${CXX_COVERAGE_FLAGS}")
else()
  message(FATAL_ERROR "Unknown build type: ${CMAKE_BUILD_TYPE}")
endif ()

# Add common flags
SET(CMAKE_CXX_FLAGS "${CXX_COMMON_FLAGS} ${CMAKE_CXX_FLAGS}")

# Flag to enable clang address sanitizer
# This will only build if clang is the chosen compiler
if (${KUDU_USE_ASAN})
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g -fno-omit-frame-pointer")
endif ()

INCLUDE_DIRECTORIES(src)

############################################################
# Testing
############################################################
FUNCTION(ADD_KUDU_TEST TEST_NAME)
  ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
  ADD_TEST(${TEST_NAME} ${TEST_NAME})
  TARGET_LINK_LIBRARIES(${TEST_NAME} ${KUDU_TEST_LINK_LIBS})
ENDFUNCTION()

ENABLE_TESTING()

############################################################
# Dependencies
############################################################
set(THIRDPARTY_PREFIX ${CMAKE_SOURCE_DIR}/thirdparty/installed)

set(LIBS ${LIBS} -lrt)

## Boost
### Workaround for http://stackoverflow.com/questions/9948375/cmake-find-package-succeeds-but-returns-wrong-path
set(Boost_NO_BOOST_CMAKE ON)

if (${KUDU_STATIC_LINK})
  set(Boost_USE_STATIC_LIBS ON)
endif()

find_package(Boost COMPONENTS thread system REQUIRED)
include_directories( ${Boost_INCLUDE_DIR} )
set(LIBS ${LIBS} ${Boost_LIBRARIES})

## GLog
find_package(GLog REQUIRED)
include_directories(${GLOG_INCLUDE_DIR})
if (${KUDU_STATIC_LINK})
  set(LIBS ${LIBS} ${GLOG_STATIC_LIB})
else()
  set(LIBS ${LIBS} ${GLOG_LIBS}/libglog.so)
endif()

## GFlags
find_package(GFlags REQUIRED)
INCLUDE_DIRECTORIES(${GFLAGS_INCLUDE_DIR})
if (${KUDU_STATIC_LINK})
  add_library(gflags STATIC IMPORTED)
  set_target_properties(gflags PROPERTIES IMPORTED_LOCATION "${GFLAGS_STATIC_LIB}")
else()
  add_library(gflags SHARED IMPORTED)
  set_target_properties(gflags PROPERTIES IMPORTED_LOCATION "${GFLAGS_LIBS}/libgflags.so")
endif()
SET(LIBS ${LIBS} gflags)

## GTest
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIR})
add_library(gtest STATIC IMPORTED)
set_target_properties(gtest PROPERTIES IMPORTED_LOCATION "${GTEST_LIBRARY}")
set(LIBS ${LIBS} ${GTEST_LIBRARIES})

## Protobuf
SET(PROTO_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/src)
SET(PROTO_DST_ROOT ${CMAKE_CURRENT_BINARY_DIR}/src)
find_package( Protobuf REQUIRED )
include_directories(${PROTOBUF_INCLUDE_DIR})
set(LIBS ${LIBS} ${PROTOBUF_LIBRARY})

## Google PerfTools
find_package( GPerf REQUIRED )
if (NOT "${KUDU_USE_ASAN}")
  set(LIBS ${LIBS} ${TCMALLOC_LIBRARY})
endif()

############################################################
# Linker setup
############################################################
SET(KUDU_DEP_LIBS ${LIBS})
SET(KUDU_LINK_LIBS tablet cfile kudu_common kudu_util gutil ${LIBS})
SET(KUDU_TEST_LINK_LIBS ${KUDU_LINK_LIBS} gtest)

############################################################
# Subdirectories
############################################################

{'fraction_non_alphanumeric': 0.20021169190685556, 'fraction_numerical': 0.003419638495359062, 'mean_word_length': 7.571528262386601, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3895185', 'n_tokens_mistral': 4375, 'n_tokens_neox': 4107, 'n_words': 884}