Repository navigation
Fix mixed target_link_libraries signature for common_flags in ReactNative-application.cmake - #60307
JagguDada01 wants to merge 1 commit into
Conversation
|
Hi @JagguDada01! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Summary:
Fixes Android CMake configure failures when an autolinked library or app-level codegen target uses the keyword signature of
target_link_libraries(PRIVATE,PUBLIC, orINTERFACE).Problem
ReactNative-application.cmakelinkscommon_flagsonto each target inAUTOLINKED_LIBRARIESandAPP_CODEGEN_TARGETusing the plaintarget_link_libraries(<target> common_flags)signature. CMake forbids mixing plain and keyword signatures on the same target, so any autolinked library whose ownCMakeLists.txtusesPRIVATE,PUBLIC, orINTERFACEfails CMake configure.Root Cause
Generated codegen targets (e.g. from
GenerateModuleJniH.js) use the plaintarget_link_librariessignature, while third-party native libraries often usePRIVATE/PUBLIC/INTERFACE. Calling either plaintarget_link_libraries(... common_flags)or keywordtarget_link_libraries(... PRIVATE common_flags)fails when the target used the opposite signature.Solution
Add a
target_link_common_flags(target)helper inpackages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmakethat attachescommon_flagsvia target properties (LINK_LIBRARIES, orINTERFACE_LINK_LIBRARIESforINTERFACE_LIBRARYtargets) after resolving aliases and skipping missing/imported targets, and call it for bothAUTOLINKED_LIBRARIESandAPP_CODEGEN_TARGET. This preservescommon_flagspropagation (folly_FLAGSandRN_STRICT_API) regardless of whichtarget_link_librariessignature the target used.Fixes #60000
Changelog:
[ANDROID] [FIXED] - Avoid mixing
target_link_librariessignatures when linkingcommon_flagsto autolinked and codegen targets inReactNative-application.cmakeTest Plan:
Verified locally using
cmake(v4.4.3) againstpackages/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmakewith mockedReactAndroid/fbjnipackage targets across three scenarios:RN_STRICT_API=OFFconfigure & build with:SHAREDautolinked library usingtarget_link_libraries(... PRIVATE ...)STATICautolinked library usingtarget_link_libraries(... PUBLIC ...)OBJECTautolinked library using plaintarget_link_libraries(...)INTERFACElibrary,ALIAStarget,IMPORTEDtarget, and non-existent targetAPP_CODEGEN_TARGET) usingPRIVATEVerified every compiled translation unit received
folly_FLAGS(FOLLY_USE_LIBCPP) and linked cleanly intoappmodules.RN_STRICT_API=ONconfigure & build verifyingRN_STRICT_APIis defined on all targets alongsidefolly_FLAGS.APP_CODEGEN_TARGETdirectory configure & build.(Full Android Gradle/NDK
rn-testerbuild was not run locally because Android NDK/node_modules are not installed in this environment; CI Android checks will cover the full NDK build.)