2013-04-17 00:00:43 -04:00
# TODO(leif): will need to be smarter about this when we do trunk/tags/branches
2013-04-17 00:01:20 -04:00
set ( TOKU_SVNROOT "${TokuDB_SOURCE_DIR}/../.." CACHE FILEPATH "The top of the tokudb source tree, usod to find xz sources, jemalloc sources, test data files, etc." )
2013-04-17 00:00:43 -04:00
include ( ExternalProject )
2013-04-17 00:01:20 -04:00
## add jemalloc with an external project
set ( JEMALLOC_SOURCE_DIR "${TOKU_SVNROOT}/jemalloc-3.2.0" 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 TOKU_SVNROOT (${TOKU_SVNROOT}) or JEMALLOC_SOURCE_DIR." )
endif ( )
2013-04-17 00:01:21 -04:00
set ( jemalloc_configure_opts "CC=${CMAKE_C_COMPILER}" "--with-jemalloc-prefix=" "--with-private-namespace=tokudb_jemalloc_internal_" "--enable-cc-silence" )
2013-04-17 00:01:20 -04:00
if ( NOT CMAKE_BUILD_TYPE MATCHES Release )
list ( APPEND jemalloc_configure_opts --enable-debug )
endif ( )
2013-04-17 00:01:20 -04:00
ExternalProject_Add ( build_jemalloc
P R E F I X j e m a l l o c
S O U R C E _ D I R " $ { J E M A L L O C _ S O U R C E _ D I R } "
C O N F I G U R E _ C O M M A N D
2013-04-17 00:01:20 -04:00
" $ { J E M A L L O C _ S O U R C E _ D I R } / c o n f i g u r e " $ { j e m a l l o c _ c o n f i g u r e _ o p t s }
2013-04-17 00:01:20 -04:00
" - - p r e f i x = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / j e m a l l o c "
)
add_library ( jemalloc STATIC IMPORTED )
set_target_properties ( jemalloc PROPERTIES IMPORTED_LOCATION
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / j e m a l l o c / l i b / l i b j e m a l l o c _ p i c . a " )
add_dependencies ( jemalloc build_jemalloc )
## add lzma with an external project
2013-04-17 00:01:07 -04:00
set ( xz_configure_opts --with-pic --enable-static )
if ( APPLE )
## lzma has some assembly that doesn't work on darwin
2013-04-17 00:00:43 -04:00
list ( APPEND xz_configure_opts --disable-assembler )
endif ( )
2013-04-17 00:00:50 -04:00
list ( APPEND xz_configure_opts CC= ${ CMAKE_C_COMPILER } )
2013-04-17 00:01:07 -04:00
if ( NOT CMAKE_BUILD_TYPE MATCHES Release )
2013-04-17 00:00:43 -04:00
list ( APPEND xz_configure_opts --enable-debug )
endif ( )
2013-04-17 00:01:20 -04:00
set ( XZ_SOURCE_DIR "${TOKU_SVNROOT}/xz-4.999.9beta" CACHE FILEPATH "Where to find sources for xz (lzma)." )
2013-04-17 00:00:43 -04:00
if ( NOT EXISTS "${XZ_SOURCE_DIR}/configure" )
2013-04-17 00:01:20 -04:00
message ( FATAL_ERROR "Can't find the xz sources. Please check them out to ${XZ_SOURCE_DIR} or modify TOKU_SVNROOT (${TOKU_SVNROOT}) or XZ_SOURCE_DIR." )
2013-04-17 00:00:43 -04:00
endif ( )
if ( CMAKE_GENERATOR STREQUAL Ninja )
## ninja doesn't understand "$(MAKE)"
2013-04-17 00:01:10 -04:00
ExternalProject_Add ( build_lzma
2013-04-17 00:00:43 -04:00
P R E F I X x z
S O U R C E _ D I R " $ { X Z _ S O U R C E _ D I R } "
C O N F I G U R E _ C O M M A N D
" $ { X Z _ S O U R C E _ D I R } / c o n f i g u r e " $ { x z _ c o n f i g u r e _ o p t s }
" - - p r e f i x = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z "
B U I L D _ C O M M A N D
m a k e - C s r c / l i b l z m a
I N S T A L L _ C O M M A N D
m a k e - C s r c / l i b l z m a i n s t a l l
)
else ( )
## use "$(MAKE)" for submakes so they can use the jobserver, doesn't
## seem to break Xcode...
2013-04-17 00:01:10 -04:00
ExternalProject_Add ( build_lzma
2013-04-17 00:00:43 -04:00
P R E F I X x z
S O U R C E _ D I R " $ { X Z _ S O U R C E _ D I R } "
C O N F I G U R E _ C O M M A N D
" $ { X Z _ S O U R C E _ D I R } / c o n f i g u r e " $ { x z _ c o n f i g u r e _ o p t s }
" - - p r e f i x = $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z "
B U I L D _ C O M M A N D
$ ( M A K E ) - C s r c / l i b l z m a
I N S T A L L _ C O M M A N D
$ ( M A K E ) - C s r c / l i b l z m a i n s t a l l
)
endif ( )
2013-04-17 00:00:47 -04:00
set_source_files_properties (
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / b a s e . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / b c j . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / b l o c k . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / c h e c k . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / c o n t a i n e r . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / d e l t a . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / f i l t e r . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / i n d e x . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / i n d e x _ h a s h . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / l z m a . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / s t r e a m _ f l a g s . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / s u b b l o c k . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / v e r s i o n . h "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / i n c l u d e / l z m a / v l i . h "
P R O P E R T I E S G E N E R A T E D T R U E )
include_directories ( "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/xz/include" )
2013-04-17 00:00:43 -04:00
add_library ( lzma STATIC IMPORTED )
set_target_properties ( lzma PROPERTIES IMPORTED_LOCATION
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / x z / l i b / l i b l z m a . a " )
2013-04-17 00:01:10 -04:00
add_dependencies ( lzma build_lzma )