From 643d2c4574b6cff8afaeda1a45d0ec39c682f3ba Mon Sep 17 00:00:00 2001 From: Andreas Atteneder Date: Tue, 24 Oct 2023 13:37:15 +0200 Subject: [PATCH] fix: Adressed linker errors due to duplicated symbols in `draco` and `dracodec_unity`. - Consolidated dracodec_unity and dracoenc_unity into a single target named draco_unity --- .github/workflows/unity.yml | 83 ++++++++++++++----------------------- CMakeLists.txt | 66 ++++++++++++++--------------- cmake/draco_install.cmake | 2 +- 3 files changed, 64 insertions(+), 87 deletions(-) diff --git a/.github/workflows/unity.yml b/.github/workflows/unity.yml index 3c2bb0e8..52a3697b 100644 --- a/.github/workflows/unity.yml +++ b/.github/workflows/unity.yml @@ -53,7 +53,7 @@ jobs: -DDRACO_GLTF_BITSTREAM=ON -DDRACO_BACKWARDS_COMPATIBILITY=OFF - name: build_mac - run: cmake --build build_mac --config MinSizeRel --target dracodec_unity dracoenc_unity + run: cmake --build build_mac --config MinSizeRel --target draco_unity - name: configure_ios run: > @@ -67,20 +67,17 @@ jobs: -DDRACO_BACKWARDS_COMPATIBILITY=OFF - name: build_ios run: | - cmake --build build_ios --config MinSizeRel --target dracodec_unity dracoenc_unity - cmake --build build_ios --config MinSizeRel --target dracodec_unity dracoenc_unity -- -sdk iphonesimulator + cmake --build build_ios --config MinSizeRel --target draco_unity + cmake --build build_ios --config MinSizeRel --target draco_unity -- -sdk iphonesimulator - name: package Apple run: | mkdir draco_apple mkdir draco_apple/x86_64 - mv build_mac/dracodec_unity.bundle draco_apple/x86_64 - mv build_mac/dracoenc_unity.bundle draco_apple/x86_64 + mv build_mac/draco_unity.bundle draco_apple/x86_64 mkdir -p draco_apple/iOS/simulator - mv build_ios/MinSizeRel-iphoneos/libdracodec_unity.a draco_apple/iOS - mv build_ios/MinSizeRel-iphoneos/libdracoenc_unity.a draco_apple/iOS - mv build_ios/MinSizeRel-iphonesimulator/libdracodec_unity.a draco_apple/iOS/simulator - mv build_ios/MinSizeRel-iphonesimulator/libdracoenc_unity.a draco_apple/iOS/simulator + mv build_ios/MinSizeRel-iphoneos/libdraco_unity.a draco_apple/iOS + mv build_ios/MinSizeRel-iphonesimulator/libdraco_unity.a draco_apple/iOS/simulator - name: upload artifact uses: actions/upload-artifact@v3 with: @@ -102,7 +99,7 @@ jobs: -DDRACO_GLTF_BITSTREAM=ON -DDRACO_BACKWARDS_COMPATIBILITY=OFF - name: build_win64 - run: cmake --build build_win_64 --config MinSizeRel --target dracodec_unity dracoenc_unity + run: cmake --build build_win_64 --config MinSizeRel --target draco_unity - name: configure_win32 run: > @@ -111,7 +108,7 @@ jobs: -DDRACO_GLTF_BITSTREAM=ON -DDRACO_BACKWARDS_COMPATIBILITY=OFF - name: build_win32 - run: cmake --build build_win_32 --config MinSizeRel --target dracodec_unity dracoenc_unity + run: cmake --build build_win_32 --config MinSizeRel --target draco_unity # Universal Windows Platform - name: configure_uwp_arm @@ -123,7 +120,7 @@ jobs: -DCMAKE_SYSTEM_NAME:String=WindowsStore -DCMAKE_SYSTEM_VERSION:String="10.0" - name: build_uwp_arm - run: cmake --build build_uwp_arm --config MinSizeRel --target dracodec_unity dracoenc_unity + run: cmake --build build_uwp_arm --config MinSizeRel --target draco_unity - name: configure_uwp_arm64 run: > @@ -134,7 +131,7 @@ jobs: -DCMAKE_SYSTEM_NAME:String=WindowsStore -DCMAKE_SYSTEM_VERSION:String="10.0" - name: build_uwp_arm64 - run: cmake --build build_uwp_arm64 --config MinSizeRel --target dracodec_unity dracoenc_unity + run: cmake --build build_uwp_arm64 --config MinSizeRel --target draco_unity - name: configure_uwp_x86 run: > @@ -145,7 +142,7 @@ jobs: -DCMAKE_SYSTEM_NAME:String=WindowsStore -DCMAKE_SYSTEM_VERSION:String="10.0" - name: build_uwp_x86 - run: cmake --build build_uwp_x86 --config MinSizeRel --target dracodec_unity dracoenc_unity + run: cmake --build build_uwp_x86 --config MinSizeRel --target draco_unity - name: configure_uwp_x64 run: > @@ -156,7 +153,7 @@ jobs: -DCMAKE_SYSTEM_NAME:String=WindowsStore -DCMAKE_SYSTEM_VERSION:String="10.0" - name: build_uwp_x64 - run: cmake --build build_uwp_x64 --config MinSizeRel --target dracodec_unity dracoenc_unity + run: cmake --build build_uwp_x64 --config MinSizeRel --target draco_unity - name: package Windows run: | @@ -166,18 +163,12 @@ jobs: mkdir draco_win/WSA/ARM64 mkdir draco_win/WSA/x86 mkdir draco_win/WSA/x64 - mv build_win_32\MinSizeRel\dracodec_unity.dll draco_win/x86 - mv build_win_32\MinSizeRel\dracoenc_unity.dll draco_win/x86 - mv build_win_64\MinSizeRel\dracodec_unity.dll draco_win/x86_64 - mv build_win_64\MinSizeRel\dracoenc_unity.dll draco_win/x86_64 - mv build_uwp_arm\MinSizeRel\dracodec_unity.dll draco_win/WSA/ARM - mv build_uwp_arm\MinSizeRel\dracoenc_unity.dll draco_win/WSA/ARM - mv build_uwp_arm64\MinSizeRel\dracodec_unity.dll draco_win/WSA/ARM64 - mv build_uwp_arm64\MinSizeRel\dracoenc_unity.dll draco_win/WSA/ARM64 - mv build_uwp_x86\MinSizeRel\dracodec_unity.dll draco_win/WSA/x86 - mv build_uwp_x86\MinSizeRel\dracoenc_unity.dll draco_win/WSA/x86 - mv build_uwp_x64\MinSizeRel\dracodec_unity.dll draco_win/WSA/x64 - mv build_uwp_x64\MinSizeRel\dracoenc_unity.dll draco_win/WSA/x64 + mv build_win_32\MinSizeRel\draco_unity.dll draco_win/x86 + mv build_win_64\MinSizeRel\draco_unity.dll draco_win/x86_64 + mv build_uwp_arm\MinSizeRel\draco_unity.dll draco_win/WSA/ARM + mv build_uwp_arm64\MinSizeRel\draco_unity.dll draco_win/WSA/ARM64 + mv build_uwp_x86\MinSizeRel\draco_unity.dll draco_win/WSA/x86 + mv build_uwp_x64\MinSizeRel\draco_unity.dll draco_win/WSA/x64 - name: upload artifact uses: actions/upload-artifact@v3 with: @@ -220,7 +211,7 @@ jobs: -DDRACO_GLTF_BITSTREAM=ON -DDRACO_BACKWARDS_COMPATIBILITY=OFF - name: build_android_arm64-v8a - run: cmake --build build_android_arm64-v8a --target dracodec_unity dracoenc_unity -j + run: cmake --build build_android_arm64-v8a --target draco_unity -j - name: configure_android_armeabi-v7a run: > @@ -233,7 +224,7 @@ jobs: -DDRACO_GLTF_BITSTREAM=ON -DDRACO_BACKWARDS_COMPATIBILITY=OFF - name: build_android_armeabi-v7a - run: cmake --build build_android_armeabi-v7a --target dracodec_unity dracoenc_unity -j + run: cmake --build build_android_armeabi-v7a --target draco_unity -j - name: configure_android_x86 run: > @@ -246,7 +237,7 @@ jobs: -DDRACO_GLTF_BITSTREAM=ON -DDRACO_BACKWARDS_COMPATIBILITY=OFF - name: build_android_x86_dracodec_unity - run: cmake --build build_android_x86 --target dracodec_unity dracoenc_unity -j + run: cmake --build build_android_x86 --target draco_unity -j # # Emscripten # - name: setup Emscripten @@ -263,28 +254,21 @@ jobs: # -DDRACO_GLTF_BITSTREAM=ON # -DDRACO_BACKWARDS_COMPATIBILITY=OFF # - name: build_webassembly_dracodec_unity - # run: cmake --build build_web --target dracodec_unity dracoenc_unity -j + # run: cmake --build build_web --target draco_unity -j # Linux artifacts - name: package Linux run: | # mkdir -p draco_linux/WebGL/2021 - # mv build_web/libdracodec_unity.a draco_linux/WebGL/2021 - # mv build_web/libdracoenc_unity.a draco_linux/WebGL/2021 + # mv build_web/libdraco_unity.a draco_linux/WebGL/2021 mkdir -p draco_linux/Android/libs/arm64-v8a mkdir -p draco_linux/Android/libs/armeabi-v7a mkdir -p draco_linux/Android/libs/x86 - mv build_android_arm64-v8a/libdracodec_unity.so \ + mv build_android_arm64-v8a/libdraco_unity.so \ draco_linux/Android/libs/arm64-v8a - mv build_android_arm64-v8a/libdracoenc_unity.so \ - draco_linux/Android/libs/arm64-v8a - mv build_android_armeabi-v7a/libdracodec_unity.so \ - draco_linux/Android/libs/armeabi-v7a - mv build_android_armeabi-v7a/libdracoenc_unity.so \ + mv build_android_armeabi-v7a/libdraco_unity.so \ draco_linux/Android/libs/armeabi-v7a - mv build_android_x86/libdracodec_unity.so \ - draco_linux/Android/libs/x86 - mv build_android_x86/libdracoenc_unity.so \ + mv build_android_x86/libdraco_unity.so \ draco_linux/Android/libs/x86 - name: upload artifact uses: actions/upload-artifact@v3 @@ -321,14 +305,13 @@ jobs: # -DDRACO_GLTF_BITSTREAM=ON \ # -DDRACO_BACKWARDS_COMPATIBILITY=OFF # - name: build_webassembly_dracodec_unity - # run: cmake --build build_web --target dracodec_unity dracoenc_unity -j + # run: cmake --build build_web --target draco_unity -j # # Artifacts # - name: package # run: | # mkdir -p draco_emscripten_3/WebGL/2022 - # mv build_web/libdracodec_unity.a draco_emscripten_3/WebGL/2022 - # mv build_web/libdracoenc_unity.a draco_emscripten_3/WebGL/2022 + # mv build_web/libdraco_unity.a draco_emscripten_3/WebGL/2022 # - name: upload artifact # uses: actions/upload-artifact@v3 # with: @@ -361,7 +344,7 @@ jobs: -DDRACO_GLTF_BITSTREAM=ON -DDRACO_BACKWARDS_COMPATIBILITY=OFF - name: build_linux64_dracodec_unity - run: cmake --build build_linux_64 --target dracodec_unity dracoenc_unity -j + run: cmake --build build_linux_64 --target draco_unity -j # # Emscripten 1 # - name: setup Emscripten 1 @@ -378,17 +361,15 @@ jobs: # -DDRACO_GLTF_BITSTREAM=ON # -DDRACO_BACKWARDS_COMPATIBILITY=OFF # - name: build_webassembly_1_dracodec_unity - # run: cmake --build build_web --target dracodec_unity dracoenc_unity -j + # run: cmake --build build_web --target draco_unity -j # Linux legacy artifacts - name: package Linux legacy run: | mkdir -p draco_linux_legacy/x86_64 - mv build_linux_64/libdracodec_unity.so draco_linux_legacy/x86_64 - mv build_linux_64/libdracoenc_unity.so draco_linux_legacy/x86_64 + mv build_linux_64/libdraco_unity.so draco_linux_legacy/x86_64 # mkdir -p draco_linux_legacy/WebGL/2020 - # mv build_web/libdracodec_unity.bc draco_linux_legacy/WebGL/2020 - # mv build_web/libdracoenc_unity.bc draco_linux_legacy/WebGL/2020 + # mv build_web/libdraco_unity.bc draco_linux_legacy/WebGL/2020 - name: upload artifact uses: actions/upload-artifact@v3 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bc811f5..a44ca8c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1059,29 +1059,34 @@ else() set(unity_decoder_lib_type MODULE) endif() - set(unity_lib_dependency ${draco_plugin_dependency}) set(unity_objlib_dependency draco_unity_plugin) - if(EMSCRIPTEN OR IOS) - unset(unity_lib_dependency) - list(APPEND unity_objlib_dependency - # Link selected object libs directly instead of ${draco_plugin_dependency} - # minimizes build size - # results in a single static lib file - draco_attributes - draco_compression_attributes_dec - draco_compression_bit_coders - draco_compression_decode - draco_compression_entropy - draco_compression_mesh_dec - draco_compression_point_cloud_dec - draco_core - draco_mesh - draco_metadata - draco_metadata_dec - draco_point_cloud - draco_points_dec - ) - endif() + + list(APPEND unity_objlib_dependency + # Link selected object libs directly instead of ${draco_plugin_dependency} + # minimizes build size by omitting animation/IO/transcoder related symbols + # results in a single static lib file (no dependency on target `draco`) + draco_attributes + draco_compression_attributes_dec + draco_compression_attributes_enc + draco_compression_attributes_pred_schemes_dec + draco_compression_attributes_pred_schemes_enc + draco_compression_bit_coders + draco_compression_decode + draco_compression_encode + draco_compression_entropy + draco_compression_mesh_dec + draco_compression_mesh_enc + draco_compression_point_cloud_dec + draco_compression_point_cloud_enc + draco_core + draco_mesh + draco_metadata + draco_metadata_dec + draco_metadata_enc + draco_point_cloud + draco_points_dec + draco_points_enc + ) draco_add_library( NAME draco_unity_plugin @@ -1090,14 +1095,6 @@ else() DEFINES ${draco_defines} INCLUDES ${draco_include_paths}) - draco_add_library( - NAME dracodec_unity - TYPE ${unity_decoder_lib_type} - DEFINES ${draco_defines} - INCLUDES ${draco_include_paths} - OBJLIB_DEPS ${unity_objlib_dependency} - LIB_DEPS ${unity_lib_dependency}) - draco_add_library( NAME draco_unity_enc_plugin TYPE OBJECT @@ -1106,17 +1103,16 @@ else() INCLUDES ${draco_include_paths}) draco_add_library( - NAME dracoenc_unity + NAME draco_unity TYPE ${unity_decoder_lib_type} DEFINES ${draco_defines} INCLUDES ${draco_include_paths} - OBJLIB_DEPS draco_unity_enc_plugin - LIB_DEPS ${draco_plugin_dependency}) + OBJLIB_DEPS ${unity_objlib_dependency} draco_unity_enc_plugin + ) # For Mac, we need to build a .bundle for the unity plugin. if(APPLE) - set_target_properties(dracodec_unity PROPERTIES BUNDLE true) - set_target_properties(dracoenc_unity PROPERTIES BUNDLE true) + set_target_properties(draco_unity PROPERTIES BUNDLE true) endif() endif() diff --git a/cmake/draco_install.cmake b/cmake/draco_install.cmake index 3be1ba16..6d211142 100644 --- a/cmake/draco_install.cmake +++ b/cmake/draco_install.cmake @@ -81,7 +81,7 @@ macro(draco_setup_install_target) endif() if(DRACO_UNITY_PLUGIN) - install(TARGETS dracodec_unity DESTINATION "${libs_path}") + install(TARGETS draco_unity DESTINATION "${libs_path}") endif() if(DRACO_MAYA_PLUGIN)