Build Yoga 2.0 as a shared library (partial implementation).
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 18.9k
- Forks
- 1.6k
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
I need to build Yoga as a shared library so that I can create C# bindings using p/invoke. Below is the updated CMakeLists.txt file for the 'yoga' directory. It includes an option to build Yoga as a shared library. Please note that although it successfully builds Yoga as a working shared library, it still throws an error. I suspect the issue is with yogatest trying to build against the Yoga static library. Any help with working on this would be greatly appreciated.
Error
collect2: error: ld returned 1 exit status
make[2]: *** [tests/CMakeFiles/yogatests.dir/build.make:887: tests/yogatests] Error 1
make[2]: Leaving directory '/home/sstarr/Downloads/yoga-2.0.0/build'
make[1]: *** [CMakeFiles/Makefile2:199: tests/CMakeFiles/yogatests.dir/all] Error 2
make[1]: Leaving directory '/home/sstarr/Downloads/yoga-2.0.0/build'
make: *** [Makefile:139: all] Error 2
yoga/CMakeLists.txt
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
cmake_minimum_required(VERSION 3.13...3.26)
project(yogacore)
set(CMAKE_VERBOSE_MAKEFILE on)
if(TARGET yogacore)
return()
endif()
include(CheckIPOSupported)
# Define an option to choose between shared and static build
option(BUILD_SHARED_LIBS "Build yogacore as a shared library" OFF)
set(YOGA_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
include(${YOGA_ROOT}/cmake/project-defaults.cmake)
file(GLOB SOURCES CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/**/*.cpp)
# Choose between adding a shared or static library based on the BUILD_SHARED_LIBS option
if(BUILD_SHARED_LIBS)
add_library(yogacore SHARED ${SOURCES})
else()
add_library(yogacore STATIC ${SOURCES})
endif()
# Yoga conditionally uses <android/log> when building for Android
if (ANDROID)
target_link_libraries(yogacore log)
endif()
check_ipo_supported(RESULT result)
if(result)
set_target_properties(yogacore PROPERTIES
CMAKE_INTERPROCEDURAL_OPTIMIZATION true)
endif()
target_include_directories(yogacore
PUBLIC
$<BUILD_INTERFACE:${YOGA_ROOT}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include/yoga>)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with yoga/CMakeLists.txt and the linker failure reported from tests/CMakeFiles/yogatests.dir/build.make; inspect how yogatests links yogacore when BUILD_SHARED_LIBS is enabled. Done means Yoga builds as a shared library and yogatests also compiles and links successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100