1cmake_minimum_required(VERSION 2.8) 2project(NANOPB_CMAKE_SIMPLE C) 3 4set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../extra) 5find_package(Nanopb REQUIRED) 6include_directories(${NANOPB_INCLUDE_DIRS}) 7 8nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS simple.proto) 9include_directories(${CMAKE_CURRENT_BINARY_DIR}) 10#add_custom_target(generate_proto_sources DEPENDS ${PROTO_SRCS} ${PROTO_HDRS}) 11set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS} 12 PROPERTIES GENERATED TRUE) 13 14set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -g -O0") 15 16add_executable(simple simple.c ${PROTO_SRCS} ${PROTO_HDRS}) 17