Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame^] | 1 | cmake_minimum_required(VERSION 2.8) |
| 2 | |
| 3 | project(FlatBuffers) |
| 4 | |
| 5 | # NOTE: Code coverage only works on Linux & OSX. |
| 6 | option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF) |
| 7 | |
| 8 | set(FlatBuffers_Compiler_SRCS |
| 9 | include/flatbuffers/flatbuffers.h |
| 10 | include/flatbuffers/idl.h |
| 11 | include/flatbuffers/util.h |
| 12 | src/idl_parser.cpp |
| 13 | src/idl_gen_cpp.cpp |
| 14 | src/idl_gen_java.cpp |
| 15 | src/idl_gen_text.cpp |
| 16 | src/flatc.cpp |
| 17 | ) |
| 18 | |
| 19 | set(FlatBuffers_Tests_SRCS |
| 20 | include/flatbuffers/flatbuffers.h |
| 21 | include/flatbuffers/idl.h |
| 22 | include/flatbuffers/util.h |
| 23 | src/idl_parser.cpp |
| 24 | src/idl_gen_text.cpp |
| 25 | tests/test.cpp |
| 26 | # file generate by running compiler on tests/monster_test.fbs |
| 27 | tests/monster_test_generated.h |
| 28 | ) |
| 29 | |
| 30 | set(FlatBuffers_Sample_Binary_SRCS |
| 31 | include/flatbuffers/flatbuffers.h |
| 32 | samples/sample_binary.cpp |
| 33 | # file generate by running compiler on samples/monster.fbs |
| 34 | samples/monster_generated.h |
| 35 | ) |
| 36 | |
| 37 | set(FlatBuffers_Sample_Text_SRCS |
| 38 | include/flatbuffers/flatbuffers.h |
| 39 | include/flatbuffers/idl.h |
| 40 | include/flatbuffers/util.h |
| 41 | src/idl_parser.cpp |
| 42 | src/idl_gen_text.cpp |
| 43 | samples/sample_text.cpp |
| 44 | # file generate by running compiler on samples/monster.fbs |
| 45 | samples/monster_generated.h |
| 46 | ) |
| 47 | |
| 48 | set(CMAKE_BUILD_TYPE Debug) |
| 49 | |
| 50 | # source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS}) |
| 51 | # source_group(Tests FILES ${FlatBuffers_Tests_SRCS}) |
| 52 | |
| 53 | if(CMAKE_COMPILER_IS_GNUCXX) |
| 54 | add_definitions("-std=c++0x") |
| 55 | add_definitions("-Wall") |
| 56 | endif() |
| 57 | if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") |
| 58 | add_definitions("-std=c++0x") |
| 59 | endif() |
| 60 | |
| 61 | if(FLATBUFFERS_CODE_COVERAGE) |
| 62 | add_definitions("-g -fprofile-arcs -ftest-coverage") |
| 63 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") |
| 64 | endif() |
| 65 | |
| 66 | include_directories(include) |
| 67 | |
| 68 | add_executable(flatc ${FlatBuffers_Compiler_SRCS}) |
| 69 | add_executable(flattests ${FlatBuffers_Tests_SRCS}) |
| 70 | add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS}) |
| 71 | add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS}) |
| 72 | |
| 73 | add_test(NAME flattest |
| 74 | CONFIGURATIONS Debug |
| 75 | WORKING_DIRECTORY tests |
| 76 | COMMAND flattests) |