Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8) |
Vladimir Glavnyy | 0fb1d44 | 2018-10-30 01:29:05 +0700 | [diff] [blame] | 2 | # generate compile_commands.json |
| 3 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) |
Vladimir Glavnyy | 5f32f94 | 2018-11-17 00:24:06 +0700 | [diff] [blame] | 4 | include(CheckCXXSymbolExists) |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 5 | |
| 6 | project(FlatBuffers) |
| 7 | |
| 8 | # NOTE: Code coverage only works on Linux & OSX. |
| 9 | option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF) |
Stewart Miles | 3f85183 | 2014-09-10 16:01:13 -0700 | [diff] [blame] | 10 | option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON) |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 11 | option(FLATBUFFERS_INSTALL "Enable the installation of targets." ON) |
Wouter van Oortmerssen | 3101e32 | 2016-07-01 18:08:51 -0700 | [diff] [blame] | 12 | option(FLATBUFFERS_BUILD_FLATLIB "Enable the build of the flatbuffers library" |
| 13 | ON) |
| 14 | option(FLATBUFFERS_BUILD_FLATC "Enable the build of the flatbuffers compiler" |
| 15 | ON) |
Alex Ames | d575321 | 2015-02-13 15:58:29 -0800 | [diff] [blame] | 16 | option(FLATBUFFERS_BUILD_FLATHASH "Enable the build of flathash" ON) |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 17 | option(FLATBUFFERS_BUILD_GRPCTEST "Enable the build of grpctest" OFF) |
changnet | a15659e | 2016-09-07 01:12:04 +0800 | [diff] [blame] | 18 | option(FLATBUFFERS_BUILD_SHAREDLIB |
| 19 | "Enable the build of the flatbuffers shared library" |
| 20 | OFF) |
Kamil Rojewski | 6bfa107 | 2018-07-19 18:40:28 +0200 | [diff] [blame] | 21 | option(FLATBUFFERS_LIBCXX_WITH_CLANG "Force libc++ when using Clang" ON) |
Vladimir Glavnyy | 0fb1d44 | 2018-10-30 01:29:05 +0700 | [diff] [blame] | 22 | # NOTE: Sanitizer check only works on Linux & OSX (gcc & llvm). |
Kamil Rojewski | 30c4948 | 2018-12-06 20:12:06 +0100 | [diff] [blame] | 23 | option(FLATBUFFERS_CODE_SANITIZE |
Vladimir Glavnyy | 0fb1d44 | 2018-10-30 01:29:05 +0700 | [diff] [blame] | 24 | "Add '-fsanitize' flags to 'flattests' and 'flatc' targets." |
| 25 | OFF) |
Marc Butler | 4567b13 | 2019-02-22 06:06:04 +1100 | [diff] [blame] | 26 | option(FLATBUFFERS_PACKAGE_REDHAT |
| 27 | "Build an rpm using the 'package' target." |
| 28 | OFF) |
| 29 | option(FLATBUFFERS_PACKAGE_DEBIAN |
| 30 | "Build an deb using the 'package' target." |
| 31 | OFF) |
Wouter van Oortmerssen | 9bf9b18 | 2019-02-25 11:42:37 -0800 | [diff] [blame] | 32 | |
Leander Bessa Beernaert | 3ec8d7f | 2015-01-02 13:51:31 +0100 | [diff] [blame] | 33 | if(NOT FLATBUFFERS_BUILD_FLATC AND FLATBUFFERS_BUILD_TESTS) |
| 34 | message(WARNING |
| 35 | "Cannot build tests without building the compiler. Tests will be disabled.") |
| 36 | set(FLATBUFFERS_BUILD_TESTS OFF) |
| 37 | endif() |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 38 | |
Vladimir Glavnyy | 925c1d7 | 2018-10-04 23:27:37 +0700 | [diff] [blame] | 39 | if(DEFINED FLATBUFFERS_MAX_PARSING_DEPTH) |
| 40 | # Override the default recursion depth limit. |
| 41 | add_definitions(-DFLATBUFFERS_MAX_PARSING_DEPTH=${FLATBUFFERS_MAX_PARSING_DEPTH}) |
| 42 | message(STATUS "FLATBUFFERS_MAX_PARSING_DEPTH: ${FLATBUFFERS_MAX_PARSING_DEPTH}") |
| 43 | endif() |
| 44 | |
Vladimir Glavnyy | 5f32f94 | 2018-11-17 00:24:06 +0700 | [diff] [blame] | 45 | # Auto-detect locale-narrow 'strtod_l' function. |
| 46 | if(NOT DEFINED FLATBUFFERS_LOCALE_INDEPENDENT) |
| 47 | if(MSVC) |
| 48 | check_cxx_symbol_exists(_strtof_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT) |
| 49 | else() |
| 50 | check_cxx_symbol_exists(strtof_l stdlib.h FLATBUFFERS_LOCALE_INDEPENDENT) |
| 51 | endif() |
| 52 | endif() |
| 53 | add_definitions(-DFLATBUFFERS_LOCALE_INDEPENDENT=$<BOOL:${FLATBUFFERS_LOCALE_INDEPENDENT}>) |
| 54 | |
Martell Malone | 79d3cb6 | 2015-07-22 13:18:59 +0100 | [diff] [blame] | 55 | set(FlatBuffers_Library_SRCS |
Lakedaemon | 8a64afa | 2016-04-13 23:21:18 +0200 | [diff] [blame] | 56 | include/flatbuffers/code_generators.h |
Wouter van Oortmerssen | 88a85ff | 2017-06-15 20:54:04 -0700 | [diff] [blame] | 57 | include/flatbuffers/base.h |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 58 | include/flatbuffers/flatbuffers.h |
Alex Ames | d575321 | 2015-02-13 15:58:29 -0800 | [diff] [blame] | 59 | include/flatbuffers/hash.h |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 60 | include/flatbuffers/idl.h |
| 61 | include/flatbuffers/util.h |
Wouter van Oortmerssen | 81312c2 | 2015-05-21 16:33:29 -0700 | [diff] [blame] | 62 | include/flatbuffers/reflection.h |
| 63 | include/flatbuffers/reflection_generated.h |
Stewart Miles | a892322 | 2017-07-13 06:27:39 -0700 | [diff] [blame] | 64 | include/flatbuffers/stl_emulation.h |
Wouter van Oortmerssen | aac6be1 | 2016-02-01 18:00:30 -0800 | [diff] [blame] | 65 | include/flatbuffers/flexbuffers.h |
Wouter van Oortmerssen | 88a85ff | 2017-06-15 20:54:04 -0700 | [diff] [blame] | 66 | include/flatbuffers/registry.h |
Wouter van Oortmerssen | 72a99ab | 2017-08-24 17:44:03 -0700 | [diff] [blame] | 67 | include/flatbuffers/minireflect.h |
Wouter van Oortmerssen | 7b94eab | 2017-01-13 17:44:42 -0800 | [diff] [blame] | 68 | src/code_generators.cpp |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 69 | src/idl_parser.cpp |
Martell Malone | 79d3cb6 | 2015-07-22 13:18:59 +0100 | [diff] [blame] | 70 | src/idl_gen_text.cpp |
Wouter van Oortmerssen | 7101224 | 2015-07-31 13:55:53 -0700 | [diff] [blame] | 71 | src/reflection.cpp |
Wouter van Oortmerssen | e98b191 | 2016-03-30 17:34:52 -0700 | [diff] [blame] | 72 | src/util.cpp |
Martell Malone | 79d3cb6 | 2015-07-22 13:18:59 +0100 | [diff] [blame] | 73 | ) |
| 74 | |
| 75 | set(FlatBuffers_Compiler_SRCS |
| 76 | ${FlatBuffers_Library_SRCS} |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 77 | src/idl_gen_cpp.cpp |
Dan Field | 8891264 | 2018-05-18 14:06:15 -0400 | [diff] [blame] | 78 | src/idl_gen_dart.cpp |
Wouter van Oortmerssen | 557c88c | 2014-09-16 17:37:17 -0700 | [diff] [blame] | 79 | src/idl_gen_general.cpp |
rw | 74d5f37 | 2014-07-11 16:12:35 -0700 | [diff] [blame] | 80 | src/idl_gen_go.cpp |
Kamil Rojewski | 30c4948 | 2018-12-06 20:12:06 +0100 | [diff] [blame] | 81 | src/idl_gen_js_ts.cpp |
Shuhei Taunma | 5ce8682 | 2015-11-05 16:19:28 +0900 | [diff] [blame] | 82 | src/idl_gen_php.cpp |
rw | 48dfc69 | 2014-12-16 00:32:11 -0800 | [diff] [blame] | 83 | src/idl_gen_python.cpp |
aardappel | 4898809 | 2018-07-23 19:03:11 -0700 | [diff] [blame] | 84 | src/idl_gen_lobster.cpp |
Derek Bailey | ba5eb3b | 2018-07-05 15:55:57 -0700 | [diff] [blame] | 85 | src/idl_gen_lua.cpp |
Robert | 3c54fd9 | 2018-09-02 17:05:50 -0700 | [diff] [blame] | 86 | src/idl_gen_rust.cpp |
Wouter van Oortmerssen | d38b9af | 2014-09-26 16:46:30 -0700 | [diff] [blame] | 87 | src/idl_gen_fbs.cpp |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 88 | src/idl_gen_grpc.cpp |
schoetbi | f202041 | 2017-07-10 17:05:59 +0200 | [diff] [blame] | 89 | src/idl_gen_json_schema.cpp |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 90 | src/flatc.cpp |
Wouter van Oortmerssen | b395359 | 2017-01-25 13:41:34 -0800 | [diff] [blame] | 91 | src/flatc_main.cpp |
Harsh Vardhan | 2e7806e | 2016-08-19 10:41:11 +0530 | [diff] [blame] | 92 | grpc/src/compiler/schema_interface.h |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 93 | grpc/src/compiler/cpp_generator.h |
| 94 | grpc/src/compiler/cpp_generator.cc |
Ronak Jain | a31ddd2 | 2016-12-06 02:50:38 +0530 | [diff] [blame] | 95 | grpc/src/compiler/go_generator.h |
| 96 | grpc/src/compiler/go_generator.cc |
Yuri Finkelstein | 8518b3f | 2017-12-21 07:55:57 -1000 | [diff] [blame] | 97 | grpc/src/compiler/java_generator.h |
| 98 | grpc/src/compiler/java_generator.cc |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 99 | ) |
| 100 | |
Alex Ames | d575321 | 2015-02-13 15:58:29 -0800 | [diff] [blame] | 101 | set(FlatHash_SRCS |
| 102 | include/flatbuffers/hash.h |
| 103 | src/flathash.cpp |
| 104 | ) |
| 105 | |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 106 | set(FlatBuffers_Tests_SRCS |
Wouter van Oortmerssen | 7101224 | 2015-07-31 13:55:53 -0700 | [diff] [blame] | 107 | ${FlatBuffers_Library_SRCS} |
Wouter van Oortmerssen | d38b9af | 2014-09-26 16:46:30 -0700 | [diff] [blame] | 108 | src/idl_gen_fbs.cpp |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 109 | tests/test.cpp |
Sumant Tambe | 49fed8c | 2018-09-24 12:03:31 -0700 | [diff] [blame] | 110 | tests/test_assert.h |
| 111 | tests/test_assert.cpp |
| 112 | tests/test_builder.h |
| 113 | tests/test_builder.cpp |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 114 | # file generate by running compiler on tests/monster_test.fbs |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 115 | ${CMAKE_CURRENT_BINARY_DIR}/tests/monster_test_generated.h |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 116 | ) |
| 117 | |
| 118 | set(FlatBuffers_Sample_Binary_SRCS |
| 119 | include/flatbuffers/flatbuffers.h |
| 120 | samples/sample_binary.cpp |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 121 | # file generated by running compiler on samples/monster.fbs |
| 122 | ${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 123 | ) |
| 124 | |
| 125 | set(FlatBuffers_Sample_Text_SRCS |
Wouter van Oortmerssen | 7b94eab | 2017-01-13 17:44:42 -0800 | [diff] [blame] | 126 | ${FlatBuffers_Library_SRCS} |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 127 | samples/sample_text.cpp |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 128 | # file generated by running compiler on samples/monster.fbs |
| 129 | ${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 130 | ) |
| 131 | |
tira-misu | dba962e | 2018-12-13 20:59:27 +0100 | [diff] [blame] | 132 | set(FlatBuffers_Sample_BFBS_SRCS |
| 133 | ${FlatBuffers_Library_SRCS} |
| 134 | src/idl_gen_general.cpp |
| 135 | samples/sample_bfbs.cpp |
| 136 | # file generated by running compiler on samples/monster.fbs |
| 137 | ${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h |
| 138 | ) |
| 139 | |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 140 | set(FlatBuffers_GRPCTest_SRCS |
| 141 | include/flatbuffers/flatbuffers.h |
| 142 | include/flatbuffers/grpc.h |
| 143 | tests/monster_test.grpc.fb.h |
Sumant Tambe | 49fed8c | 2018-09-24 12:03:31 -0700 | [diff] [blame] | 144 | tests/test_assert.h |
| 145 | tests/test_builder.h |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 146 | tests/monster_test.grpc.fb.cc |
Sumant Tambe | 49fed8c | 2018-09-24 12:03:31 -0700 | [diff] [blame] | 147 | tests/test_assert.cpp |
| 148 | tests/test_builder.cpp |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 149 | grpc/tests/grpctest.cpp |
Sumant Tambe | e757854 | 2018-08-30 16:43:22 -0700 | [diff] [blame] | 150 | grpc/tests/message_builder_test.cpp |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 151 | # file generated by running compiler on samples/monster.fbs |
| 152 | ${CMAKE_CURRENT_BINARY_DIR}/samples/monster_generated.h |
| 153 | ) |
| 154 | |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 155 | # source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS}) |
| 156 | # source_group(Tests FILES ${FlatBuffers_Tests_SRCS}) |
| 157 | |
Andrew Hundt | 520d684 | 2016-10-05 16:20:30 -0400 | [diff] [blame] | 158 | if(EXISTS "${CMAKE_TOOLCHAIN_FILE}") |
Wouter van Oortmerssen | 606098c | 2016-10-17 13:06:11 -0700 | [diff] [blame] | 159 | # do not apply any global settings if the toolchain |
Andrew Hundt | 520d684 | 2016-10-05 16:20:30 -0400 | [diff] [blame] | 160 | # is being configured externally |
Vladimir Glavnyy | 7d3930a | 2019-01-29 01:16:12 +0700 | [diff] [blame] | 161 | message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.") |
Andrew Hundt | 520d684 | 2016-10-05 16:20:30 -0400 | [diff] [blame] | 162 | elseif(APPLE) |
Jason Sanmiya | 30c07f4 | 2016-07-22 19:04:23 -0700 | [diff] [blame] | 163 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++") |
Per Grön | 9aeeddf | 2017-05-12 18:48:17 +0200 | [diff] [blame] | 164 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Wno-unused-parameter") |
Frank Benkstein | 20396a1 | 2018-10-16 00:11:31 +0200 | [diff] [blame] | 165 | set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast") |
Wouter van Oortmerssen | 932b22f | 2015-05-27 16:57:21 -0700 | [diff] [blame] | 166 | elseif(CMAKE_COMPILER_IS_GNUCXX) |
Tony Kelman | 4c16038 | 2016-04-01 21:42:23 -0700 | [diff] [blame] | 167 | if(CYGWIN) |
| 168 | set(CMAKE_CXX_FLAGS |
| 169 | "${CMAKE_CXX_FLAGS} -std=gnu++11") |
| 170 | else(CYGWIN) |
| 171 | set(CMAKE_CXX_FLAGS |
| 172 | "${CMAKE_CXX_FLAGS} -std=c++0x") |
| 173 | endif(CYGWIN) |
Wouter van Oortmerssen | bc5fa9d | 2014-08-25 10:42:38 -0700 | [diff] [blame] | 174 | set(CMAKE_CXX_FLAGS |
Tony Kelman | 4c16038 | 2016-04-01 21:42:23 -0700 | [diff] [blame] | 175 | "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow") |
Frank Benkstein | 20396a1 | 2018-10-16 00:11:31 +0200 | [diff] [blame] | 176 | set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast") |
Kamil Rojewski | 474ba68 | 2018-02-12 17:37:51 +0100 | [diff] [blame] | 177 | if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4) |
| 178 | if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) |
| 179 | set(CMAKE_CXX_FLAGS |
Wouter van Oortmerssen | a821b15 | 2018-12-26 16:02:14 -0800 | [diff] [blame] | 180 | "${CMAKE_CXX_FLAGS} -faligned-new -Werror=implicit-fallthrough=2") |
Kamil Rojewski | 474ba68 | 2018-02-12 17:37:51 +0100 | [diff] [blame] | 181 | endif() |
maurice barnum | 697cad7 | 2016-02-11 00:03:53 +0000 | [diff] [blame] | 182 | set(CMAKE_CXX_FLAGS |
Juyeon Yoon | 0998861 | 2018-04-06 01:17:33 +0900 | [diff] [blame] | 183 | "${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter") |
maurice barnum | 697cad7 | 2016-02-11 00:03:53 +0000 | [diff] [blame] | 184 | endif() |
Will Gardner | ce4d331 | 2016-02-29 17:28:40 +0000 | [diff] [blame] | 185 | |
| 186 | # Certain platforms such as ARM do not use signed chars by default |
| 187 | # which causes issues with certain bounds checks. |
| 188 | set(CMAKE_CXX_FLAGS |
| 189 | "${CMAKE_CXX_FLAGS} -fsigned-char") |
| 190 | |
Jason Sanmiya | 985de21 | 2016-09-08 10:47:50 -0700 | [diff] [blame] | 191 | elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") |
Wouter van Oortmerssen | 932b22f | 2015-05-27 16:57:21 -0700 | [diff] [blame] | 192 | set(CMAKE_CXX_FLAGS |
Alex Ames | f2627e1 | 2017-10-20 16:29:51 -0700 | [diff] [blame] | 193 | "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra -Wno-unused-parameter") |
Frank Benkstein | 20396a1 | 2018-10-16 00:11:31 +0200 | [diff] [blame] | 194 | set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast") |
Vladimir Glavnyy | 7d3930a | 2019-01-29 01:16:12 +0700 | [diff] [blame] | 195 | if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8) |
Wouter van Oortmerssen | e237f53 | 2019-03-07 15:14:40 -0800 | [diff] [blame] | 196 | list(APPEND FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wimplicit-fallthrough" "-Wextra-semi" "-Werror=unused-private-field") # enable warning |
Vladimir Glavnyy | 7d3930a | 2019-01-29 01:16:12 +0700 | [diff] [blame] | 197 | endif() |
Kamil Rojewski | 6bfa107 | 2018-07-19 18:40:28 +0200 | [diff] [blame] | 198 | if(FLATBUFFERS_LIBCXX_WITH_CLANG) |
| 199 | if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Linux") |
| 200 | set(CMAKE_CXX_FLAGS |
| 201 | "${CMAKE_CXX_FLAGS} -stdlib=libc++") |
| 202 | endif() |
| 203 | if(NOT ("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD" OR |
| 204 | "${CMAKE_SYSTEM_NAME}" MATCHES "Linux")) |
| 205 | set(CMAKE_EXE_LINKER_FLAGS |
| 206 | "${CMAKE_EXE_LINKER_FLAGS} -lc++abi") |
| 207 | endif() |
Yuri | 26f15bc | 2016-03-02 17:15:42 -0800 | [diff] [blame] | 208 | endif() |
Will Gardner | ce4d331 | 2016-02-29 17:28:40 +0000 | [diff] [blame] | 209 | |
| 210 | # Certain platforms such as ARM do not use signed chars by default |
| 211 | # which causes issues with certain bounds checks. |
| 212 | set(CMAKE_CXX_FLAGS |
| 213 | "${CMAKE_CXX_FLAGS} -fsigned-char") |
| 214 | |
Wouter van Oortmerssen | 6561c7a | 2017-02-15 17:44:55 -0800 | [diff] [blame] | 215 | elseif(MSVC) |
chronoxor | f538738 | 2017-03-10 21:27:30 +0300 | [diff] [blame] | 216 | # Visual Studio pedantic build settings |
Wouter van Oortmerssen | 238a8eb | 2017-03-29 12:01:11 -0700 | [diff] [blame] | 217 | # warning C4512: assignment operator could not be generated |
Wouter van Oortmerssen | e93a565 | 2017-04-24 10:29:25 -0700 | [diff] [blame] | 218 | # warning C4316: object allocated on the heap may not be aligned |
| 219 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4512 /wd4316") |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 220 | endif() |
| 221 | |
| 222 | if(FLATBUFFERS_CODE_COVERAGE) |
Stefan Eilemann | 52f4f45 | 2014-07-26 13:12:56 +0200 | [diff] [blame] | 223 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage") |
Wouter van Oortmerssen | 8f80fec | 2014-07-29 10:29:38 -0700 | [diff] [blame] | 224 | set(CMAKE_EXE_LINKER_FLAGS |
| 225 | "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 226 | endif() |
| 227 | |
Vladimir Glavnyy | 0fb1d44 | 2018-10-30 01:29:05 +0700 | [diff] [blame] | 228 | function(add_fsanitize_to_target _target _sanitizer) |
| 229 | # FLATBUFFERS_CODE_SANITIZE: boolean {ON,OFF,YES,NO} or string with list of sanitizer. |
| 230 | # List of sanitizer is string starts with '=': "=address,undefined,thread,memory". |
| 231 | if((${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") OR |
Vladimir Glavnyy | 9ad73bf | 2018-12-18 02:50:31 +0700 | [diff] [blame] | 232 | ((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")) |
Vladimir Glavnyy | 0fb1d44 | 2018-10-30 01:29:05 +0700 | [diff] [blame] | 233 | ) |
| 234 | set(_sanitizer_flags "=address,undefined") |
| 235 | if(_sanitizer MATCHES "=.*") |
| 236 | # override default by user-defined sanitizer list |
| 237 | set(_sanitizer_flags ${_sanitizer}) |
| 238 | endif() |
Kamil Rojewski | 30c4948 | 2018-12-06 20:12:06 +0100 | [diff] [blame] | 239 | target_compile_options(${_target} PRIVATE |
Vladimir Glavnyy | 0fb1d44 | 2018-10-30 01:29:05 +0700 | [diff] [blame] | 240 | -g -fsigned-char -fno-omit-frame-pointer |
| 241 | "-fsanitize${_sanitizer_flags}") |
| 242 | target_link_libraries(${_target} PRIVATE |
| 243 | "-fsanitize${_sanitizer_flags}") |
| 244 | set_property(TARGET ${_target} PROPERTY POSITION_INDEPENDENT_CODE ON) |
Vladimir Glavnyy | 5f32f94 | 2018-11-17 00:24:06 +0700 | [diff] [blame] | 245 | message(STATUS "Sanitizer ${_sanitizer_flags} added to ${_target}") |
Vladimir Glavnyy | 0fb1d44 | 2018-10-30 01:29:05 +0700 | [diff] [blame] | 246 | endif() |
| 247 | endfunction() |
| 248 | |
franramirez688 | da0f096 | 2015-01-31 11:14:59 -0500 | [diff] [blame] | 249 | if(BIICODE) |
franchuti688 | 23f75f5 | 2015-04-01 12:35:37 +0200 | [diff] [blame] | 250 | include(biicode/cmake/biicode.cmake) |
franramirez688 | da0f096 | 2015-01-31 11:14:59 -0500 | [diff] [blame] | 251 | return() |
franchuti688 | 23f75f5 | 2015-04-01 12:35:37 +0200 | [diff] [blame] | 252 | endif() |
franramirez688 | da0f096 | 2015-01-31 11:14:59 -0500 | [diff] [blame] | 253 | |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 254 | include_directories(include) |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 255 | include_directories(grpc) |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 256 | |
Martell Malone | 79d3cb6 | 2015-07-22 13:18:59 +0100 | [diff] [blame] | 257 | if(FLATBUFFERS_BUILD_FLATLIB) |
Vladimir Glavnyy | 27e4f43 | 2018-08-07 04:59:29 +0700 | [diff] [blame] | 258 | add_library(flatbuffers STATIC ${FlatBuffers_Library_SRCS}) |
| 259 | # CMake > 2.8.11: Attach header directory for when build via add_subdirectory(). |
| 260 | target_include_directories(flatbuffers INTERFACE |
| 261 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>) |
Frank Benkstein | 20396a1 | 2018-10-16 00:11:31 +0200 | [diff] [blame] | 262 | target_compile_options(flatbuffers PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}") |
Martell Malone | 79d3cb6 | 2015-07-22 13:18:59 +0100 | [diff] [blame] | 263 | endif() |
| 264 | |
Leander Bessa Beernaert | 3ec8d7f | 2015-01-02 13:51:31 +0100 | [diff] [blame] | 265 | if(FLATBUFFERS_BUILD_FLATC) |
Alex Ames | d575321 | 2015-02-13 15:58:29 -0800 | [diff] [blame] | 266 | add_executable(flatc ${FlatBuffers_Compiler_SRCS}) |
Frank Benkstein | 20396a1 | 2018-10-16 00:11:31 +0200 | [diff] [blame] | 267 | target_compile_options(flatc PRIVATE "${FLATBUFFERS_PRIVATE_CXX_FLAGS}") |
Vladimir Glavnyy | 3f388ec | 2019-01-25 04:30:11 +0700 | [diff] [blame] | 268 | if(FLATBUFFERS_CODE_SANITIZE AND NOT WIN32) |
Vladimir Glavnyy | 0fb1d44 | 2018-10-30 01:29:05 +0700 | [diff] [blame] | 269 | add_fsanitize_to_target(flatc ${FLATBUFFERS_CODE_SANITIZE}) |
| 270 | endif() |
Xiaolei Yu | 3a8bc30 | 2016-05-01 11:15:53 +0800 | [diff] [blame] | 271 | if(NOT FLATBUFFERS_FLATC_EXECUTABLE) |
| 272 | set(FLATBUFFERS_FLATC_EXECUTABLE $<TARGET_FILE:flatc>) |
| 273 | endif() |
Wouter van Oortmerssen | cb2481e | 2017-05-10 15:42:23 -0700 | [diff] [blame] | 274 | if(MSVC) |
| 275 | # Make flatc.exe not depend on runtime dlls for easy distribution. |
| 276 | target_compile_options(flatc PUBLIC $<$<CONFIG:Release>:/MT>) |
| 277 | endif() |
Alex Ames | d575321 | 2015-02-13 15:58:29 -0800 | [diff] [blame] | 278 | endif() |
| 279 | |
Jason Sanmiya | f47660f | 2015-04-28 15:44:10 -0700 | [diff] [blame] | 280 | if(FLATBUFFERS_BUILD_FLATHASH) |
Alex Ames | d575321 | 2015-02-13 15:58:29 -0800 | [diff] [blame] | 281 | add_executable(flathash ${FlatHash_SRCS}) |
Leander Bessa Beernaert | 3ec8d7f | 2015-01-02 13:51:31 +0100 | [diff] [blame] | 282 | endif() |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 283 | |
changnet | a15659e | 2016-09-07 01:12:04 +0800 | [diff] [blame] | 284 | if(FLATBUFFERS_BUILD_SHAREDLIB) |
| 285 | add_library(flatbuffers_shared SHARED ${FlatBuffers_Library_SRCS}) |
Sergey Avseyev | ca52bfe | 2017-11-10 01:39:32 +0300 | [diff] [blame] | 286 | |
| 287 | # Shared object version: "major.minor.micro" |
| 288 | # - micro updated every release when there is no API/ABI changes |
| 289 | # - minor updated when there are additions in API/ABI |
| 290 | # - major (ABI number) updated when there are changes in ABI (or removals) |
| 291 | set(FlatBuffers_Library_SONAME_MAJOR "1") |
Wouter van Oortmerssen | 9e7e8cb | 2019-04-24 11:34:53 -0700 | [diff] [blame] | 292 | set(FlatBuffers_Library_SONAME_FULL "${FlatBuffers_Library_SONAME_MAJOR}.11.0") |
Sergey Avseyev | ca52bfe | 2017-11-10 01:39:32 +0300 | [diff] [blame] | 293 | set_target_properties(flatbuffers_shared PROPERTIES OUTPUT_NAME flatbuffers |
| 294 | SOVERSION "${FlatBuffers_Library_SONAME_MAJOR}" |
| 295 | VERSION "${FlatBuffers_Library_SONAME_FULL}") |
changnet | a15659e | 2016-09-07 01:12:04 +0800 | [diff] [blame] | 296 | endif() |
| 297 | |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 298 | function(compile_flatbuffers_schema_to_cpp SRC_FBS) |
Wouter van Oortmerssen | 4cdf3eb | 2014-10-24 14:26:29 -0700 | [diff] [blame] | 299 | get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) |
Wouter van Oortmerssen | 7b80535 | 2014-09-23 11:55:42 -0700 | [diff] [blame] | 300 | string(REGEX REPLACE "\\.fbs$" "_generated.h" GEN_HEADER ${SRC_FBS}) |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 301 | add_custom_command( |
| 302 | OUTPUT ${GEN_HEADER} |
Wouter van Oortmerssen | 3101e32 | 2016-07-01 18:08:51 -0700 | [diff] [blame] | 303 | COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -c --no-includes --gen-mutable |
Thomas | 33791dc | 2018-09-22 01:53:59 +0200 | [diff] [blame] | 304 | --gen-object-api --gen-compare -o "${SRC_FBS_DIR}" |
Stewart Miles | a892322 | 2017-07-13 06:27:39 -0700 | [diff] [blame] | 305 | --cpp-ptr-type flatbuffers::unique_ptr # Used to test with C++98 STLs |
Wouter van Oortmerssen | 72a99ab | 2017-08-24 17:44:03 -0700 | [diff] [blame] | 306 | --reflect-names |
Wouter van Oortmerssen | 22743ca | 2017-05-24 15:21:26 -0700 | [diff] [blame] | 307 | -I "${CMAKE_CURRENT_SOURCE_DIR}/tests/include_test" |
Wouter van Oortmerssen | 3101e32 | 2016-07-01 18:08:51 -0700 | [diff] [blame] | 308 | "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 309 | DEPENDS flatc) |
| 310 | endfunction() |
| 311 | |
Wouter van Oortmerssen | 81312c2 | 2015-05-21 16:33:29 -0700 | [diff] [blame] | 312 | function(compile_flatbuffers_schema_to_binary SRC_FBS) |
| 313 | get_filename_component(SRC_FBS_DIR ${SRC_FBS} PATH) |
| 314 | string(REGEX REPLACE "\\.fbs$" ".bfbs" GEN_BINARY_SCHEMA ${SRC_FBS}) |
| 315 | add_custom_command( |
| 316 | OUTPUT ${GEN_BINARY_SCHEMA} |
Wouter van Oortmerssen | 3101e32 | 2016-07-01 18:08:51 -0700 | [diff] [blame] | 317 | COMMAND "${FLATBUFFERS_FLATC_EXECUTABLE}" -b --schema -o "${SRC_FBS_DIR}" |
| 318 | "${CMAKE_CURRENT_SOURCE_DIR}/${SRC_FBS}" |
Wouter van Oortmerssen | 81312c2 | 2015-05-21 16:33:29 -0700 | [diff] [blame] | 319 | DEPENDS flatc) |
| 320 | endfunction() |
| 321 | |
Stewart Miles | 3f85183 | 2014-09-10 16:01:13 -0700 | [diff] [blame] | 322 | if(FLATBUFFERS_BUILD_TESTS) |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 323 | compile_flatbuffers_schema_to_cpp(tests/monster_test.fbs) |
| 324 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/tests) |
Stewart Miles | 3f85183 | 2014-09-10 16:01:13 -0700 | [diff] [blame] | 325 | add_executable(flattests ${FlatBuffers_Tests_SRCS}) |
Zarian Waheed | 6d6271d | 2016-12-16 08:46:30 -0800 | [diff] [blame] | 326 | set_property(TARGET flattests |
| 327 | PROPERTY COMPILE_DEFINITIONS FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE |
| 328 | FLATBUFFERS_DEBUG_VERIFICATION_FAILURE=1) |
Vladimir Glavnyy | 3f388ec | 2019-01-25 04:30:11 +0700 | [diff] [blame] | 329 | if(FLATBUFFERS_CODE_SANITIZE) |
| 330 | if(WIN32) |
| 331 | target_compile_definitions(flattests PRIVATE FLATBUFFERS_MEMORY_LEAK_TRACKING) |
| 332 | message(STATUS "Sanitizer MSVC::_CrtDumpMemoryLeaks added to flattests") |
| 333 | else() |
| 334 | add_fsanitize_to_target(flattests ${FLATBUFFERS_CODE_SANITIZE}) |
| 335 | endif() |
| 336 | endif() |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 337 | |
| 338 | compile_flatbuffers_schema_to_cpp(samples/monster.fbs) |
| 339 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/samples) |
Stewart Miles | 3f85183 | 2014-09-10 16:01:13 -0700 | [diff] [blame] | 340 | add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS}) |
| 341 | add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS}) |
tira-misu | dba962e | 2018-12-13 20:59:27 +0100 | [diff] [blame] | 342 | add_executable(flatsamplebfbs ${FlatBuffers_Sample_BFBS_SRCS}) |
Stewart Miles | 3f85183 | 2014-09-10 16:01:13 -0700 | [diff] [blame] | 343 | endif() |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 344 | |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 345 | if(FLATBUFFERS_BUILD_GRPCTEST) |
| 346 | if(CMAKE_COMPILER_IS_GNUCXX) |
Lawrence Chan | da67c0a | 2017-06-07 15:56:49 -0500 | [diff] [blame] | 347 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter -Wno-shadow") |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 348 | endif() |
Sumant Tambe | e757854 | 2018-08-30 16:43:22 -0700 | [diff] [blame] | 349 | if(NOT GRPC_INSTALL_PATH) |
| 350 | message(SEND_ERROR "GRPC_INSTALL_PATH variable is not defined. See grpc/README.md") |
| 351 | endif() |
| 352 | if(NOT PROTOBUF_DOWNLOAD_PATH) |
| 353 | message(SEND_ERROR "PROTOBUF_DOWNLOAD_PATH variable is not defined. See grpc/README.md") |
| 354 | endif() |
| 355 | INCLUDE_DIRECTORIES(${GRPC_INSTALL_PATH}/include) |
| 356 | INCLUDE_DIRECTORIES(${PROTOBUF_DOWNLOAD_PATH}/src) |
| 357 | LINK_DIRECTORIES(${GRPC_INSTALL_PATH}/lib) |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 358 | add_executable(grpctest ${FlatBuffers_GRPCTest_SRCS}) |
Yuri Finkelstein | 61f4a46 | 2017-12-21 06:49:00 -1000 | [diff] [blame] | 359 | target_link_libraries(grpctest grpc++_unsecure grpc_unsecure gpr pthread dl) |
Wouter van Oortmerssen | 48f37f9 | 2016-04-13 18:16:05 -0700 | [diff] [blame] | 360 | endif() |
| 361 | |
Dmitry Volosnykh | daf0a42 | 2018-02-16 00:39:15 +0300 | [diff] [blame] | 362 | include(CMake/Version.cmake) |
| 363 | |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 364 | if(FLATBUFFERS_INSTALL) |
Sergey Avseyev | 2edb1dc | 2017-11-06 21:38:53 +0300 | [diff] [blame] | 365 | include(GNUInstallDirs) |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 366 | |
Sergey Avseyev | 2edb1dc | 2017-11-06 21:38:53 +0300 | [diff] [blame] | 367 | install(DIRECTORY include/flatbuffers DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 368 | |
| 369 | set(FB_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/flatbuffers") |
| 370 | |
Dmitry Volosnykh | daf0a42 | 2018-02-16 00:39:15 +0300 | [diff] [blame] | 371 | configure_file(CMake/FlatbuffersConfigVersion.cmake.in FlatbuffersConfigVersion.cmake @ONLY) |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 372 | install( |
Dmitry Volosnykh | daf0a42 | 2018-02-16 00:39:15 +0300 | [diff] [blame] | 373 | FILES "CMake/FlatbuffersConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/FlatbuffersConfigVersion.cmake" |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 374 | DESTINATION ${FB_CMAKE_DIR} |
| 375 | ) |
| 376 | |
Martell Malone | 79d3cb6 | 2015-07-22 13:18:59 +0100 | [diff] [blame] | 377 | if(FLATBUFFERS_BUILD_FLATLIB) |
Bastien Brunnenstein | ba08b0e | 2017-11-30 17:45:58 +0100 | [diff] [blame] | 378 | if(CMAKE_VERSION VERSION_LESS 3.0) |
| 379 | install( |
| 380 | TARGETS flatbuffers EXPORT FlatbuffersTargets |
| 381 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 382 | ) |
| 383 | else() |
| 384 | install( |
| 385 | TARGETS flatbuffers EXPORT FlatbuffersTargets |
| 386 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 387 | INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
| 388 | ) |
| 389 | endif() |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 390 | |
| 391 | install(EXPORT FlatbuffersTargets |
| 392 | FILE FlatbuffersTargets.cmake |
| 393 | NAMESPACE flatbuffers:: |
| 394 | DESTINATION ${FB_CMAKE_DIR} |
| 395 | ) |
Martell Malone | 79d3cb6 | 2015-07-22 13:18:59 +0100 | [diff] [blame] | 396 | endif() |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 397 | |
Leander Bessa Beernaert | 3ec8d7f | 2015-01-02 13:51:31 +0100 | [diff] [blame] | 398 | if(FLATBUFFERS_BUILD_FLATC) |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 399 | install( |
| 400 | TARGETS flatc EXPORT FlatcTargets |
| 401 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 402 | ) |
| 403 | |
| 404 | install( |
| 405 | EXPORT FlatcTargets |
| 406 | FILE FlatcTargets.cmake |
| 407 | NAMESPACE flatbuffers:: |
| 408 | DESTINATION ${FB_CMAKE_DIR} |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 409 | ) |
Leander Bessa Beernaert | 3ec8d7f | 2015-01-02 13:51:31 +0100 | [diff] [blame] | 410 | endif() |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 411 | |
changnet | a15659e | 2016-09-07 01:12:04 +0800 | [diff] [blame] | 412 | if(FLATBUFFERS_BUILD_SHAREDLIB) |
Bastien Brunnenstein | ba08b0e | 2017-11-30 17:45:58 +0100 | [diff] [blame] | 413 | if(CMAKE_VERSION VERSION_LESS 3.0) |
| 414 | install( |
| 415 | TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets |
| 416 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 417 | RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 418 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 419 | ) |
| 420 | else() |
| 421 | install( |
| 422 | TARGETS flatbuffers_shared EXPORT FlatbuffersSharedTargets |
| 423 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 424 | RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 425 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 426 | INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
| 427 | ) |
| 428 | endif() |
red1939 | 7e803c4 | 2017-11-16 21:51:25 +0100 | [diff] [blame] | 429 | |
| 430 | install( |
| 431 | EXPORT FlatbuffersSharedTargets |
| 432 | FILE FlatbuffersSharedTargets.cmake |
| 433 | NAMESPACE flatbuffers:: |
| 434 | DESTINATION ${FB_CMAKE_DIR} |
| 435 | ) |
changnet | a15659e | 2016-09-07 01:12:04 +0800 | [diff] [blame] | 436 | endif() |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 437 | endif() |
Daniel Nachbaur | 7a99b3c | 2014-07-15 15:09:36 +0200 | [diff] [blame] | 438 | |
Stewart Miles | 3f85183 | 2014-09-10 16:01:13 -0700 | [diff] [blame] | 439 | if(FLATBUFFERS_BUILD_TESTS) |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 440 | enable_testing() |
| 441 | |
Wouter van Oortmerssen | 7b80535 | 2014-09-23 11:55:42 -0700 | [diff] [blame] | 442 | file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tests" DESTINATION |
| 443 | "${CMAKE_CURRENT_BINARY_DIR}") |
Zbigniew Mandziejewicz | 3f8700b | 2014-09-16 00:50:23 +0800 | [diff] [blame] | 444 | add_test(NAME flattests COMMAND flattests) |
Sumant Tambe | e757854 | 2018-08-30 16:43:22 -0700 | [diff] [blame] | 445 | if(FLATBUFFERS_BUILD_GRPCTEST) |
| 446 | add_test(NAME grpctest COMMAND grpctest) |
| 447 | endif() |
Stewart Miles | 3f85183 | 2014-09-10 16:01:13 -0700 | [diff] [blame] | 448 | endif() |
Johan Euphrosine | 331d2d8 | 2015-11-17 13:39:37 -0800 | [diff] [blame] | 449 | |
| 450 | include(CMake/BuildFlatBuffers.cmake) |
Vitaly Isaev | 928effd | 2015-05-13 15:15:59 +0300 | [diff] [blame] | 451 | |
Marc Butler | 4567b13 | 2019-02-22 06:06:04 +1100 | [diff] [blame] | 452 | if(UNIX) |
| 453 | # Use of CPack only supported on Linux systems. |
| 454 | if(FLATBUFFERS_PACKAGE_DEBIAN) |
| 455 | include(CMake/PackageDebian.cmake) |
| 456 | endif() |
| 457 | if (FLATBUFFERS_PACKAGE_REDHAT) |
| 458 | include(CMake/PackageRedhat.cmake) |
| 459 | endif() |
| 460 | include(CPack) |
Vitaly Isaev | 928effd | 2015-05-13 15:15:59 +0300 | [diff] [blame] | 461 | endif() |