Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flatbuffers: conan v2 support #12702

Merged
merged 1 commit into from
Aug 31, 2022

Conversation

SpaceIm
Copy link
Contributor

@SpaceIm SpaceIm commented Aug 30, 2022

Specify library name and version: lib/1.0

This is also a good place to share with all of us why you are submitting this PR (specially if it is a new addition to ConanCenter): is it a dependency of other libraries you want to package? Are you the author of the library? Thanks!


  • I've read the guidelines for contributing.
  • I've followed the PEP8 style guides for Python code in the recipes.
  • I've used the latest Conan client version.
  • I've tried at least one configuration locally with the conan-center hook activated.

Comment on lines +84 to +86
tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
# Relocatable shared libs on Macos
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think the advice should be for deciding on using cache variables? The conan docs are not the most intuitive

I want to say

anything that needs to be set before the call to project or cmake_min_version

but that's not super obvious -- so my current train of thought is

whenever you use set a CMAKE_ prefixed var

I havent seen any downside yet but Looking for a second opinion 🙏

Suggested change
tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
# Relocatable shared libs on Macos
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW"
tc.cache_variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
# Relocatable shared libs on Macos
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0042"] = "NEW"

Copy link
Contributor Author

@SpaceIm SpaceIm Aug 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've described some cases in a conan issue conan-io/conan#11937 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the link!

@conan-center-bot
Copy link
Collaborator

All green in build 1 (44994d77333911316836d2215e6e9a0f43c605ac):

  • flatbuffers/2.0.5@:
    All packages built successfully! (All logs)

    🔸 Informative: This recipe is not ready for Conan v2

    We have started the migration process to Conan v2 and exporting recipes successfully will be required in the future.
    This is just an informative note to gain awareness about the process, no need to take any action. The plan is to enforce smaller steps that are easier to fix and, eventually, this conan export step will work.
    See the recipe migration guide to know more about the changes required.

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py", line 2, in <module>
        from conan.tools.apple import is_apple_os
    ImportError: cannot import name 'is_apple_os' from 'conan.tools.apple' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/tools/apple/__init__.py)
    
  • flatbuffers/2.0.0@:
    All packages built successfully! (All logs)

    🔸 Informative: This recipe is not ready for Conan v2

    We have started the migration process to Conan v2 and exporting recipes successfully will be required in the future.
    This is just an informative note to gain awareness about the process, no need to take any action. The plan is to enforce smaller steps that are easier to fix and, eventually, this conan export step will work.
    See the recipe migration guide to know more about the changes required.

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py", line 2, in <module>
        from conan.tools.apple import is_apple_os
    ImportError: cannot import name 'is_apple_os' from 'conan.tools.apple' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/tools/apple/__init__.py)
    
  • flatbuffers/1.12.0@:
    All packages built successfully! (All logs)

    🔸 Informative: This recipe is not ready for Conan v2

    We have started the migration process to Conan v2 and exporting recipes successfully will be required in the future.
    This is just an informative note to gain awareness about the process, no need to take any action. The plan is to enforce smaller steps that are easier to fix and, eventually, this conan export step will work.
    See the recipe migration guide to know more about the changes required.

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py", line 2, in <module>
        from conan.tools.apple import is_apple_os
    ImportError: cannot import name 'is_apple_os' from 'conan.tools.apple' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/tools/apple/__init__.py)
    
  • flatbuffers/1.11.0@:
    All packages built successfully! (All logs)

    🔸 Informative: This recipe is not ready for Conan v2

    We have started the migration process to Conan v2 and exporting recipes successfully will be required in the future.
    This is just an informative note to gain awareness about the process, no need to take any action. The plan is to enforce smaller steps that are easier to fix and, eventually, this conan export step will work.
    See the recipe migration guide to know more about the changes required.

    ERROR: Error loading conanfile at '/home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py': Unable to load conanfile in /home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/conan/w/prod_cci_PR-12702/recipes/flatbuffers/all/conanfile.py", line 2, in <module>
        from conan.tools.apple import is_apple_os
    ImportError: cannot import name 'is_apple_os' from 'conan.tools.apple' (/opt/pyenv/versions/3.7.13/lib/python3.7/site-packages/conan/tools/apple/__init__.py)
    

