mirror of https://github.com/facebook/rocksdb.git
Add initial CMake support to plugin (#9214)
Summary: Not a CMake expert, and the current CMake build support added by this PR is unlikely the best way of doing it. Sending out the PR to demonstrate it can work. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9214 Test Plan: Will need to update https://github.com/ajkr/dedupfs with CMake build. Also, PR https://github.com/facebook/rocksdb/issues/9170 and PR https://github.com/facebook/rocksdb/issues/9206 both include CMake support for their plugins, and can be used as a proof of concept. Reviewed By: ajkr Differential Revision: D32738273 Pulled By: riversand963 fbshipit-source-id: da87fb4377c716bbbd577a69763b48d22483f845
This commit is contained in:
parent
552256cb1a
commit
29954b8b57
|
@ -938,6 +938,31 @@ list(APPEND SOURCES
|
||||||
utilities/transactions/lock/range/range_tree/lib/util/dbt.cc
|
utilities/transactions/lock/range/range_tree/lib/util/dbt.cc
|
||||||
utilities/transactions/lock/range/range_tree/lib/util/memarena.cc)
|
utilities/transactions/lock/range/range_tree/lib/util/memarena.cc)
|
||||||
|
|
||||||
|
message(STATUS "ROCKSDB_PLUGINS: ${ROCKSDB_PLUGINS}")
|
||||||
|
if ( ROCKSDB_PLUGINS )
|
||||||
|
string(REPLACE " " ";" PLUGINS ${ROCKSDB_PLUGINS})
|
||||||
|
foreach (plugin ${PLUGINS})
|
||||||
|
add_subdirectory("plugin/${plugin}")
|
||||||
|
foreach (src ${${plugin}_SOURCES})
|
||||||
|
list(APPEND SOURCES plugin/${plugin}/${src})
|
||||||
|
set_source_files_properties(
|
||||||
|
plugin/${plugin}/${src}
|
||||||
|
PROPERTIES COMPILE_FLAGS "${${plugin}_COMPILE_FLAGS}")
|
||||||
|
endforeach()
|
||||||
|
foreach (path ${${plugin}_INCLUDE_PATHS})
|
||||||
|
include_directories(${path})
|
||||||
|
endforeach()
|
||||||
|
foreach (lib ${${plugin}_LIBS})
|
||||||
|
list(APPEND THIRDPARTY_LIBS ${lib})
|
||||||
|
endforeach()
|
||||||
|
foreach (link_path ${${plugin}_LINK_PATHS})
|
||||||
|
link_directories(AFTER ${link_path})
|
||||||
|
endforeach()
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${${plugin}_CMAKE_SHARED_LINKER_FLAGS}")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${${plugin}_CMAKE_EXE_LINKER_FLAGS}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(HAVE_SSE42 AND NOT MSVC)
|
if(HAVE_SSE42 AND NOT MSVC)
|
||||||
set_source_files_properties(
|
set_source_files_properties(
|
||||||
util/crc32c.cc
|
util/crc32c.cc
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -251,6 +251,7 @@ ROCKSDB_PLUGIN_SOURCES = $(foreach plugin, $(ROCKSDB_PLUGINS), $(foreach source,
|
||||||
ROCKSDB_PLUGIN_HEADERS = $(foreach plugin, $(ROCKSDB_PLUGINS), $(foreach header, $($(plugin)_HEADERS), plugin/$(plugin)/$(header)))
|
ROCKSDB_PLUGIN_HEADERS = $(foreach plugin, $(ROCKSDB_PLUGINS), $(foreach header, $($(plugin)_HEADERS), plugin/$(plugin)/$(header)))
|
||||||
ROCKSDB_PLUGIN_PKGCONFIG_REQUIRES = $(foreach plugin, $(ROCKSDB_PLUGINS), $($(plugin)_PKGCONFIG_REQUIRES))
|
ROCKSDB_PLUGIN_PKGCONFIG_REQUIRES = $(foreach plugin, $(ROCKSDB_PLUGINS), $($(plugin)_PKGCONFIG_REQUIRES))
|
||||||
PLATFORM_LDFLAGS += $(foreach plugin, $(ROCKSDB_PLUGINS), $($(plugin)_LDFLAGS))
|
PLATFORM_LDFLAGS += $(foreach plugin, $(ROCKSDB_PLUGINS), $($(plugin)_LDFLAGS))
|
||||||
|
CXXFLAGS += $(foreach plugin, $(ROCKSDB_PLUGINS), $($(plugin)_CXXFLAGS))
|
||||||
|
|
||||||
ifneq ($(ROCKSDB_PLUGIN_PKGCONFIG_REQUIRES),)
|
ifneq ($(ROCKSDB_PLUGIN_PKGCONFIG_REQUIRES),)
|
||||||
LDFLAGS := $(LDFLAGS) $(shell pkg-config --libs $(ROCKSDB_PLUGIN_PKGCONFIG_REQUIRES))
|
LDFLAGS := $(LDFLAGS) $(shell pkg-config --libs $(ROCKSDB_PLUGIN_PKGCONFIG_REQUIRES))
|
||||||
|
|
|
@ -12,14 +12,32 @@ External plugins will be linked according to their name into a subdirectory of "
|
||||||
|
|
||||||
### Build standard
|
### Build standard
|
||||||
|
|
||||||
Currently the only supported build system is make. In the plugin directory, files ending in the .mk extension can define the following variables.
|
Currently the only supported build system are make and cmake.
|
||||||
|
|
||||||
|
For make, files in the plugin directory ending in the .mk extension can define the following variables.
|
||||||
|
|
||||||
* `$(PLUGIN_NAME)_SOURCES`: these files will be compiled and linked with RocksDB. They can access RocksDB public header files.
|
* `$(PLUGIN_NAME)_SOURCES`: these files will be compiled and linked with RocksDB. They can access RocksDB public header files.
|
||||||
* `$(PLUGIN_NAME)_HEADERS`: these files will be installed in the RocksDB header directory. Their paths will be prefixed by "rocksdb/plugin/$(PLUGIN_NAME)/".
|
* `$(PLUGIN_NAME)_HEADERS`: these files will be installed in the RocksDB header directory. Their paths will be prefixed by "rocksdb/plugin/$(PLUGIN_NAME)/".
|
||||||
* `$(PLUGIN_NAME)_LDFLAGS`: these flags will be passed to the final link step. For example, library dependencies can be propagated here, or symbols can be forcibly included, e.g., for static registration.
|
* `$(PLUGIN_NAME)_LDFLAGS`: these flags will be passed to the final link step. For example, library dependencies can be propagated here, or symbols can be forcibly included, e.g., for static registration.
|
||||||
|
* `$(PLUGIN_NAME)_CXXFLAGS`: these flags will be passed to the compiler. For example, they can specify locations of header files in non-standard locations.
|
||||||
|
|
||||||
Users will run the usual make commands from the RocksDB directory, specifying the plugins to include in a space-separated list in the variable `ROCKSDB_PLUGINS`.
|
Users will run the usual make commands from the RocksDB directory, specifying the plugins to include in a space-separated list in the variable `ROCKSDB_PLUGINS`.
|
||||||
|
|
||||||
|
For CMake, the CMakeLists.txt file in the plugin directory can define the following variables.
|
||||||
|
|
||||||
|
* `${PLUGIN_NAME}_SOURCES`: these files will be compiled and linked with RocksDB. They can access RocksDB public header files.
|
||||||
|
* `${PLUGIN_NAME}_COMPILE_FLAGS`: these flags will be passed to the compiler. For example, they can specify locations of header files in non-standard locations.
|
||||||
|
* `${PLUGIN_NAME}_INCLUDE_PATHS`: paths to directories to search for plugin-specific header files during compilation.
|
||||||
|
* `${PLUGIN_NAME}_LIBS`: list of library names required to build the plugin, e.g. `dl`, `java`, `jvm`, `rados`, etc. CMake will generate proper flags for linking.
|
||||||
|
* `${PLUGIN_NAME}_LINK_PATHS`: list of paths for the linker to search for required libraries in additional to standard locations.
|
||||||
|
* `${PLUGIN_NAME}_CMAKE_SHARED_LINKER_FLAGS` additional linker flags used to generate shared libraries. For example, symbols can be forcibly included, e.g., for static registration.
|
||||||
|
* `${PLUGIN_NAME}_CMAKE_EXE_LINKER_FLAGS`: additional linker flags used to generate executables. For example, symbols can be forcibly included, e.g., for static registration.
|
||||||
|
|
||||||
|
Users will run the usual cmake commands, specifying the plugins to include in a space-separated list in the command line variable `ROCKSDB_PLUGINS` when invoking cmake.
|
||||||
|
```
|
||||||
|
cmake .. -DROCKSDB_PLUGINS="dedupfs hdfs rados"
|
||||||
|
```
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
For a working example, see [Dedupfs](https://github.com/ajkr/dedupfs).
|
For a working example, see [Dedupfs](https://github.com/ajkr/dedupfs).
|
||||||
|
|
Loading…
Reference in New Issue