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) |
Wouter van Oortmerssen | bc5fa9d | 2014-08-25 10:42:38 -0700 | [diff] [blame^] | 55 | set(CMAKE_CXX_FLAGS |
| 56 | "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++ -Wall -pedantic -Werror -Wextra") |
Stefan Eilemann | 52f4f45 | 2014-07-26 13:12:56 +0200 | [diff] [blame] | 57 | elseif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") |
Wouter van Oortmerssen | bc5fa9d | 2014-08-25 10:42:38 -0700 | [diff] [blame^] | 58 | set(CMAKE_CXX_FLAGS |
| 59 | "${CMAKE_CXX_FLAGS} -std=c++0x -Wall -pedantic -Werror -Wextra") |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 60 | endif() |
| 61 | |
| 62 | if(FLATBUFFERS_CODE_COVERAGE) |
Stefan Eilemann | 52f4f45 | 2014-07-26 13:12:56 +0200 | [diff] [blame] | 63 | 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] | 64 | set(CMAKE_EXE_LINKER_FLAGS |
| 65 | "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 66 | endif() |
| 67 | |
| 68 | include_directories(include) |
| 69 | |
| 70 | add_executable(flatc ${FlatBuffers_Compiler_SRCS}) |
| 71 | add_executable(flattests ${FlatBuffers_Tests_SRCS}) |
| 72 | add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS}) |
| 73 | add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS}) |
| 74 | |
Daniel Nachbaur | 7a99b3c | 2014-07-15 15:09:36 +0200 | [diff] [blame] | 75 | install(DIRECTORY include/flatbuffers DESTINATION include) |
| 76 | install(TARGETS flatc DESTINATION bin) |
| 77 | |
Wouter van Oortmerssen | 26a3073 | 2014-01-27 16:52:49 -0800 | [diff] [blame] | 78 | add_test(NAME flattest |
| 79 | CONFIGURATIONS Debug |
| 80 | WORKING_DIRECTORY tests |
| 81 | COMMAND flattests) |