Closed mjvankampen closed 5 years ago
Could you please exemplify your thoughts with a CMake file and the commands that you run?
If you are looking for the macro FLATBUFFERS_GENERATE_C_HEADERS
we don't have such support for now because we can't export cmake files directly. We are discussing about some better way to make those macros available here https://github.com/conan-io/conan/issues/5798
That issue is the same as I am having indeed. My workflow is to:
For me the advantage of using it in this way is that my project is not dependent on Conan. I can build everything myself, set the correct module path and such and my cmake file will work.
As the software I am building is aimed to run for 20-30 years I rather limit my dependencies on external tools. But I do like to use them as long as possible because they make my life much easier!
Something like:
# Include conan variables, can also be done on command line
set(CMAKE_PROJECT_TEST_INCLUDE "${CMAKE_BINARY_DIR}/conan_paths.cmake")
project(TEST VERSION 0.1.0)
# Set minimum global cmake version
cmake_minimum_required(VERSION 3.15.0)
find_package(FlatBuffers REQUIRED)
set(FBS_FILES
flatbuffers/test.fbs
)
set(GENERATED_DIR "${CMAKE_CURRENT_BINARY_DIR}/generated")
build_flatbuffers("${FBS_FILES}" "${CMAKE_CURRENT_SOURCE_DIR}/flatbuffers" flatbuffers_lib "" "${GENERATED_DIR }/fbgenerated" "" "")
add_dependencies(test flatbuffers_lib)
get_target_property(FLATBUFFERS_GENERATED_DIR flatbuffers_lib "GENERATED_INCLUDES_DIR")
file(GLOB GENERATED_FBS_FILES "${FLATBUFFERS_GENERATED_DIR}/*.h")
target_sources(test INTERFACE ${GENERATED_FBS_FILES})
Unfortunately is not possible using the current stage of flatbuffers in Conan Center Index, but you can try the version maintained by the author, which contains all CMake files, including these macros that you mentioned.
https://bintray.com/aardappel/flatbuffers/flatbuffers%3Agoogle
conan install -r conan-center flatbuffers/1.11.0@google/stable
We are working in solution to export CMake macros, but as it requires a new feature in Conan, it can take much time than you can wait for now.
Hmmm so this means that it becomes infeasible to manually manage your packages or use conan without changing your cmakefile if you are using packages from Conan Center Index? Because you have to do a different call to find_package if you use conan generated vs directly from the authors repo? For me that seems like a loss to be honest.
Anyway that is not for this issue, thank you for help (and your lots of work, conan rocks!)!
When using flatbuffers with the cmake_paths generator (which is nice as it does not require any conan references in your cmake file) find_package will not work as the flatbuffers/flatc do not include the relevant cmake files (which also includes build_flatbuffers). Would it be possible to add these to the package?
[settings] arch=x86_64 arch_build=x86_64 os=Neutrino os_build=Windows compiler=qcc compiler.libcxx=cxx compiler.version=5.4 os.version=7.0
flatbuffers:compiler=qcc flatbuffers:compiler.libcxx=cxx flatbuffers:compiler.version=5.4 flatbuffers:compiler.cppstd=gnu11