Make Windows dep switches compatible with other builds

Summary:
Make dependacies switches compatible with other OS builds
  TODO: Make find_package work for Windows.
Closes https://github.com/facebook/rocksdb/pull/3322

Differential Revision: D6667637

Pulled By: sagar0

fbshipit-source-id: 5afcd7bbfe69465310a4fbc8e589f01e506b95f5
main
Dmitri Smirnov 7 years ago committed by Facebook Github Bot
parent 90c1d81975
commit 84ddbd186a
  1. 30
      CMakeLists.txt
  2. 2
      appveyor.yml
  3. 63
      thirdparty.inc

@ -14,7 +14,7 @@
# cd build # cd build
# 3. Run cmake to generate project files for Windows, add more options to enable required third-party libraries. # 3. Run cmake to generate project files for Windows, add more options to enable required third-party libraries.
# See thirdparty.inc for more information. # See thirdparty.inc for more information.
# sample command: cmake -G "Visual Studio 14 Win64" -DGFLAGS=1 -DSNAPPY=1 -DJEMALLOC=1 -DJNI=1 .. # sample command: cmake -G "Visual Studio 15 Win64" -DWITH_GFLAGS=1 -DWITH_SNAPPY=1 -DWITH_JEMALLOC=1 -DWITH_JNI=1 ..
# 4. Then build the project in debug mode (you may want to add /m[:<N>] flag to run msbuild in <N> parallel threads # 4. Then build the project in debug mode (you may want to add /m[:<N>] flag to run msbuild in <N> parallel threads
# or simply /m ot use all avail cores) # or simply /m ot use all avail cores)
# msbuild rocksdb.sln # msbuild rocksdb.sln
@ -42,7 +42,14 @@ endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/") list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/")
option(WITH_JEMALLOC "build with JeMalloc" OFF) option(WITH_JEMALLOC "build with JeMalloc" OFF)
option(WITH_SNAPPY "build with SNAPPY" OFF)
option(WITH_LZ4 "build with lz4" OFF)
option(WITH_ZLIB "build with zlib" OFF)
if(MSVC) if(MSVC)
# Defaults currently different for GFLAGS.
# We will address find_package work a little later
option(WITH_GFLAGS "build with GFlags" OFF)
option(WITH_XPRESS "build with windows built in compression" OFF)
include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc) include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty.inc)
else() else()
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
@ -56,8 +63,18 @@ else()
include_directories(${JEMALLOC_INCLUDE_DIR}) include_directories(${JEMALLOC_INCLUDE_DIR})
endif() endif()
endif() endif()
# No config file for this
option(WITH_GFLAGS "build with GFlags" ON)
if(WITH_GFLAGS)
find_package(gflags)
if(gflags_FOUND)
add_definitions(-DGFLAGS=1)
include_directories(${gflags_INCLUDE_DIR})
list(APPEND THIRDPARTY_LIBS ${gflags_LIBRARIES})
endif()
endif()
option(WITH_SNAPPY "build with SNAPPY" OFF)
if(WITH_SNAPPY) if(WITH_SNAPPY)
find_package(snappy REQUIRED) find_package(snappy REQUIRED)
add_definitions(-DSNAPPY) add_definitions(-DSNAPPY)
@ -65,7 +82,6 @@ else()
list(APPEND THIRDPARTY_LIBS ${SNAPPY_LIBRARIES}) list(APPEND THIRDPARTY_LIBS ${SNAPPY_LIBRARIES})
endif() endif()
option(WITH_ZLIB "build with zlib" OFF)
if(WITH_ZLIB) if(WITH_ZLIB)
find_package(zlib REQUIRED) find_package(zlib REQUIRED)
add_definitions(-DZLIB) add_definitions(-DZLIB)
@ -81,7 +97,6 @@ else()
list(APPEND THIRDPARTY_LIBS ${BZIP2_LIBRARIES}) list(APPEND THIRDPARTY_LIBS ${BZIP2_LIBRARIES})
endif() endif()
option(WITH_LZ4 "build with lz4" OFF)
if(WITH_LZ4) if(WITH_LZ4)
find_package(lz4 REQUIRED) find_package(lz4 REQUIRED)
add_definitions(-DLZ4) add_definitions(-DLZ4)
@ -254,13 +269,6 @@ if(WITH_UBSAN)
endif() endif()
endif() endif()
find_package(gflags)
if(gflags_FOUND)
add_definitions(-DGFLAGS=1)
include_directories(${gflags_INCLUDE_DIR})
list(APPEND THIRDPARTY_LIBS ${gflags_LIBRARIES})
endif()
find_package(NUMA) find_package(NUMA)
if(NUMA_FOUND) if(NUMA_FOUND)
add_definitions(-DNUMA) add_definitions(-DNUMA)

