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

Fix libjpeg-turbo build for Android #8592

Merged

Conversation

kdsx
Copy link
Contributor

@kdsx kdsx commented Dec 31, 2021

It didn't work for Android/armv7 because the recipe specifies
CMAKE_SYSTEM_PROCESSOR=armv7 which is not known to Android NDK CMake scripts.
However Conan specifies enough details to CMake in Android build, so there's
no need to specify CMAKE_SYSTEM_PROCESSOR manually.

Specify library name and version: libjpeg-turbo/2.1.2


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

@conan-center-bot

This comment has been minimized.

@SpaceIm
Copy link
Contributor

SpaceIm commented Dec 31, 2021

Here is a more robust approach suggested in abseil: #8577 (comment)

@@ -117,7 +117,7 @@ def _configure_cmake(self):
if tools.Version(self.version) <= "2.1.0":
self._cmake.definitions["CMAKE_MACOSX_BUNDLE"] = False # avoid configuration error if building for iOS/tvOS/watchOS

if tools.cross_building(self):
if tools.cross_building(self) and not self.settings.os == "Android":
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not an actual fix.
The real bug is conan not respecting CONAN_CMAKE_SYSTEM_PROCESSOR when cross building.

See this bug report: conan-io/conan#9736

Copy link
Contributor

Choose a reason for hiding this comment

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

Does conan automagically set CONAN_CMAKE_SYSTEM_PROCESSOR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, to self.settings.arch.
Overriding it in the profiles does not work when cross building.
You can find a short repro in the issue (without requiring downloading the android ndk).

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, to self.settings.arch.

But it's wrong anyway in some cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, my issue is about being unable to override CONAN_CMAKE_SYSTEM_PROCESSOR.

It didn't work for Android/armv7 because the recipe specifies
CMAKE_SYSTEM_PROCESSOR=armv7 which is not known to Android NDK CMake scripts.
However the NDK toolchain does not require this variable (it sets the variable
itself), so it does not need to be specified at all.
@kdsx kdsx force-pushed the fix_libjpeg_turbo_build_for_android branch from b13e177 to 5a122ee Compare January 3, 2022 21:08
@kdsx
Copy link
Contributor Author

kdsx commented Jan 3, 2022

Updated the MR using the suggested approach from the abseil recipe.

@conan-center-bot

This comment has been minimized.

@conan-center-bot
Copy link
Collaborator

All green in build 3 (5a122eee5f9b7e8dd3188975876b09cd96f86a26):

  • libjpeg-turbo/2.1.1@:
    All packages built successfully! (All logs)

  • libjpeg-turbo/2.0.5@:
    All packages built successfully! (All logs)

  • libjpeg-turbo/2.0.2@:
    All packages built successfully! (All logs)

  • libjpeg-turbo/2.1.2@:
    All packages built successfully! (All logs)

  • libjpeg-turbo/2.0.6@:
    All packages built successfully! (All logs)

  • libjpeg-turbo/2.0.4@:
    All packages built successfully! (All logs)

  • libjpeg-turbo/2.1.0@:
    All packages built successfully! (All logs)

@conan-center-bot conan-center-bot merged commit 4137735 into conan-io:master Jan 5, 2022
Comment on lines +8 to +10
if(NOT CMAKE_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR ${CONAN_LIBJPEG_SYSTEM_PROCESSOR})
endif()
Copy link
Contributor

@SpaceIm SpaceIm Jan 7, 2022

Choose a reason for hiding this comment

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

After some experimentations in libpng and using the same trick, I've found it should be:

if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR OR CMAKE_SYSTEM_PROCESSOR STREQUAL "")
    set(CMAKE_SYSTEM_PROCESSOR ${CONAN_LIBJPEG_SYSTEM_PROCESSOR})
endif()

Indeed, CMAKE_SYSTEM_PROCESSOR seems to always be defined, just empty by default if cross-building.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, no it's fine, it doesn't check if CMAKE_SYSTEM_PROCESSOR is defined, so it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"STREQUAL" check is surely more strict, but I can't imagine any sane value for this variable which could be rejected by simple "NOT".

However there are cases in CMake when its necessary to check a variable for emptiness. It's done simply by taking it's value in the quotes:

if("${VAR}" STREQUAL "")

There's no need to check if it's defined.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this check is perfectly fine, my bad, I thought the check was if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Really, I tried NOT DEFINED first, but it didn't work, so I switched to just NOT.

@SpaceIm SpaceIm mentioned this pull request Jan 7, 2022
4 tasks
miklelappo pushed a commit to miklelappo/conan-center-index that referenced this pull request Feb 9, 2022
It didn't work for Android/armv7 because the recipe specifies
CMAKE_SYSTEM_PROCESSOR=armv7 which is not known to Android NDK CMake scripts.
However the NDK toolchain does not require this variable (it sets the variable
itself), so it does not need to be specified at all.
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