Added option to disable build of tests and samples.
Added FLATBUFFERS_BUILD_TESTS option which can be used to disable
the build of flatbuffers tests and samples.
Tested:
Verified tests and samples are no longer built on Linux when
FLATBUFFERS_BUILD_TESTS=OFF.
Change-Id: Ic23ab827849ba2c4481de9ca86adc1ab8e6b828c
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 57fdba0..2a6323c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,7 @@
# NOTE: Code coverage only works on Linux & OSX.
option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
+option(FLATBUFFERS_BUILD_TESTS "Enable the build of tests and samples." ON)
set(FlatBuffers_Compiler_SRCS
include/flatbuffers/flatbuffers.h
@@ -68,14 +69,18 @@
include_directories(include)
add_executable(flatc ${FlatBuffers_Compiler_SRCS})
-add_executable(flattests ${FlatBuffers_Tests_SRCS})
-add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
-add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
+if(FLATBUFFERS_BUILD_TESTS)
+ add_executable(flattests ${FlatBuffers_Tests_SRCS})
+ add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
+ add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
+endif()
install(DIRECTORY include/flatbuffers DESTINATION include)
install(TARGETS flatc DESTINATION bin)
-add_test(NAME flattest
- CONFIGURATIONS Debug
- WORKING_DIRECTORY tests
- COMMAND flattests)
+if(FLATBUFFERS_BUILD_TESTS)
+ add_test(NAME flattest
+ CONFIGURATIONS Debug
+ WORKING_DIRECTORY tests
+ COMMAND flattests)
+endif()