I am using protobuf_generate_cpp() in order to generate *.cc and *.h files from the *.proto file but it is not getting executed. I do not get any error message, the lines are just skipped. The CMakeLists.txt file looks something like this:
cmake_minimum_required(VERSION 3.1.2)
cmake_policy(SET CMP0028 NEW)
project(ProjectName CXX C)
execute_process(COMMAND conan install . WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY})
include(conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
find_package(Protobuf REQUIRED)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS /path/to/NAME.proto)
add_custom_command(
OUTPUT NAME.pbs.h
OUTPUT NAME.pbs.cc
DEPENDS NAME.proto
COMMAND protoc --cpp_out=$(CMAKE_BINARY_SOURCE_DIR) --proto_path=../path/to/NAME.proto
)
set(ProjectName-HeaderFiles
${ProjectName-HeaderFiles}
<list of all header files>
)
set(ProjectName-SourceFiles
${ProjectName-SourceFiles}
<list of all source files>
)
add_executable(ProjectName ${PROTO_SRCS} ${PROTO_HDRS}
<list of all other executables>
)
add_definitions(
-D_CONSOLE
-DWIN32
-D_DEBUG
-DSTANDALONE_PROGRAM
)
include_directories(
<list of all include paths>
)
target_link_libraries( ProjectName
PUBLIC
CONAN_PKG::Protobuf
LIB1
LIB2
)
My solution is created @location CMAKE_BINARY_SOURCE_DIR but NAME.pb.h and NAME.pb.cc files do not get created. Could someone let me know what the issue might be? Any suggestions are appreciated.