diff --git a/.gitignore b/.gitignore index e07fbae9a08801d30c4e1f0e0c8398139eedba43..79c70d0cd66e397363164d46e28a1d3caeec6951 100755 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ target build/VS2010/FlatBuffers.sdf build/VS2010/FlatBuffers.opensdf build/VS2010/ipch/**/*.ipch +*.so diff --git a/CMakeLists.txt b/CMakeLists.txt index 1af3d3334159823e16fca5511161e0ef8a2ce416..ad01c211a99dec30314a6b6b4d4befce9b5fc46e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,9 @@ option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" ON) option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON) option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF) +option(FLATBUFFERS_BUILD_SHAREDLIB + "Enable the build of the flatbuffers shared library" + OFF) if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS) message(WARNING @@ -164,6 +167,11 @@ if(FLATBUFFERS_BUILD_FLATHASH) add_executable(flathash ${FlatHash_SRCS}) endif() +if(FLATBUFFERS_BUILD_SHAREDLIB) + add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS}) + set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers) +endif() + function(compile_flatbuffers_schema_to_cpp SRC_FBS) get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS}) @@ -212,6 +220,9 @@ if(FLATBUFFERS_INSTALL) if(FLATBUFFERS_BUILD_FLATC) install(TARGETS flatc DESTINATION bin) endif() + if(FLATBUFFERS_BUILD_SHAREDLIB) + install(TARGETS flatbuffers_shared DESTINATION lib) + endif() endif() if(FLATBUFFERS_BUILD_TESTS)