Commit 2bb02c83 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

[t:4814] clean up and comment the CMakeLists.txts


git-svn-id: file:///svn/toku/tokudb@43367 c7de825b-a66e-492c-adef-691d508d4ae1
parent a759afe7
cmake_minimum_required(VERSION 2.8.8)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
## this needs to happen before calling project(), when cmake detects some
## basic things about the compiler
include(TokuSetupIntelCompiler)
project(TOKUDB)
project(TokuDB)
include(TokuFeatureDetection)
include(TokuSetupCompiler)
include(TokuSetupCTest)
## lzma
## add lzma with an external project
include(ExternalProject)
set(xz_configure_opts --with-pic)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if (CMAKE_SYSTEM_NAME MATCHES Darwin)
## lzma has some assembly that doesn't work on osx
list(APPEND xz_configure_opts --disable-assembler)
endif()
endif ()
if(${CMAKE_BUILD_TYPE} MATCHES "Release")
if(CMAKE_C_COMPILER_ID MATCHES "Intel")
if (CMAKE_BUILD_TYPE MATCHES Release)
if (CMAKE_C_COMPILER_ID MATCHES Intel)
list(APPEND xz_configure_opts CC=icc "CFLAGS=-O2 -g -ip -ipo1" AR=xiar)
endif()
else()
endif ()
else ()
list(APPEND xz_configure_opts --enable-debug)
endif()
endif ()
if (CMAKE_GENERATOR STREQUAL "Ninja")
if (CMAKE_GENERATOR STREQUAL Ninja)
## ninja doesn't understand "$(MAKE)"
ExternalProject_Add(ep_lzma
PREFIX xz
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xz-4.999.9beta
......@@ -37,6 +41,8 @@ if (CMAKE_GENERATOR STREQUAL "Ninja")
make -C src/liblzma install
)
else ()
## use "$(MAKE)" for submakes so they can use the jobserver, doesn't
## seem to break Xcode...
ExternalProject_Add(ep_lzma
PREFIX xz
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/xz-4.999.9beta
......@@ -55,9 +61,20 @@ add_library(lzma STATIC IMPORTED)
set_target_properties(lzma PROPERTIES IMPORTED_LOCATION
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/xz/lib/liblzma.a")
## everything needs these libraries
link_libraries(dl pthread z)
## need a way to change the name of libs we build
set(LIBTOKUPORTABILITY "tokuportability" CACHE STRING "Name of libtokuportability.so")
set(LIBTOKUDB "tokudb" CACHE STRING "Name of libtokudb.so")
## add an option for cilk
option(USE_CILK "Use cilk in tokudb." OFF)
## can't use cilk without icc
if (USE_CILK AND (NOT CMAKE_C_COMPILER_ID MATCHES Intel))
message(FATAL_ERROR "You specified USE_CILK=ON so you need INTEL_CC=ON.")
endif ()
## default includes and libraries
include_directories(SYSTEM
/usr/local/include
......@@ -67,15 +84,12 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/toku_include
${CMAKE_CURRENT_SOURCE_DIR}/portability
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR} ## so you can include <newbrt/brt.h> from inside src/
)
## include where config.h will be
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/toku_include
)
link_libraries(dl pthread z)
## include where config.h will be generated
include_directories(${CMAKE_CURRENT_BINARY_DIR}/toku_include)
## build db.h and include that directory
## build db.h and include where it will be generated
add_subdirectory(buildheader)
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/buildheader)
......@@ -96,6 +110,7 @@ install(
DESTINATION .
)
## set up lists of sources and headers for tags
file(GLOB_RECURSE all_srcs
include/*.c
toku_include/*.c
......@@ -117,4 +132,5 @@ file(GLOB_RECURSE all_hdrs
db-benchmark-test/*.h
)
## build tags
include(TokuBuildTagDatabases)
find_program(CTAGS "ctags")
if(NOT CTAGS MATCHES "CTAGS-NOTFOUND")
option(USE_CTAGS "Build the ctags database." ON)
if (USE_CTAGS)
find_program(CTAGS "ctags")
if (NOT CTAGS MATCHES NOTFOUND)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/tags"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ctags-stamp"
......@@ -8,10 +10,13 @@ if(NOT CTAGS MATCHES "CTAGS-NOTFOUND")
DEPENDS ${all_srcs} ${all_hdrs} install_tdb_h generate_logging_code generate_config_h
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
add_custom_target(build_ctags ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tags" ctags-stamp)
endif()
endif ()
endif ()
find_program(ETAGS "etags")
if(NOT ETAGS MATCHES "ETAGS-NOTFOUND")
option(USE_ETAGS "Build the etags database." ON)
if (USE_ETAGS)
find_program(ETAGS "etags")
if (NOT ETAGS MATCHES NOTFOUND)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/TAGS"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/etags-stamp"
......@@ -20,10 +25,13 @@ if(NOT ETAGS MATCHES "ETAGS-NOTFOUND")
DEPENDS ${all_srcs} ${all_hdrs} install_tdb_h generate_logging_code generate_config_h
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
add_custom_target(build_etags ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/TAGS" etags-stamp)
endif()
endif ()
endif ()
find_program(CSCOPE "cscope")
if(NOT CSCOPE MATCHES "CSCOPE-NOTFOUND")
option(USE_CSCOPE "Build the cscope database." ON)
if (USE_CSCOPE)
find_program(CSCOPE "cscope")
if (NOT CSCOPE MATCHES NOTFOUND)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/cscope.out"
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/cscope.in.out"
......@@ -35,10 +43,14 @@ if(NOT CSCOPE MATCHES "CSCOPE-NOTFOUND")
"${CMAKE_CURRENT_SOURCE_DIR}/cscope.out"
"${CMAKE_CURRENT_SOURCE_DIR}/cscope.in.out"
"${CMAKE_CURRENT_SOURCE_DIR}/cscope.po.out")
endif()
endif ()
endif ()
find_program(GTAGS "gtags")
if(NOT GTAGS MATCHES "GTAGS-NOTFOUND")
option(USE_GTAGS "Build the gtags database." ON)
if (USE_GTAGS)
find_program(GTAGS "gtags")
if (NOT GTAGS MATCHES NOTFOUND)
## todo: use global -u instead of gtags each time
add_custom_command(
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/GTAGS"
OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/GRTAGS"
......@@ -50,4 +62,5 @@ if(NOT GTAGS MATCHES "GTAGS-NOTFOUND")
"${CMAKE_CURRENT_SOURCE_DIR}/GTAGS"
"${CMAKE_CURRENT_SOURCE_DIR}/GRTAGS"
"${CMAKE_CURRENT_SOURCE_DIR}/GPATH")
endif()
endif ()
endif ()
\ No newline at end of file
## some functions for getting system info to build BUILDNAME
## some functions for getting system info so we can construct BUILDNAME
## given an executable, follows symlinks and resolves paths until it runs
## out of symlinks, then gives you the basename
......@@ -85,18 +85,19 @@ endmacro(get_svn_wc_status)
## gather machine info
uname("-m" machine_type)
real_executable_name("${CMAKE_C_COMPILER}" real_c_compiler)
get_svn_revision("${CMAKE_CURRENT_SOURCE_DIR}" svn_revision)
get_svn_wc_status("${CMAKE_CURRENT_SOURCE_DIR}" wc_status)
get_svn_revision("${CMAKE_CURRENT_SOURCE_DIR}" svn_revision) ## unused since it confuses cdash about history
get_svn_wc_status("${CMAKE_CURRENT_SOURCE_DIR}" wc_status) ## unused since it confuses cdash about history
get_filename_component(branchname "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
## construct BUILDNAME
## construct BUILDNAME, seems to have to happen before include(CTest)
set(BUILDNAME "${branchname} ${CMAKE_BUILD_TYPE} ${CMAKE_SYSTEM} ${machine_type} ${CMAKE_C_COMPILER_ID} ${real_c_compiler} ${CMAKE_C_COMPILER_VERSION}" CACHE STRING "CTest build name" FORCE)
include(CTest)
if(BUILD_TESTING)
if (BUILD_TESTING)
## set up full valgrind suppressions file (concatenate the suppressions files)
file(COPY newbrt/valgrind.suppressions DESTINATION .)
file(READ newbrt/valgrind.suppressions valgrind_suppressions)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${valgrind_suppressions}")
file(READ src/tests/bdb.suppressions bdb_suppressions)
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/valgrind.suppressions" "${bdb_suppressions}")
file(READ bash.suppressions bash_suppressions)
......@@ -106,8 +107,11 @@ if(BUILD_TESTING)
set(CMAKE_HELGRIND_COMMAND_STRING "valgrind --quiet --tool=helgrind --error-exitcode=1 --suppressions=${TOKUDB_SOURCE_DIR}/src/tests/helgrind.suppressions --trace-children=yes --trace-children-skip=sh,*/sh,basename,*/basename,dirname,*/dirname,rm,*/rm,cp,*/cp,mv,*/mv,cat,*/cat,diff,*/diff,test,*/tokudb_dump* --trace-children-skip-by-arg=--only_create,--test,--no-shutdown")
function(add_helgrind_test name)
if (CMAKE_SYSTEM_NAME MATCHES Darwin OR
CMAKE_C_COMPILER_ID MATCHES Intel OR
((CMAKE_C_COMPILER_ID MATCHES Intel) AND
(CMAKE_BUILD_TYPE MATCHES Release)) OR
USE_GCOV)
## can't use helgrind on osx or with optimized intel, no point in
## using it if we're doing coverage
add_test(
NAME ${name}
COMMAND ${ARGN}
......@@ -125,19 +129,22 @@ if(BUILD_TESTING)
set(CMAKE_DRD_COMMAND_STRING "valgrind --quiet --tool=drd --error-exitcode=1 --suppressions=${TOKUDB_SOURCE_DIR}/src/tests/drd.suppressions --trace-children=yes --trace-children-skip=sh,*/sh,basename,*/basename,dirname,*/dirname,rm,*/rm,cp,*/cp,mv,*/mv,cat,*/cat,diff,*/diff,test,*/tokudb_dump* --trace-children-skip-by-arg=--only_create,--test,--no-shutdown")
function(add_drd_test name)
if (CMAKE_SYSTEM_NAME MATCHES Darwin OR
CMAKE_C_COMPILER_ID MATCHES Intel OR
((CMAKE_C_COMPILER_ID MATCHES Intel) AND
(CMAKE_BUILD_TYPE MATCHES Release)) OR
USE_GCOV)
## can't use drd on osx or with optimized intel, no point in
## using it if we're doing coverage
add_test(
NAME ${name}
COMMAND ${ARGN}
)
else()
else ()
separate_arguments(CMAKE_DRD_COMMAND_STRING)
add_test(
NAME ${name}
COMMAND ${CMAKE_DRD_COMMAND_STRING} ${ARGN}
)
endif()
endif ()
endfunction(add_drd_test)
option(RUN_LONG_TESTS "If set, run all tests, even the ones that take a long time to complete." OFF)
......@@ -145,4 +152,4 @@ if(BUILD_TESTING)
option(RUN_PERF_TESTS "If set, run the perf tests." OFF)
configure_file(CTestCustom.cmake . @ONLY)
endif(BUILD_TESTING)
endif (BUILD_TESTING)
......@@ -6,11 +6,11 @@ function(add_c_defines)
endfunction(add_c_defines)
## os name detection (threadpool-test.c needs this)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if (CMAKE_SYSTEM_NAME MATCHES Darwin)
add_c_defines(DARWIN=1 _DARWIN_C_SOURCE)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
elseif (CMAKE_SYSTEM_NAME MATCHES Linux)
add_c_defines(__linux__=1)
endif()
endif ()
## preprocessor definitions we want everywhere
add_c_defines(
......@@ -20,10 +20,10 @@ add_c_defines(
_LARGEFILE64_SOURCE
)
if(CMAKE_SYSTEM_NAME MATCHES Darwin)
if (CMAKE_SYSTEM_NAME MATCHES Darwin)
message(WARNING "Setting TOKU_ALLOW_DEPRECATED on Darwin. TODO: remove this.")
add_c_defines(TOKU_ALLOW_DEPRECATED)
endif()
endif ()
## coverage
option(USE_GCOV "Use gcov for test coverage." OFF)
......@@ -33,6 +33,9 @@ if (USE_GCOV)
endif ()
endif (USE_GCOV)
## this function makes sure that the libraries passed to it get compiled
## with gcov-needed flags, we only add those flags to our libraries
## because we don't really care whether our tests get covered
function(maybe_add_gcov_to_libraries)
if (USE_GCOV)
foreach(lib ${ARGN})
......@@ -55,41 +58,46 @@ endfunction(maybe_add_gcov_to_libraries)
include(CheckCCompilerFlag)
## disable some warnings, if we can
function(set_flag_if_exists flag)
## adds a compiler flag if the compiler supports it
function(set_cflags_if_supported)
foreach(flag ${ARGN})
check_c_compiler_flag(${flag} HAVE_${flag})
if(HAVE_${flag})
if (HAVE_${flag})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
endif()
endif ()
endforeach(flag)
endfunction(set_flag_if_exists)
foreach(flag -Wno-self-assign -Wno-missing-field-initializers -Wno-maybe-uninitialized)
set_flag_if_exists(${flag})
endforeach(flag)
## disable some warnings
set_cflags_if_supported(
-Wno-self-assign
-Wno-missing-field-initializers
-Wno-maybe-uninitialized
)
## set extra debugging flags and preprocessor definitions
set(CMAKE_C_FLAGS_DEBUG "-g3 -ggdb -O0")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g3 -ggdb -O0")
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_DEBUG FORTIFY_SOURCE=2)
## set extra release flags
set(CMAKE_C_FLAGS_RELEASE "-O3")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
## check how to do inter-procedural optimization
check_c_compiler_flag(-flto HAVE_CC_FLAG_FLTO)
check_c_compiler_flag(-ipo HAVE_CC_FLAG_IPO)
## add inter-procedural optimization flags
if(HAVE_CC_FLAG_FLTO)
if (HAVE_CC_FLAG_FLTO)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto")
elseif(HAVE_CC_FLAG_IPO)
elseif (HAVE_CC_FLAG_IPO)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ip -ipo1")
endif()
endif ()
if(CMAKE_C_COMPILER_ID MATCHES "^Intel$")
# make sure intel libs are linked statically
if (CMAKE_C_COMPILER_ID MATCHES Intel)
## make sure intel libs are linked statically
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-intel")
# disable some intel-specific warnings
## disable some intel-specific warnings
set(intel_warnings
94 # allow arrays of length 0
589 # do not complain about goto that skips initialization
......@@ -101,15 +109,33 @@ if(CMAKE_C_COMPILER_ID MATCHES "^Intel$")
)
string(REGEX REPLACE ";" "," intel_warning_string "${intel_warnings}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -diag-disable ${intel_warning_string}")
## icc does -g differently
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -debug all")
set(EXTRA_CFLAGS "-Wall -Wcheck")
## set icc warnings
set(WARN_CFLAGS
-Wall
-Wcheck ## icc version of -Wextra
)
else()
set(EXTRA_CFLAGS "-Wall -Wextra -Wcast-align -Wbad-function-cast -Wno-missing-noreturn -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wmissing-format-attribute -Wshadow")
## set gcc warnings
set(WARN_CFLAGS
-Wall
-Wextra
-Wcast-align
-Wbad-function-cast
-Wno-missing-noreturn
-Wstrict-prototypes
-Wmissing-prototypes
-Wmissing-declarations
-Wpointer-arith
-Wmissing-format-attribute
-Wshadow
)
endif()
## default warning levels
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
set_cflags_if_supported(${WARN_CFLAGS})
## function for adding -fvisibility=hidden to targets
function(set_targets_visibility_hidden)
......
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
option(USE_CILK "Use cilk in tokudb." OFF)
## can't use cilk without icc
if(USE_CILK AND NOT(CMAKE_C_COMPILER_ID MATCHES Intel))
message(FATAL_ERROR "You specified USE_CILK=ON so you need to use an Intel compiler.")
endif()
## generate log_code.c, log_print.c, log_header.c
## TODO: generate these in the build directory instead
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/log_code.c PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/log_print.c PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/log_header.h PROPERTIES GENERATED TRUE)
......@@ -78,6 +72,7 @@ set(BRT_SOURCES
add_library(newbrt SHARED ${BRT_SOURCES})
add_library(newbrt_static STATIC ${BRT_SOURCES})
## we're going to link this into libtokudb.so so it needs to have PIC
set_property(TARGET newbrt_static APPEND PROPERTY COMPILE_FLAGS "-fPIC")
maybe_add_gcov_to_libraries(newbrt newbrt_static)
......@@ -85,11 +80,14 @@ maybe_add_gcov_to_libraries(newbrt newbrt_static)
add_dependencies(newbrt install_tdb_h build_lzma)
add_dependencies(newbrt_static install_tdb_h build_lzma)
## link with lzma (which should be static)
## link with tokuportability, and lzma (which should be static)
target_link_libraries(newbrt ${LIBTOKUPORTABILITY} lzma)
target_link_libraries(newbrt_static ${LIBTOKUPORTABILITY} lzma)
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
if (CMAKE_C_COMPILER_ID STREQUAL Intel)
## don't link with default libs, those come with tokuportability, but we
## do need libc and we need the intel libirc (and it should be static to
## be redistributable)
target_link_libraries(newbrt -nodefaultlibs c -Bstatic irc -Bdynamic)
endif ()
......
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE)
if(BUILD_TESTING)
## get a list of the sources in this directory
file(GLOB srcs RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" *.c)
## these are generated by some tests, we need to remember to clean them
## up
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES
foo1.brt foo2.brt foo3.brt foo4.brt
bar1.brt bar2.brt bar3.brt bar4.brt
test-dump-brt.out)
## this macro will remove the test from the list of source files so it
## doesn't end up getting the default test rule applied to it
macro(declare_custom_tests)
foreach(source ${ARGN})
list(REMOVE_ITEM srcs ${source})
......@@ -19,7 +24,7 @@ if(BUILD_TESTING)
add_test(logcursor-bw echo "logcursor-bw must be run manually (needs logs to iterate over).")
foreach(src ${srcs})
if(NOT "${src}" MATCHES "dir[.].*[.]c")
if(NOT "${src}" MATCHES "dir[.].*[.]c") ## annoying
get_filename_component(base ${src} NAME_WE)
add_executable(${base} ${src})
target_link_libraries(${base} newbrt ${LIBTOKUPORTABILITY})
......@@ -28,10 +33,16 @@ if(BUILD_TESTING)
file(GLOB log_tests RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" log-test*.c)
foreach(src ${log_tests})
## these tests use -Ddname=foo to decide where to put their data, if
## we don't specify it, it defaults to "dir."__FILE__ which with cmake
## is going to be an absolute path with "dir." in front, and that's
## not a valid path
set_property(SOURCE ${src} APPEND PROPERTY
COMPILE_DEFINITIONS "dname=\"${src}\"")
endforeach(src)
## declare some tests that should be run with specific options
declare_custom_tests(test-assert.c)
add_test(test-assertA test-assert)
add_test(test-assertB test-assert notok)
......@@ -93,6 +104,7 @@ if(BUILD_TESTING)
foreach(src ${srcs})
if(NOT "${src}" MATCHES "dir[.].*[.]c")
## add a default test rule that runs with no options
get_filename_component(base ${src} NAME_WE)
add_test(${base} ${base})
endif()
......
......@@ -19,24 +19,31 @@ set(tokudb_srcs
elocks.c
)
## make the shared library
add_library(${LIBTOKUDB} SHARED ${tokudb_srcs})
add_dependencies(${LIBTOKUDB} generate_logging_code install_tdb_h)
target_link_libraries(${LIBTOKUDB} lock_tree_static range_tree_static newbrt_static)
## make the static library
add_library(${LIBTOKUDB}_static STATIC ${tokudb_srcs})
add_dependencies(${LIBTOKUDB}_static generate_logging_code install_tdb_h)
target_link_libraries(${LIBTOKUDB}_static lock_tree_static range_tree_static newbrt_static)
## add a version script and set -fvisibility=hidden for the shared library
configure_file(export.map . COPYONLY)
get_target_property(link_flags ${LIBTOKUDB} LINK_FLAGS)
set_target_properties(${LIBTOKUDB} PROPERTIES
LINK_FLAGS "${LINK_FLAGS} -Wl,--version-script=export.map")
set_targets_visibility_hidden(${LIBTOKUDB})
add_library(${LIBTOKUDB}_static STATIC ${tokudb_srcs})
add_dependencies(${LIBTOKUDB}_static generate_logging_code install_tdb_h)
target_link_libraries(${LIBTOKUDB}_static lock_tree_static range_tree_static newbrt_static)
set_targets_visibility_hidden(${LIBTOKUDB} ${LIBTOKUDB}_static)
## add gcov and define _GNU_SOURCE
maybe_add_gcov_to_libraries(${LIBTOKUDB} ${LIBTOKUDB}_static)
set_property(TARGET ${LIBTOKUDB} ${LIBTOKUDB}_static APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE)
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
if (CMAKE_C_COMPILER_ID STREQUAL Intel)
## don't link with default libs, those come with tokuportability, but we
## do need libc and we need the intel libirc (and it should be static to
## be redistributable)
target_link_libraries(${LIBTOKUDB} -nodefaultlibs c -Bstatic irc -Bdynamic)
endif ()
......
......@@ -2,17 +2,18 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(lock_tree_srcs locktree.c idlth.c lth.c rth.c txnid_set.c wfg.c)
## make the linear library
add_library(lock_tree_lin_static STATIC ${lock_tree_srcs})
set_property(TARGET lock_tree_lin_static APPEND PROPERTY
COMPILE_FLAGS "-fPIC")
add_dependencies(lock_tree_lin_static install_tdb_h)
## make the log library
add_library(lock_tree_tlog_static STATIC ${lock_tree_srcs})
set_property(TARGET lock_tree_tlog_static APPEND PROPERTY
COMPILE_FLAGS "-fPIC")
set_property(TARGET lock_tree_tlog_static APPEND PROPERTY
COMPILE_DEFINITIONS TOKU_RT_NOOVERLAPS)
add_dependencies(lock_tree_tlog_static install_tdb_h)
## make the real library, it's going to go into libtokudb.so so it needs
## to be PIC
add_library(lock_tree_static STATIC ${lock_tree_srcs})
set_property(TARGET lock_tree_static APPEND PROPERTY
COMPILE_FLAGS "-fPIC")
......
......@@ -4,6 +4,8 @@ if(BUILD_TESTING)
get_filename_component(base ${src} NAME_WE)
foreach(impl lin tlog)
## each source file test_foo.c creates binaries lt_test_foo.lin and
## lt_test_foo.tlog
add_executable(lt_${base}.${impl} ${src})
set_property(TARGET lt_${base}.${impl} APPEND PROPERTY
COMPILE_DEFINITIONS "TESTDIR=\"dir.${base}.c.${impl}\"")
......@@ -22,6 +24,9 @@ if(BUILD_TESTING)
COMPILE_DEFINITIONS TOKU_RT_NOOVERLAPS)
endforeach(src)
## run test_footprint_point_write.c and test_footprint_range_write.c in
## a bunch of different ways.
## TODO: add lt_ prefix to test names
foreach(impl lin tlog)
foreach(type point range)
foreach(i 1 2)
......
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
## make the linear library
add_library(range_tree_lin_static STATIC linear.c)
set_property(TARGET range_tree_lin_static APPEND PROPERTY
COMPILE_FLAGS "-fPIC")
add_dependencies(range_tree_lin_static install_tdb_h)
## make the log library
add_library(range_tree_tlog_static STATIC log_nooverlap.c)
set_property(TARGET range_tree_tlog_static APPEND PROPERTY
COMPILE_FLAGS "-fPIC")
add_dependencies(range_tree_tlog_static install_tdb_h)
## make the real library, it's going to go into libtokudb.so so it needs
## to be PIC
add_library(range_tree_static STATIC log_nooverlap.c)
set_property(TARGET range_tree_static APPEND PROPERTY
COMPILE_FLAGS "-fPIC")
set_property(SOURCE log_nooverlap.c APPEND PROPERTY LABELS RUN_GCOV)
add_dependencies(range_tree_static install_tdb_h)
maybe_add_gcov_to_libraries(range_tree_lin_static range_tree_tlog_static range_tree_static)
......
......@@ -4,6 +4,8 @@ if(BUILD_TESTING)
get_filename_component(base ${src} NAME_WE)
foreach(impl lin tlog)
## each source file test_foo.c creates binaries rt_test_foo.lin and
## rt_test_foo.tlog
add_executable(rt_${base}.${impl} ${src})
set_property(TARGET rt_${base}.${impl} APPEND PROPERTY
COMPILE_DEFINITIONS "TESTDIR=\"dir.${base}.c.${impl}\"")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment