facebook / fbthrift

Facebook's branch of Apache Thrift, including a new C++ server.
Apache License 2.0
2.55k stars 608 forks source link

ThriftLibrary.cmake is invalid #526

Closed CJCombrink closed 1 year ago

CJCombrink commented 1 year ago

I can't get the ThriftLibrary.cmake to work as expected.

I have set the following:

find_program(THRIFT1    NAMES thrift1    HINTS /opt/fbthrift/fbthrift/bin)
find_library(THRIFTCPP2 NAMES thriftcpp2 HINTS /opt/fbthrift/fbthrift/lib)
message(WARNING "THRIFT1   : ${THRIFT1}")
message(WARNING "THRIFTCPP2: ${THRIFTCPP2}")

And it produces

CMake Warning at CMakeLists.txt:23 (message):
  THRIFT1 : /opt/fbthrift/fbthrift/bin/thrift1
CMake Warning at CMakeLists.txt:24 (message):
  THRIFTCPP2: /opt/fbthrift/fbthrift/lib/libthriftcpp2.a

Calling thrift_library(...) with generator cpp2 does not have any affect and no files are generated. From searching I found I must specify the generator as mstch_cpp2 then files are generated, but the library are not building with the following error

c++: error: /my/path/build_fbthrift/common/gen-mstch_cpp2/all_includes_constants.cpp: No such file or directory

On further inspection I see that the generated folder on disk is correctly called gen-cpp2 and not (gen-mstch_cpp2 as expected by ThriftLibrary.cmake):

$ ls common/
gen-cpp2
thedavekwon commented 1 year ago

Hi, have you tried following the example in https://github.com/facebook/fbthrift/blob/fbacb59d3f1afe4ba9217a63a56f139ff15384d4/thrift/example/if/CMakeLists.txt?

CJCombrink commented 1 year ago

@thedavekwon

I went back to double check. I see my original post was incorrect. When using cpp2 it works as expected, I was starting out with cpp as commented in the CMake file

@language  - The generator to use (cpp, cpp2 or py3)

Then during the struggles I switched to mstch_cpp2 as the language which broke things. Using cpp2 is correct.

thrift1 does not seem to support a cpp generator.

thedavekwon commented 1 year ago

glad you figured it out! Good catch! Closing the issue.