CMakeLists.txt (1012B)
1 include(CTest) 2 3 # 4 # This projects depends headers generated from reflection.fbs but these 5 # are pre-generated in `include/flatcc/reflection` so we don't need to 6 # build them here. 7 # 8 # What we do build is a binary schema `monster.bfbs` for the monster 9 # sample, and the actual C source of this project. 10 # 11 12 set(INC_DIR "${PROJECT_SOURCE_DIR}/include") 13 set(GEN_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated") 14 set(FBS_DIR "${PROJECT_SOURCE_DIR}/samples/monster") 15 16 include_directories("${GEN_DIR}" "${INC_DIR}") 17 18 add_custom_target(gen_monster_bfbs ALL) 19 add_custom_command ( 20 TARGET gen_monster_bfbs 21 COMMAND ${CMAKE_COMMAND} -E make_directory "${GEN_DIR}" 22 COMMAND flatcc_cli --schema -o "${GEN_DIR}" "${FBS_DIR}/monster.fbs" 23 DEPENDS flatcc_cli "${FBS_DIR}/monster.fbs" 24 ) 25 add_executable(bfbs2json bfbs2json.c) 26 add_dependencies(bfbs2json gen_monster_bfbs) 27 target_link_libraries(bfbs2json flatccrt) 28 29 if (FLATCC_TEST) 30 add_test(bfbs2json bfbs2json${CMAKE_EXECUTABLE_SUFFIX} ${GEN_DIR}/monster.bfbs) 31 endif()