jbeder / yaml-cpp

A YAML parser and emitter in C++
MIT License
4.91k stars 1.77k forks source link

Add option YAML_ENABLE_PIC #1271

Closed humbertodias closed 4 months ago

humbertodias commented 4 months ago

Features

On PSP/PS3, it's necessary to disable the YAML_ENABLE_PIC option to compile on MIPS. The default value for YAML_ENABLE_PIC is ON

Error

docker run --platform=linux/amd64 --rm -i pspdev/pspdev:latest sh -s <<EOF
apk add git
git clone https://github.com/jbeder/yaml-cpp
cd yaml-cpp
mkdir -p build 
cd build
cmake -Wno-dev -DCMAKE_TOOLCHAIN_FILE=/usr/local/pspdev/psp/share/pspdev.cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/pspdev/psp -DBUILD_SHARED_LIBS=OFF ..
make 
make install
EOF
-- Build files have been written to: /yaml-cpp/build
[  2%] Building CXX object CMakeFiles/yaml-cpp.dir/src/contrib/graphbuilder.cpp.obj
cc1plus: error: cannot generate position-independent code for ‘-mabi=eabi’
make[2]: *** [CMakeFiles/yaml-cpp.dir/build.make:76: CMakeFiles/yaml-cpp.dir/src/contrib/graphbuilder.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:861: CMakeFiles/yaml-cpp.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
[  2%] Building CXX object CMakeFiles/yaml-cpp.dir/src/contrib/graphbuilder.cpp.obj
cc1plus: error: cannot generate position-independent code for ‘-mabi=eabi’
make[2]: *** [CMakeFiles/yaml-cpp.dir/build.make:76: CMakeFiles/yaml-cpp.dir/src/contrib/graphbuilder.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:861: CMakeFiles/yaml-cpp.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

Fix

docker run --platform=linux/amd64 --rm -i pspdev/pspdev:latest sh -s <<EOF
apk add git
git clone https://github.com/humbertodias/yaml-cpp
cd yaml-cpp
mkdir -p build 
cd build
cmake -Wno-dev -DCMAKE_TOOLCHAIN_FILE=/usr/local/pspdev/psp/share/pspdev.cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/pspdev/psp -DBUILD_SHARED_LIBS=OFF -DYAML_ENABLE_PIC=OFF ..
make 
make install
EOF
[ 97%] Building CXX object util/CMakeFiles/yaml-cpp-read.dir/read.cpp.obj
[100%] Linking CXX executable read
[100%] Built target yaml-cpp-read
[ 84%] Built target yaml-cpp
[ 89%] Built target yaml-cpp-sandbox
[ 94%] Built target yaml-cpp-parse
[100%] Built target yaml-cpp-read
Install the project...