@ -3,7 +3,7 @@ image: Visual Studio 2015
before_build: before_build:
- md %APPVEYOR_BUILD_FOLDER%\build - md %APPVEYOR_BUILD_FOLDER%\build
- cd %APPVEYOR_BUILD_FOLDER%\build - cd %APPVEYOR_BUILD_FOLDER%\build
- cmake -G "Visual Studio 14 2015 Win64" -DOPTDBG=1 -DXPRESS=1 -DPORTABLE=1 .. - cmake -G "Visual Studio 14 Win64" -DOPTDBG=1 -DWITH_XPRESS=1 -DPORTABLE=1 ..
- cd .. - cd ..
build: build:
project: build\rocksdb.sln project: build\rocksdb.sln

@ -1,14 +1,6 @@
# Edit definitions below to specify paths to include files and libraries of all 3rd party libraries # Edit definitions below to specify paths to include files and libraries of all 3rd party libraries
# # TODO: Make this work with find_package and/or get rid of it
# Edit these lines to set defaults for use of external libraries
#
set(USE_GFLAGS_DEFAULT 0) # GFLAGS is disabled by default, enable with -DGFLAGS=1 cmake command line agrument
set(USE_SNAPPY_DEFAULT 0) # SNAPPY is disabled by default, enable with -DSNAPPY=1 cmake command line agrument
set(USE_LZ4_DEFAULT 0) # LZ4 is disabled by default, enable with -DLZ4=1 cmake command line agrument
set(USE_ZLIB_DEFAULT 0) # ZLIB is disabled by default, enable with -DZLIB=1 cmake command line agrument
set(USE_XPRESS_DEFAULT 0) # XPRESS is disabled by default, enable with -DXPRESS=1 cmake command line agrument
# #
# This example assumes all the libraries locate in directories under THIRDPARTY_HOME environment variable # This example assumes all the libraries locate in directories under THIRDPARTY_HOME environment variable
# Set environment variable THIRDPARTY_HOME to point to your third party libraries home (Unix style dir separators) # Set environment variable THIRDPARTY_HOME to point to your third party libraries home (Unix style dir separators)
@ -17,7 +9,7 @@ set(USE_XPRESS_DEFAULT 0) # XPRESS is disabled by default, enable with -D
set (THIRDPARTY_LIBS "") # Initialization, don't touch set (THIRDPARTY_LIBS "") # Initialization, don't touch
# #
# Edit these 4 lines to define paths to GFLAGS # Defaults
# #
set(GFLAGS_HOME $ENV{THIRDPARTY_HOME}/Gflags.Library) set(GFLAGS_HOME $ENV{THIRDPARTY_HOME}/Gflags.Library)
set(GFLAGS_INCLUDE ${GFLAGS_HOME}/inc/include) set(GFLAGS_INCLUDE ${GFLAGS_HOME}/inc/include)
@ -25,16 +17,12 @@ set(GFLAGS_LIB_DEBUG ${GFLAGS_HOME}/bin/debug/amd64/gflags.lib)
set(GFLAGS_LIB_RELEASE ${GFLAGS_HOME}/bin/retail/amd64/gflags.lib) set(GFLAGS_LIB_RELEASE ${GFLAGS_HOME}/bin/retail/amd64/gflags.lib)
# ================================================== GFLAGS ================================================== # ================================================== GFLAGS ==================================================
# # For compatibility
# Don't touch these lines if (GFLAGS)
# set(WITH_GFLAGS ON)
if (DEFINED GFLAGS)
set(USE_GFLAGS ${GFLAGS})
else ()
set(USE_GFLAGS ${USE_GFLAGS_DEFAULT})
endif () endif ()
if (${USE_GFLAGS} EQUAL 1) if (WITH_GFLAGS)
message(STATUS "GFLAGS library is enabled") message(STATUS "GFLAGS library is enabled")
if(DEFINED ENV{GFLAGS_INCLUDE}) if(DEFINED ENV{GFLAGS_INCLUDE})
@ -68,16 +56,12 @@ set(SNAPPY_INCLUDE ${SNAPPY_HOME}/inc/inc)
set(SNAPPY_LIB_DEBUG ${SNAPPY_HOME}/bin/debug/amd64/snappy.lib) set(SNAPPY_LIB_DEBUG ${SNAPPY_HOME}/bin/debug/amd64/snappy.lib)
set(SNAPPY_LIB_RELEASE ${SNAPPY_HOME}/bin/retail/amd64/snappy.lib) set(SNAPPY_LIB_RELEASE ${SNAPPY_HOME}/bin/retail/amd64/snappy.lib)
# # For compatibility
# Don't touch these lines if(SNAPPY)
# set(WITH_SNAPPY ON)
if (DEFINED SNAPPY)
set(USE_SNAPPY ${SNAPPY})
else ()
set(USE_SNAPPY ${USE_SNAPPY_DEFAULT})
endif () endif ()
if (${USE_SNAPPY} EQUAL 1) if (WITH_SNAPPY)
message(STATUS "SNAPPY library is enabled") message(STATUS "SNAPPY library is enabled")
if(DEFINED ENV{SNAPPY_INCLUDE}) if(DEFINED ENV{SNAPPY_INCLUDE})
@ -115,12 +99,10 @@ set(LZ4_LIB_RELEASE ${LZ4_HOME}/bin/retail/amd64/lz4.lib)
# Don't touch these lines # Don't touch these lines
# #
if (DEFINED LZ4) if (DEFINED LZ4)
set(USE_LZ4 ${LZ4}) set(WITH_LZ4 ON)
else ()
set(USE_LZ4 ${USE_LZ4_DEFAULT})
endif () endif ()
if (${USE_LZ4} EQUAL 1) if (WITH_LZ4)
message(STATUS "LZ4 library is enabled") message(STATUS "LZ4 library is enabled")
if(DEFINED ENV{LZ4_INCLUDE}) if(DEFINED ENV{LZ4_INCLUDE})
@ -157,13 +139,13 @@ set(ZLIB_LIB_RELEASE ${ZLIB_HOME}/bin/retail/amd64/zlib.lib)
# #
# Don't touch these lines # Don't touch these lines
# #
if (DEFINED ZLIB)
set(USE_ZLIB ${ZLIB}) # For compatibilty
else () if (ZLIB)
set(USE_ZLIB ${USE_ZLIB_DEFAULT}) set(WITH_ZLIB ON)
endif () endif ()
if (${USE_ZLIB} EQUAL 1) if (WITH_ZLIB)
message(STATUS "ZLIB library is enabled") message(STATUS "ZLIB library is enabled")
if(DEFINED ENV{ZLIB_INCLUDE}) if(DEFINED ENV{ZLIB_INCLUDE})
@ -188,13 +170,12 @@ else ()
message(STATUS "ZLIB library is disabled") message(STATUS "ZLIB library is disabled")
endif () endif ()
if (DEFINED XPRESS) # For compatibilty
set(USE_XPRESS ${XPRESS}) if (XPRESS)
else () set(WITH_XPRESS ON)
set(USE_XPRESS ${USE_XPRESS_DEFAULT})
endif () endif ()
if (${USE_XPRESS} EQUAL 1) if (WITH_XPRESS)
message(STATUS "XPRESS is enabled") message(STATUS "XPRESS is enabled")
add_definitions(-DXPRESS) add_definitions(-DXPRESS)
@ -218,7 +199,7 @@ set(JEMALLOC_LIB_RELEASE ${JEMALLOC_HOME}/bin/retail/amd64/jemalloc.lib)
# Don't touch these lines # Don't touch these lines
# #
# For compatibilty with previous # For compatibilty
if(JEMALLOC) if(JEMALLOC)
set(WITH_JEMALLOC ON) set(WITH_JEMALLOC ON)
endif() endif()

Loading…
Cancel
Save