@conan-center-bot conan-center-bot merged commit 0dee7c0 into conan-io:master Aug 31, 2022
@SpaceIm SpaceIm deleted the flatbuffers-conan-v2 branch August 31, 2022 11:48
@sourcedelica
Copy link
Contributor

Hi - I just picked up this change in my fork of CCI and ran into issues when I tried to build with Conan 1.52.

flatbuffers/2.0.7: Calling build()
flatbuffers/2.0.7: CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/eric/.conan/data/flatbuffers/2.0.7/_/_/build/038baac88f4c7bfa972ce5adac1616bed8fe2ef4/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/eric/.conan/data/flatbuffers/2.0.7/_/_/package/038baac88f4c7bfa972ce5adac1616bed8fe2ef4" -DCMAKE_POLICY_DEFAULT_CMP0042="NEW" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Debug" "/home/eric/.conan/data/flatbuffers/2.0.7/_/_/build/038baac88f4c7bfa972ce5adac1616bed8fe2ef4/src"
CMake Error at CMakeLists.txt:23 (project):
  VERSION ".." format invalid.


-- Configuring incomplete, errors occurred!
flatbuffers/2.0.7:
flatbuffers/2.0.7: ERROR: Package '038baac88f4c7bfa972ce5adac1616bed8fe2ef4' build failed

The problem is that none of the CMake variables are set in build() anymore. I tried building with

conan create . 2.0.7@

(I've added the 2.0.7 and 2.0.8 sources to my fork's conandata.yml).

Thanks,

@SpaceIm
Copy link
Contributor Author

SpaceIm commented Aug 31, 2022

It's specific to these new versions of flatbuffers (not in CCI), so it's unrelated to conan 1.52 and conan center. flatbuffers 2.0.5 recipe works fine. It's a consequence of google/flatbuffers@0471fa8, so will start to see such error if we package flatbuffers >= 2.0.7. And the fix is to inject VERSION_MAJOR etc with tc.cache_variables instead of tc.variables.

@sourcedelica
Copy link
Contributor

That worked - thanks!

diff --git a/recipes/flatbuffers/all/conanfile.py b/recipes/flatbuffers/all/conanfile.py
index ad32669a4..0ea6e0846 100644
--- a/recipes/flatbuffers/all/conanfile.py
+++ b/recipes/flatbuffers/all/conanfile.py
@@ -77,9 +77,9 @@ class FlatbuffersConan(ConanFile):
         tc.variables["FLATBUFFERS_LIBCXX_WITH_CLANG"] = False
         # Mimic upstream CMake/Version.cmake removed in _patch_sources()
         version = Version(self.version)
-        tc.variables["VERSION_MAJOR"] = version.major
-        tc.variables["VERSION_MINOR"] = version.minor
-        tc.variables["VERSION_PATCH"] = version.patch
+        tc.cache_variables["VERSION_MAJOR"] = version.major.value
+        tc.cache_variables["VERSION_MINOR"] = version.minor.value
+        tc.cache_variables["VERSION_PATCH"] = version.patch.value
         # For msvc shared
         tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
         # Relocatable shared libs on Macos

@bog-dan-ro
Copy link
Contributor

This patch broke the compilation for Android armv8 ...

$ conan install flatbuffers/2.0.5@ --update  --build=outdated --profile:host android_armv8 --profile:build default
Configuration (profile_host):
[settings]
arch=armv8
arch_build=x86_64
build_type=Release
compiler=clang
compiler.libcxx=c++_shared
compiler.version=9
os=Android
os.api_level=21
os_build=Linux
[options]
[build_requires]
*: android-ndk/r21e
[env]

Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux
os_build=Linux
[options]
[build_requires]
[env]

