Skip to content

Commit

Permalink
Add link_library(libc++.a) (#1245)
Browse files Browse the repository at this point in the history
* Add link_library(libc++.a)

* Always link statically against libc++ and libc++abi on Linux
  • Loading branch information
romainguy authored May 30, 2019
1 parent e1b7739 commit d780e8b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 26 deletions.
15 changes: 3 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,9 @@ endif()

if (LINUX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
if (FILAMENT_REQUIRES_CXXABI)
# Required in CI environment with custom libc++ and libc++abi
link_libraries(libc++abi.a)
endif()
# To distribute our binaries, we must remove the dependency on libc++ and libgcc.
if (CMAKE_BUILD_TYPE STREQUAL "Release")
link_libraries("-static-libgcc -static-libstdc++")
endif()
else()
if (FILAMENT_REQUIRES_CXXABI)
message("The option FILAMENT_REQUIRES_CXXABI is unsupported on this platform")
endif()
link_libraries("-static-libgcc -static-libstdc++")
link_libraries(libc++.a)
link_libraries(libc++abi.a)
endif()

if (CYGWIN)
Expand Down
13 changes: 3 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ If you use CMake directly instead of the build script, pass `-DENABLE_JAVA=OFF`

Make sure you've installed the following dependencies:

- `clang-7`
- `clang-7` or higher
- `libglu1-mesa-dev`
- `libc++-7-dev` (`libcxx-devel` and `libcxx-static` on Fedora)
- `libc++abi-7-dev` (`libcxxabi-static` on Fedora)
- `libc++-7-dev` (`libcxx-devel` and `libcxx-static` on Fedora) or higher
- `libc++abi-7-dev` (`libcxxabi-static` on Fedora) or higher
- `ninja-build`
- `libxi-dev`

Expand All @@ -260,13 +260,6 @@ $ cd out/cmake-release
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../release/filament ../..
```

If you experience link errors you must ensure that you are using `libc++abi` by passing this
extra parameter to `cmake`:

```
-DFILAMENT_REQUIRES_CXXABI=true
```

Your Linux distribution might default to `gcc` instead of `clang`, if that's the case invoke
`cmake` with the following command:

Expand Down
1 change: 0 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ function build_desktop_target {
-DIMPORT_EXECUTABLES_DIR=out \
-DCMAKE_BUILD_TYPE=$1 \
-DCMAKE_INSTALL_PREFIX=../${lc_target}/filament \
-DFILAMENT_REQUIRES_CXXABI=${FILAMENT_REQUIRES_CXXABI} \
-DENABLE_JAVA=${ENABLE_JAVA} \
../..
fi
Expand Down
3 changes: 0 additions & 3 deletions build/linux/ci-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ if [[ "$KOKORO_BUILD_ID" ]]; then

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH

# set to true to link against libc++abi
export FILAMENT_REQUIRES_CXXABI=false
fi

wget -q https://github.com/ninja-build/ninja/releases/download/v$NINJA_VERSION/ninja-linux.zip
Expand Down

0 comments on commit d780e8b

Please sign in to comment.