Commit 00686e6d authored by Sergei Golubchik's avatar Sergei Golubchik

cmake fixes for tokudb

cmake/jemalloc.cmake:
  for dependencies to work, LIBJEMALLOC should be the target name, not the path
storage/tokudb/CMakeLists.txt:
  * check the preconditions
  * disable bdb tests (compilation errors)
  * set variable, instead of SET_PROPERTY. same effect,
    but doesn't fail when a plugin is disabled (that is, a target does not exist)
storage/tokudb/ft-index/CMakeLists.txt:
  cmake should not look into examples/ directory,
  there is hand-crafted examples/Makefile that
  cmake will overwrite
storage/tokudb/ft-index/buildheader/CMakeLists.txt:
  the syntax is ADD_EXECUTABLE(target source) and "source" is the file name
storage/tokudb/ft-index/cmake_modules/TokuMergeLibs.cmake:
  Libraries must be specified in the specific order,
  REMOVE_DUPLICATES cannot be used, because it destroys this order.
  
  (when OSLIBS contains "-lpthread -ljemalloc -lpthread", REMOVE_DUPLICATES
  makes it "-lpthread -ljemalloc". But a thread library *must* be *after* jemalloc)
storage/tokudb/ft-index/cmake_modules/TokuSetupCTest.cmake:
  * 'which' might print errors to stderr, they are not important, shut them up
  * we don't have TOKUDB_DATA, no need to warn about it
  * don't configure_file into itself (with input=output)
storage/tokudb/ft-index/cmake_modules/TokuThirdParty.cmake:
  jemalloc is built externally to tokudb/ft-index
storage/tokudb/ft-index/ft/CMakeLists.txt:
  the syntax is ADD_EXECUTABLE(target source) and "source" is the file name
storage/tokudb/ft-index/ft/tests/CMakeLists.txt:
  the syntax is ADD_EXECUTABLE(target source) and "source" is the file name
storage/tokudb/ft-index/locktree/tests/CMakeLists.txt:
  the syntax is ADD_EXECUTABLE(target source) and "source" is the file name
storage/tokudb/ft-index/portability/CMakeLists.txt:
  s/jemalloc/libjemalloc/
storage/tokudb/ft-index/portability/os_malloc.cc:
  unnecessary include file
storage/tokudb/ft-index/portability/tests/CMakeLists.txt:
  the syntax is ADD_EXECUTABLE(target source) and "source" is the file name
storage/tokudb/ft-index/src/tests/CMakeLists.txt:
  the syntax is ADD_EXECUTABLE(target source) and "source" is the file name
storage/tokudb/ft-index/util/tests/CMakeLists.txt:
  the syntax is ADD_EXECUTABLE(target source) and "source" is the file name
storage/tokudb/ft-index/utils/CMakeLists.txt:
  the syntax is ADD_EXECUTABLE(target source) and "source" is the file name