....
flatbuffers/2.0.5: Applying build-requirement: android-ndk/r21e
flatbuffers/2.0.5: WARN: Build folder is dirty, removing it: /home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f
flatbuffers/2.0.5: Copying sources to build folder
flatbuffers/2.0.5: Building your package in /home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f
flatbuffers/2.0.5: Generator txt created conanbuildinfo.txt
flatbuffers/2.0.5: Calling generate()
flatbuffers/2.0.5: Aggregating env generators
[HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] OK. 'fPIC' option found and apparently well managed
[HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] OK
flatbuffers/2.0.5: Calling build()
flatbuffers/2.0.5: CMake command: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/package/a2ccebaee30b07c93935ff3643d57c8239e9ee4f" -DCMAKE_POLICY_DEFAULT_CMP0042="NEW" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/src"
-- Using Conan toolchain: /home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/generators/conan_toolchain.cmake
-- ANDROID_PLATFORM not set. Defaulting to minimum supported version
16.
-- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: /home/bogdan/.conan/data/android-ndk/r21e/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-- Check for working CXX compiler: /home/bogdan/.conan/data/android-ndk/r21e/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - broken
CMake Error at /usr/share/cmake-3.24/Modules/CMakeTestCXXCompiler.cmake:62 (message):
  The C++ compiler

    "/home/bogdan/.conan/data/android-ndk/r21e/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/Release/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_6f6ed/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_6f6ed.dir/build.make CMakeFiles/cmTC_6f6ed.dir/build
    gmake[1]: Entering directory '/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/Release/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_6f6ed.dir/testCXXCompiler.cxx.o
    /home/bogdan/.conan/data/android-ndk/r21e/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=aarch64-none-linux-android21 --gcc-toolchain=/home/bogdan/.conan/data/android-ndk/r21e/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/toolchains/llvm/prebuilt/linux-x86_64 --sysroot=/home/bogdan/.conan/data/android-ndk/r21e/_/_/package/4db1be536558d833e52e862fd84d64d75c2b3656/toolchains/llvm/prebuilt/linux-x86_64/sysroot   -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security    -fPIE -MD -MT CMakeFiles/cmTC_6f6ed.dir/testCXXCompiler.cxx.o -MF CMakeFiles/cmTC_6f6ed.dir/testCXXCompiler.cxx.o.d -o CMakeFiles/cmTC_6f6ed.dir/testCXXCompiler.cxx.o -c /home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/Release/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    clang++: error: the clang compiler does not support '-march=armv7-a'
    gmake[1]: *** [CMakeFiles/cmTC_6f6ed.dir/build.make:79: CMakeFiles/cmTC_6f6ed.dir/testCXXCompiler.cxx.o] Error 1
    gmake[1]: Leaving directory '/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/Release/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:127: cmTC_6f6ed/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:5 (project)


-- Configuring incomplete, errors occurred!
See also "/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/Release/CMakeFiles/CMakeOutput.log".
See also "/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/Release/CMakeFiles/CMakeError.log".
flatbuffers/2.0.5: 
flatbuffers/2.0.5: ERROR: Package 'a2ccebaee30b07c93935ff3643d57c8239e9ee4f' build failed
flatbuffers/2.0.5: WARN: Build folder /home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/Release
ERROR: flatbuffers/2.0.5: Error in build() method, line 112
        cmake.configure()
        ConanException: Error 1 while executing cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/package/a2ccebaee30b07c93935ff3643d57c8239e9ee4f" -DCMAKE_POLICY_DEFAULT_CMP0042="NEW" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/bogdan/.conan/data/flatbuffers/2.0.5/_/_/build/a2ccebaee30b07c93935ff3643d57c8239e9ee4f/src"

Why on earth is adding -march=armv7-a to compiler flags for an armv8 build?

@bog-dan-ro
Copy link
Contributor

#12795 fixes it.

ericLemanissier pushed a commit to ericLemanissier/conan-center-index that referenced this pull request Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants