axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
868 stars 195 forks source link

Live2D Android build issue #1406

Closed rh101 closed 11 months ago

rh101 commented 11 months ago

Live2d has the following in Live2D/CMakeLists.txt:

if (ANDROID)
    target_link_libraries(${LIB_NAME} INTERFACE Live2DCubismCore)
else()
    target_link_libraries(${LIB_NAME} Live2DCubismCore)
endif()

Then when it calls setup_ax_extension_config(${LIB_NAME}), it links with Axmol:

function(setup_ax_extension_config target_name)
  set(options DNTLINK opt_DNTLINK)
  cmake_parse_arguments(opt "" "${options}" ""
                          "" ${ARGN} )

  target_link_libraries(${target_name} ${_AX_CORE_LIB})
...

It results in the following error when running cmake for the Android build:

CMake Error at G:/game_engines/axmol/extensions/CMakeLists.txt:14 (target_link_libraries):
The keyword signature for target_link_libraries has already been used with
the target "Live2D".  All uses of target_link_libraries with a target must
be either all-keyword or all-plain.

Is the "INTERFACE" scope required for Android in this line? target_link_libraries(${LIB_NAME} INTERFACE Live2DCubismCore)

If it is required, then a suggested fix:

Adjust setup_ax_extension_config to allow for optional link scope argument, for example:

function(setup_ax_extension_config target_name)
  set(options DNTLINK opt_DNTLINK)
  set(options LINK_SCOPE opt_LINK_SCOPE)
  cmake_parse_arguments(opt "" "${options}" ""
                          "" ${ARGN} )

  target_link_libraries(${target_name} ${opt_LINK_SCOPE} ${_AX_CORE_LIB})

Which would be called like this: setup_ax_extension_config(${LIB_NAME} LINK_SCOPE PRIVATE)

The above modification to setup_ax_extension_config has been tested, and it works, without affecting any other extensions.

halx99 commented 11 months ago

lgtm, I think you can post a PR to fix it?

rh101 commented 11 months ago

lgtm, I think you can post a PR to fix it?

Sure, I'll post a PR up soon.