parent a8fc90a1
......@@ -3,7 +3,7 @@ INCLUDE(ExternalProject)
MACRO (USE_BUNDLED_JEMALLOC)
SET(SOURCE_DIR "${CMAKE_SOURCE_DIR}/extra/jemalloc")
SET(BINARY_DIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/extra/jemalloc/build")
SET(LIBJEMALLOC "${BINARY_DIR}/lib/libjemalloc_pic.a")
SET(LIBJEMALLOC "libjemalloc")
SET(JEMALLOC_CONFIGURE_OPTS "CC=${CMAKE_C_COMPILER}" "--with-private-namespace=jemalloc_internal_" "--enable-cc-silence")
IF (CMAKE_BUILD_TYPE MATCHES "Debug" AND NOT APPLE) # see the comment in CMakeLists.txt
LIST(APPEND JEMALLOC_CONFIGURE_OPTS --enable-debug)
......@@ -18,7 +18,7 @@ MACRO (USE_BUNDLED_JEMALLOC)
INSTALL_COMMAND ""
)
ADD_LIBRARY(libjemalloc STATIC IMPORTED)
SET_TARGET_PROPERTIES(libjemalloc PROPERTIES IMPORTED_LOCATION ${LIBJEMALLOC})
SET_TARGET_PROPERTIES(libjemalloc PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/lib/libjemalloc_pic.a")
ADD_DEPENDENCIES(libjemalloc jemalloc)
ENDMACRO()
......
......@@ -102,8 +102,8 @@ ADD_LIBRARY(sql STATIC ${SQL_SOURCE})
ADD_DEPENDENCIES(sql GenServerSource)
DTRACE_INSTRUMENT(sql)
TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
mysys dbug strings vio regex
${LIBWRAP} ${LIBCRYPT} ${LIBDL} ${LIBJEMALLOC} ${CMAKE_THREAD_LIBS_INIT}
mysys dbug strings vio regex ${LIBJEMALLOC}
${LIBWRAP} ${LIBCRYPT} ${LIBDL} ${CMAKE_THREAD_LIBS_INIT}
${SSL_LIBRARIES})
IF(WIN32)
......
# ft-index can be compiled only with gcc-4.7+, cmake-2.8.8+
# and supports only x86-64 platform
IF(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
CMAKE_VERSION VERSION_LESS "2.8.8" OR
NOT CMAKE_COMPILER_IS_GNUCXX OR
CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
IF (NOT WITHOUT_TOKUDB)
MESSAGE("TokuDB is disabled: not supported
(${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_VERSION}-<${CMAKE_COMPILER_IS_GNUCXX}>-${CMAKE_CXX_COMPILER_VERSION}")
ENDIF()
RETURN()
ENDIF()
SET(ENV{TOKUDB_VERSION} "7.0.2")
SET(USE_BDB OFF CACHE BOOL "")
############################################
IF(DEFINED ENV{TOKUDB_VERSION})
SET(TOKUDB_VERSION $ENV{TOKUDB_VERSION})
ADD_DEFINITIONS("-DTOKUDB_VERSION=\"${TOKUDB_VERSION}\"")
......@@ -24,4 +40,4 @@ SET(TOKUDB_PLUGIN_DYNAMIC "ha_tokudb")
SET(TOKUDB_SOURCES ha_tokudb.cc)
MYSQL_ADD_PLUGIN(tokudb ${TOKUDB_SOURCES} STORAGE_ENGINE MODULE_ONLY
LINK_LIBRARIES tokufractaltree_static tokuportability_static z stdc++)
SET_PROPERTY(TARGET tokudb APPEND PROPERTY LINK_FLAGS_RELEASE "-flto -fuse-linker-plugin")
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto -fuse-linker-plugin")
......@@ -53,7 +53,7 @@ add_subdirectory(utils)
## subdirectories that just install things
add_subdirectory(include)
add_subdirectory(toku_include)
add_subdirectory(examples)
#add_subdirectory(examples)
install(
FILES README.md README-TOKUDB
......
......@@ -4,7 +4,7 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/runcat.sh" "#!/bin/bash
out=$1; shift
exec \"$@\" >$out")
add_executable(make_tdb make_tdb)
add_executable(make_tdb make_tdb.cc)
set_property(TARGET make_tdb APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/db.h"
......@@ -24,4 +24,4 @@ if (NOT DEFINED MYSQL_PROJECT_NAME_DOCSTRING)
FILES "${CMAKE_CURRENT_BINARY_DIR}/db.h"
DESTINATION include
)
endif ()
\ No newline at end of file
endif ()
......@@ -49,7 +49,7 @@ MACRO(TOKU_MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
ENDIF()
ENDFOREACH()
IF(OSLIBS)
LIST(REMOVE_DUPLICATES OSLIBS)
#LIST(REMOVE_DUPLICATES OSLIBS)
TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS})
ENDIF()
......
......@@ -9,6 +9,7 @@ macro(real_executable_name filename_input out)
execute_process(
COMMAND which ${filename}
RESULT_VARIABLE res
ERROR_QUIET
OUTPUT_VARIABLE full_filename
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT(res))
......@@ -84,7 +85,7 @@ include(CTest)
set(TOKUDB_DATA "${TokuDB_SOURCE_DIR}/../tokudb.data" CACHE FILEPATH "Path to data files for tests")
if (BUILD_TESTING OR BUILD_FT_TESTS OR BUILD_SRC_TESTS)
set(WARNED_ABOUT_DATA 0)
set(WARNED_ABOUT_DATA 1) # disable the warning below
if (NOT EXISTS "${TOKUDB_DATA}/" AND NOT WARNED_ABOUT_DATA)
message(WARNING "Test data files are missing from ${TOKUDB_DATA}, which will cause some tests to fail. Please put them there or modify TOKUDB_DATA to avoid this.")
set(WARNED_ABOUT_DATA 1)
......@@ -152,5 +153,5 @@ if (BUILD_TESTING OR BUILD_FT_TESTS OR BUILD_SRC_TESTS)
option(RUN_STRESS_TESTS "If set, run the stress tests." OFF)
option(RUN_PERF_TESTS "If set, run the perf tests." OFF)
configure_file(CTestCustom.cmake . @ONLY)
configure_file(CTestCustom.cmake.in CTestCustom.cmake @ONLY)
endif (BUILD_TESTING OR BUILD_FT_TESTS OR BUILD_SRC_TESTS)
include(ExternalProject)
## add jemalloc with an external project
set(JEMALLOC_SOURCE_DIR "${TokuDB_SOURCE_DIR}/third_party/jemalloc" CACHE FILEPATH "Where to find jemalloc sources.")
if (NOT EXISTS "${JEMALLOC_SOURCE_DIR}/configure")
message(FATAL_ERROR "Can't find jemalloc sources. Please check them out to ${JEMALLOC_SOURCE_DIR} or modify JEMALLOC_SOURCE_DIR.")
endif ()
set(jemalloc_configure_opts "CC=${CMAKE_C_COMPILER}" "--with-jemalloc-prefix=" "--with-private-namespace=tokudb_jemalloc_internal_" "--enable-cc-silence")
option(JEMALLOC_DEBUG "Build jemalloc with --enable-debug." OFF)
if (JEMALLOC_DEBUG)
list(APPEND jemalloc_configure_opts --enable-debug)
endif ()
ExternalProject_Add(build_jemalloc
PREFIX jemalloc
SOURCE_DIR "${JEMALLOC_SOURCE_DIR}"
CONFIGURE_COMMAND
"${JEMALLOC_SOURCE_DIR}/configure" ${jemalloc_configure_opts}
"--prefix=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc"
)
add_library(jemalloc STATIC IMPORTED GLOBAL)
set_target_properties(jemalloc PROPERTIES IMPORTED_LOCATION
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc/lib/libjemalloc_pic.a")
add_dependencies(jemalloc build_jemalloc)
add_library(jemalloc_nopic STATIC IMPORTED GLOBAL)
set_target_properties(jemalloc_nopic PROPERTIES IMPORTED_LOCATION
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc/lib/libjemalloc.a")
add_dependencies(jemalloc_nopic build_jemalloc)
# detect when we are being built as a subproject
if (NOT DEFINED MYSQL_PROJECT_NAME_DOCSTRING)
install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/jemalloc/lib"
DESTINATION .
)
endif ()
## add lzma with an external project
set(xz_configure_opts --with-pic --enable-static)
if (APPLE)
......
......@@ -92,7 +92,7 @@ target_link_libraries(ft_static LINK_PRIVATE lzma)
## build the bins in this directory
foreach(tool tokuftdump tdb_logprint tdb-recover ftverify)
add_executable(${tool} ${tool})
add_executable(${tool} ${tool}.cc)
add_dependencies(${tool} install_tdb_h)
target_link_libraries(${tool} ft_static util_static z lzma ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
add_space_separated_property(TARGET ${tool} COMPILE_FLAGS -fvisibility=hidden)
......
......@@ -29,7 +29,7 @@ if(BUILD_TESTING OR BUILD_FT_TESTS)
add_test(ft/logcursor-bw echo "logcursor-bw must be run manually (needs logs to iterate over).")
foreach(test ${tests})
add_executable(${test} ${test})
add_executable(${test} ${test}.cc)
target_link_libraries(${test} ft ${LIBTOKUPORTABILITY})
set_target_properties(${test} PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_space_separated_property(TARGET ${test} COMPILE_FLAGS -fvisibility=hidden)
......
......@@ -7,7 +7,7 @@ if(BUILD_TESTING)
foreach(src ${srcs})
get_filename_component(base ${src} NAME_WE)
add_executable(${base} ${base})
add_executable(${base} ${base}.cc)
add_space_separated_property(TARGET ${base} COMPILE_FLAGS -fvisibility=hidden)
target_link_libraries(${base} locktree ft ${LIBTOKUPORTABILITY})
add_locktree_test(${base})
......
......@@ -15,13 +15,12 @@ set(tokuportability_srcs
)
add_library(${LIBTOKUPORTABILITY} SHARED ${tokuportability_srcs})
target_link_libraries(${LIBTOKUPORTABILITY} LINK_PRIVATE jemalloc)
target_link_libraries(${LIBTOKUPORTABILITY} LINK_PRIVATE ${LIBJEMALLOC})
target_link_libraries(${LIBTOKUPORTABILITY} LINK_PUBLIC ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
add_library(tokuportability_static_conv STATIC ${tokuportability_srcs})
set_target_properties(tokuportability_static_conv PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_dependencies(tokuportability_static_conv build_jemalloc)
set(tokuportability_source_libs tokuportability_static_conv jemalloc ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
set(tokuportability_source_libs tokuportability_static_conv ${LIBJEMALLOC} ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
toku_merge_static_libs(${LIBTOKUPORTABILITY}_static ${LIBTOKUPORTABILITY}_static "${tokuportability_source_libs}")
maybe_add_gcov_to_libraries(${LIBTOKUPORTABILITY} tokuportability_static_conv)
......
......@@ -92,7 +92,7 @@ PATENT RIGHTS GRANT:
#include <toku_portability.h>
#include <stdlib.h>
#include <jemalloc/include/jemalloc/jemalloc.h>
//#include <jemalloc/include/jemalloc/jemalloc.h>
#if defined(HAVE_MALLOC_H)
# include <malloc.h>
#elif defined(HAVE_SYS_MALLOC_H)
......
......@@ -10,7 +10,7 @@ if(BUILD_TESTING)
foreach(src ${srcs})
get_filename_component(test ${src} NAME_WE)
add_executable(${test} ${test})
add_executable(${test} ${test}.cc)
target_link_libraries(${test} ${LIBTOKUPORTABILITY})
set_target_properties(${test} PROPERTIES POSITION_INDEPENDENT_CODE ON)
add_space_separated_property(TARGET ${test} COMPILE_FLAGS -fvisibility=hidden)
......
......@@ -359,7 +359,7 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
## #5138 only reproduces when using the static library.
list(REMOVE_ITEM tdb_bins test-5138.tdb)
add_executable(test-5138.tdb test-5138)
add_executable(test-5138.tdb test-5138.cc)
target_link_libraries(test-5138.tdb ${LIBTOKUDB}_static z ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
set_property(TARGET test-5138.tdb APPEND PROPERTY
COMPILE_DEFINITIONS "USE_TDB;IS_TDB=1;TOKUDB=1")
......@@ -369,7 +369,7 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
foreach(bin ${tdb_bins})
get_filename_component(base ${bin} NAME_WE)
add_executable(${base}.tdb ${base})
add_executable(${base}.tdb ${base}.cc)
# Some of the symbols in util may not be exported properly by
# libtokudb.so.
# We link the test with util directly so that the test code itself can use
......@@ -384,7 +384,7 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
foreach(bin ${bdb_bins})
get_filename_component(base ${bin} NAME_WE)
add_executable(${base}.bdb ${base})
add_executable(${base}.bdb ${base}.cc)
set_property(TARGET ${base}.bdb APPEND PROPERTY
COMPILE_DEFINITIONS "USE_BDB;IS_TDB=0;TOKU_ALLOW_DEPRECATED")
set_target_properties(${base}.bdb PROPERTIES
......
......@@ -6,7 +6,7 @@ if(BUILD_TESTING)
endforeach(src)
foreach(test ${tests})
add_executable(${test} ${test})
add_executable(${test} ${test}.cc)
target_link_libraries(${test} util ${LIBTOKUPORTABILITY})
endforeach(test)
......
......@@ -2,7 +2,7 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE DONT_DEPR
set(utils tokudb_gen tokudb_load tokudb_dump)
foreach(util ${utils})
add_executable(${util} ${util})
add_executable(${util} ${util}.cc)
set_target_properties(${util} PROPERTIES
COMPILE_DEFINITIONS "IS_TDB=1;USE_TDB=1;TDB_IS_STATIC=1")
target_link_libraries(${util} ${LIBTOKUDB}_static ft_static z lzma ${LIBTOKUPORTABILITY}_static ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_SYSTEM_LIBS})
......
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