blob: f50c491678585ac838a85ce4231f823f0cc8dee1 [file] [log] [blame]
Wouter van Oortmerssen26a30732014-01-27 16:52:49 -08001cmake_minimum_required(VERSION 2.8)
2
3project(FlatBuffers)
4
5# NOTE: Code coverage only works on Linux & OSX.
6option(FLATBUFFERS_CODE_COVERAGE "Enable the code coverage build option." OFF)
7
8set(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
rw74d5f372014-07-11 16:12:35 -070015 src/idl_gen_go.cpp
Wouter van Oortmerssen26a30732014-01-27 16:52:49 -080016 src/idl_gen_text.cpp
17 src/flatc.cpp
18)
19
20set(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
31set(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
38set(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
49set(CMAKE_BUILD_TYPE Debug)
50
51# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
52# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
53
54if(CMAKE_COMPILER_IS_GNUCXX)
55 add_definitions("-std=c++0x")
56 add_definitions("-Wall")
57endif()
58if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
59 add_definitions("-std=c++0x")
60endif()
61
62if(FLATBUFFERS_CODE_COVERAGE)
63 add_definitions("-g -fprofile-arcs -ftest-coverage")
64 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
65endif()
66
67include_directories(include)
68
69add_executable(flatc ${FlatBuffers_Compiler_SRCS})
70add_executable(flattests ${FlatBuffers_Tests_SRCS})
71add_executable(flatsamplebinary ${FlatBuffers_Sample_Binary_SRCS})
72add_executable(flatsampletext ${FlatBuffers_Sample_Text_SRCS})
73
Daniel Nachbaur7a99b3c2014-07-15 15:09:36 +020074install(DIRECTORY include/flatbuffers DESTINATION include)
75install(TARGETS flatc DESTINATION bin)
76
Wouter van Oortmerssen26a30732014-01-27 16:52:49 -080077add_test(NAME flattest
78 CONFIGURATIONS Debug
79 WORKING_DIRECTORY tests
80 COMMAND flattests)