diff --git a/CMakeLists.txt b/CMakeLists.txt index 43931e8d3e7e1aeeb98eac5f4543e799b9912278..2ce45baaf229be6fe18efcb6b1cf7a730664a409 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,8 @@ include(CheckCCompilerFlag) include(CheckSymbolExists) include(CheckCSourceRuns) include(CheckCXXSourceRuns) +include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) include(TestBigEndian) include(CheckFunctionExists) diff --git a/README.MacOSX b/README.MacOSX index 0768d19bede37f23bad286b63c0859cadfa8e7da..e9803161e3bbe60dc7cd26601b1891ab5fe9e138 100644 --- a/README.MacOSX +++ b/README.MacOSX @@ -1,3 +1,11 @@ +OS X Readme +=========== + +This manual explains how to manually build tarantool from sources. +If you just need a working binary, please use homebrew: + + brew install http://tarantool.org/dist/tarantool.rb + Target OS: MacOS X "Lion" First of all, make sure mac ports are available (to install packages from). @@ -7,7 +15,13 @@ First of all, make sure mac ports are available (to install packages from). port install autoconf binutils cmake ncurses zlib readline -2. Install necessary python modules: pexpect, pyYAML, daemon +2. Upgrade clang to 3.2+ + +Go to http://developer.apple.com/ to download and install the latest version +of "Command Line Tools for Xcode". This package contains /usr/bin/clang and +/usr/bin/clang++ binaries. Check that clang version is at least 3.2. + +3. Install necessary python modules: pyYAML, daemon ------------- NB: it is recommended to install python modules through setup.py, using the default python (which should be >= 2.6.x and < 3.x); @@ -16,10 +30,10 @@ tar -xzf module.tar.gz cd module-dir sudo python setup.py install -where module is the name of the installed module and module-dir is the name of the directory -the module's archive deflates into. +where module is the name of the installed module and module-dir is the name of +the directory the module's archive deflates into. -3. Download & build tarantool source code: +4. Download & build tarantool source code: ------------- git clone git://github.com/tarantool/tarantool.git @@ -27,7 +41,7 @@ git clone git://github.com/tarantool/tarantool.git cd tarantool CC=clang CXX=clang++ cmake . -DCMAKE_BUILD_TYPE=RelWithDebugInfo -DENABLE_CLIENT=true -4. Run tarantool test suite +5. Run tarantool test suite ------------- NB: the following tests are not runnable on MacOS X at this point: diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 3732a3a06df4642a94b7e23cce71680b55e25677..e1ca97b2791da6afb57cb9ea82b83edafb95296c 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -16,22 +16,28 @@ if (CMAKE_C_COMPILER_ID STREQUAL Clang) set(CMAKE_COMPILER_IS_GNUCXX OFF) endif() -if(CMAKE_COMPILER_IS_GNUCC) - # gcc and g++ >= 4.5 are supported - execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion - OUTPUT_VARIABLE CC_VERSION) - if (CC_VERSION VERSION_LESS 4.5) - message (FATAL_ERROR - "${CMAKE_C_COMPILER} version should be >= 4.5 -- ${CC_VERSION}") - endif() - execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion - OUTPUT_VARIABLE CXX_VERSION) - if (CXX_VERSION VERSION_LESS 4.5) - message (FATAL_ERROR - "${CMAKE_CXX_COMPILER} version should be >= 4.5 -- ${CXX_VERSION}") - endif() +# +# Check supported standards +# +if((NOT HAVE_STD_C11 AND NOT HAVE_STD_GNU99) OR + (NOT HAVE_STD_CXX11 AND NOT HAVE_STD_GNUXX0X)) + set(CMAKE_REQUIRED_FLAGS "-std=c11") + check_c_source_compiles("int main(void) { return 0; }" HAVE_STD_C11) + set(CMAKE_REQUIRED_FLAGS "-std=gnu99") + check_c_source_compiles("int main(void) { return 0; }" HAVE_STD_GNU99) + set(CMAKE_REQUIRED_FLAGS "-std=c++11") + check_cxx_source_compiles("int main(void) { return 0; }" HAVE_STD_CXX11) + set(CMAKE_REQUIRED_FLAGS "-std=gnu++0x") + check_cxx_source_compiles("int main(void) { return 0; }" HAVE_STD_GNUXX0X) + set(CMAKE_REQUIRED_FLAGS "") +endif() +if((NOT HAVE_STD_C11 AND NOT HAVE_STD_GNU99) OR + (NOT HAVE_STD_CXX11 AND NOT HAVE_STD_GNUXX0X)) + message (FATAL_ERROR + "${CMAKE_C_COMPILER} should support -std=c11 or -std=gnu99. " + "${CMAKE_CXX_COMPILER} should support -std=c++11 or -std=gnu++0x. " + "Please consider upgrade to gcc 4.5+ or clang 3.2+.") endif() - # # Perform build type specific configuration. @@ -82,12 +88,15 @@ macro(enable_tnt_compile_flags) # of the code. # Set standard - if (CMAKE_COMPILER_IS_CLANG OR CC_VERSION VERSION_GREATER 4.7 OR - CC_VERSION VERSION_EQUAL 4.7) + if (HAVE_STD_C11) add_compile_flags("C" "-std=c11") - add_compile_flags("CXX" "-std=c++11") else() add_compile_flags("C" "-std=gnu99") + endif() + + if (HAVE_STD_CXX11) + add_compile_flags("CXX" "-std=c++11") + else() add_compile_flags("CXX" "-std=gnu++0x") endif() @@ -112,11 +121,12 @@ macro(enable_tnt_compile_flags) add_definitions("-D__STDC_LIMIT_MACROS=1") add_definitions("-D__STDC_CONSTANT_MACROS=1") - # Only add -Werror if it's a debug build, done by developers using GCC. - # Community builds should not cause extra trouble. - if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND CMAKE_COMPILER_IS_GNUCC) - add_compile_flags("C;CXX" "-Werror") - endif() + # Only add -Werror if it's a debug build, done by developers. + # Release builds should not cause extra trouble. + if ((${CMAKE_BUILD_TYPE} STREQUAL "Debug") + AND HAVE_STD_C11 AND HAVE_STD_CXX11) + add_compile_flags("C;CXX" "-Werror") + endif() endmacro(enable_tnt_compile_flags) # diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe000c8f2b4abfb3e744f0c6301f375784370ae9..efd1e2b148e1dc2740921d72a9a90550a49bf499 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,8 +3,9 @@ # enable_tnt_compile_flags() - -add_subdirectory(plugin) +if (NOT TARGET_OS_DARWIN) + add_subdirectory(plugin) +endif() include_directories(${LIBEV_INCLUDE_DIR}) include_directories(${LIBEIO_INCLUDE_DIR})