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 |
rw | 74d5f37 | 2014-07-11 16:12:35 -0700 | [diff] [blame] | 15 | src/idl_gen_go.cpp |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 16 | src/idl_gen_text.cpp |
| 17 | src/flatc.cpp |
| 18 | ) |
| 19 | |
| 20 | set(FlatBuffers_Tests_SRCS |
| 21 | include/flatbuffers/flatbuffers.h |
| 22 | include/flatbuffers/idl.h |
| 23 | include/flatbuffers/util.h |
| 24 | src/idl_parser.cpp |
| 25 | src/idl_gen_text.cpp |
| 26 | tests/test.cpp |
| 27 | # file generate by running compiler on tests/monster_test.fbs |
| 28 | tests/monster_test_generated.h |
| 29 | ) |
| 30 | |
| 31 | set(FlatBuffers_Sample_Binary_SRCS |
| 32 | include/flatbuffers/flatbuffers.h |
| 33 | samples/sample_binary.cpp |
| 34 | # file generate by running compiler on samples/monster.fbs |
| 35 | samples/monster_generated.h |
| 36 | ) |
| 37 | |
| 38 | set(FlatBuffers_Sample_Text_SRCS |
| 39 | include/flatbuffers/flatbuffers.h |
| 40 | include/flatbuffers/idl.h |
| 41 | include/flatbuffers/util.h |
| 42 | src/idl_parser.cpp |
| 43 | src/idl_gen_text.cpp |
| 44 | samples/sample_text.cpp |
| 45 | # file generate by running compiler on samples/monster.fbs |
| 46 | samples/monster_generated.h |
| 47 | ) |
| 48 | |
| 49 | set(CMAKE_BUILD_TYPE Debug) |
| 50 | |
| 51 | # source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS}) |
| 52 | # source_group(Tests FILES ${FlatBuffers_Tests_SRCS}) |
| 53 | |
Stefan Eilemann | 52f4f45 | 2014-07-26 13:12:56 +0200 | [diff] [blame^] | 54 | if(APPLE) |
| 55 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -Wall") |
| 56 | elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") |
| 57 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall") |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 58 | endif() |
| 59 | |
| 60 | if(FLATBUFFERS_CODE_COVERAGE) |
Stefan Eilemann | 52f4f45 | 2014-07-26 13:12:56 +0200 | [diff] [blame^] | 61 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fprofile-arcs -ftest-coverage") |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 62 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") |
| 63 | endif() |
| 64 | |
| 65 | include_directories(include) |
| 66 | |
| 67 | add_executable(flatc ${FlatBuffers_Compiler_SRCS}) |
| 68 | add_executable(flattests ${FlatBuffers_Tests_SRCS}) |
| 69 | add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS}) |
| 70 | add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS}) |
| 71 | |
Daniel Nachbaur | 7a99b3c | 2014-07-15 15:09:36 +0200 | [diff] [blame] | 72 | install(DIRECTORY include/flatbuffers DESTINATION include) |
| 73 | install(TARGETS flatc DESTINATION bin) |
| 74 | |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 75 | add_test(NAME flattest |
| 76 | CONFIGURATIONS Debug |
| 77 | WORKING_DIRECTORY tests |
| 78 | COMMAND flattests) |