Skip to content

Commit

Permalink
Change build system to CMake
Browse files Browse the repository at this point in the history
It's a much cleaner build system with a clear syntax and simple
configuration. Using cmake flags, we can control precisely which extra
components we build (examples, unit-tests, benchmarks, etc).

Split benchmarks into specific-benchmarks (the old ones) and
universal-benchmark (the new one)
  • Loading branch information
manugoyal committed Feb 10, 2017
1 parent 1684e7e commit dfe7d8d
Show file tree
Hide file tree
Showing 71 changed files with 2,589 additions and 1,955 deletions.
15 changes: 15 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 2.8.7)
project(libcuckoo LANGUAGES CXX)
set (libcuckoo_VERSION_MAJOR 0)
set (libcuckoo_VERSION_MINOR 1)

# Add the libcuckoo interface target
add_subdirectory(libcuckoo)

# Build examples
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

# Build tests -- this only builds tests that were specified
add_subdirectory(tests)
4 changes: 2 additions & 2 deletions LICENSE
Expand Up @@ -14,5 +14,5 @@ limitations under the License.

---------------------------

CityHash (lib/city.h, lib/city.cc) is Copyright (c) Google, Inc. and
has its own license, as detailed in the source files.
The third-party libraries have their own licenses, as detailed in their source
files.
8 changes: 0 additions & 8 deletions Makefile.am

This file was deleted.

Empty file removed cityhash-1.1.1/m4/.gitkeep
Empty file.
33 changes: 0 additions & 33 deletions configure.ac

This file was deleted.

10 changes: 10 additions & 0 deletions examples/CMakeLists.txt
@@ -0,0 +1,10 @@
add_subdirectory(cityhash)

add_executable(nested_table nested_table.cc)
target_link_libraries(nested_table libcuckoo)

add_executable(hellohash hellohash.cc)
target_link_libraries(hellohash libcuckoo cityhash)

add_executable(count_freq count_freq.cc)
target_link_libraries(count_freq libcuckoo cityhash)
9 changes: 0 additions & 9 deletions examples/Makefile.am

This file was deleted.

12 changes: 12 additions & 0 deletions examples/cityhash/CMakeLists.txt
@@ -0,0 +1,12 @@
# Run configure to generate the config.h file
execute_process(COMMAND cmake -E chdir ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/configure)

# Add the current directory as an interface library to include
add_library(cityhash_config INTERFACE)
target_include_directories(cityhash_config INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)

# The src subdirectory contains the actual library definition
add_subdirectory(src)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions examples/cityhash/src/CMakeLists.txt
@@ -0,0 +1,2 @@
add_library(cityhash city.cc city.h)
target_link_libraries(cityhash cityhash_config)
File renamed without changes.
File renamed without changes.
24 changes: 21 additions & 3 deletions cityhash-1.1.1/src/city.cc → examples/cityhash/src/city.cc
Expand Up @@ -60,6 +60,24 @@ static uint32 UNALIGNED_LOAD32(const char *p) {
#define bswap_32(x) OSSwapInt32(x)
#define bswap_64(x) OSSwapInt64(x)

#elif defined(__sun) || defined(sun)

#include <sys/byteorder.h>
#define bswap_32(x) BSWAP_32(x)
#define bswap_64(x) BSWAP_64(x)

#elif defined(__FreeBSD__)

#include <sys/endian.h>
#define bswap_32(x) bswap32(x)
#define bswap_64(x) bswap64(x)

#elif defined(__OpenBSD__)

#include <sys/types.h>
#define bswap_32(x) swap32(x)
#define bswap_64(x) swap64(x)

#elif defined(__NetBSD__)

#include <sys/types.h>
Expand Down Expand Up @@ -105,8 +123,8 @@ static const uint64 k1 = 0xb492b66fbe98f273ULL;
static const uint64 k2 = 0x9ae16a3b2f90404fULL;

// Magic numbers for 32-bit hashing. Copied from Murmur3.
static const uint32_t c1 = 0xcc9e2d51;
static const uint32_t c2 = 0x1b873593;
static const uint32 c1 = 0xcc9e2d51;
static const uint32 c2 = 0x1b873593;

// A 32-bit to 32-bit integer hash copied from Murmur3.
static uint32 fmix(uint32 h)
Expand Down Expand Up @@ -152,7 +170,7 @@ static uint32 Hash32Len13to24(const char *s, size_t len) {
static uint32 Hash32Len0to4(const char *s, size_t len) {
uint32 b = 0;
uint32 c = 9;
for (int i = 0; i < len; i++) {
for (size_t i = 0; i < len; i++) {
signed char v = s[i];
b = b * c1 + v;
c ^= b;
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions examples/count_freq.cc
Expand Up @@ -11,8 +11,8 @@
#include <thread>
#include <utility>

#include "../src/cuckoohash_map.hh"
#include "../src/city_hasher.hh"
#include <libcuckoo/cuckoohash_map.hh>
#include <libcuckoo/city_hasher.hh>

typedef uint32_t KeyType;
typedef cuckoohash_map<KeyType, size_t, CityHasher<KeyType> > Table;
Expand Down
4 changes: 2 additions & 2 deletions examples/hellohash.cc
Expand Up @@ -2,8 +2,8 @@
#include <string>
#include <iostream>

#include "../src/cuckoohash_map.hh"
#include "../src/city_hasher.hh"
#include <libcuckoo/cuckoohash_map.hh>
#include <libcuckoo/city_hasher.hh>

int main() {
cuckoohash_map<int, std::string, CityHasher<int> >Table;
Expand Down
2 changes: 1 addition & 1 deletion examples/nested_table.cc
Expand Up @@ -7,7 +7,7 @@
#include <memory>
#include <utility>

#include "../src/cuckoohash_map.hh"
#include <libcuckoo/cuckoohash_map.hh>

typedef cuckoohash_map<std::string, std::string> InnerTable;
typedef cuckoohash_map<std::string, std::unique_ptr<InnerTable>> OuterTable;
Expand Down
26 changes: 26 additions & 0 deletions libcuckoo/CMakeLists.txt
@@ -0,0 +1,26 @@
add_library(libcuckoo INTERFACE)

# Include relative to the base directory
target_include_directories(libcuckoo INTERFACE
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)

# Enable C++11 for all targets that link with libcuckoo
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_options(libcuckoo INTERFACE -std=c++11 -stdlib=libc++)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(libcuckoo INTERFACE -std=gnu++11)
endif()


install(
FILES
city_hasher.hh
cuckoohash_config.hh
cuckoohash_map.hh
cuckoohash_util.hh
lazy_array.hh
DESTINATION
${CMAKE_INSTALL_PREFIX}/include/libcuckoo
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
74 changes: 0 additions & 74 deletions m4/ax_check_compile_flag.m4

This file was deleted.

0 comments on commit dfe7d8d

Please sign in to comment.