rizsotto / Bear

Bear is a tool that generates a compilation database for clang tooling.
GNU General Public License v3.0
4.76k stars 312 forks source link

Added CMAKE_EXE_LINKER_FLAGS to external projects. #437

Closed XaverKlemenschits closed 2 years ago

XaverKlemenschits commented 2 years ago

When using a compiler other than the system compiler, it is necessary to set some linker flags to the correct C++ standard libraries. This also applies to 3rd party dependencies.

Therefore, it is necessary to pass the linker flags through to the external projects. With these changes, linker flags can be passed on the command line and all dependencies + bear will be linked correctly, e.g.:

cmake .. -DENABLE_UNIT_TESTS=OFF \
-DENABLE_FUNC_TESTS=OFF \
-DCMAKE_INSTALL_LIBDIR=lib64 \
-DCMAKE_EXE_LINKER_FLAGS="-Wl,-rpath=$GCC_PATH/lib64"

works for CentOS/Redhat with a non-system compiler installed at $GCC_PATH.

rizsotto commented 2 years ago

Thanks @XaverKlemenschits ! Will be released as 3.0.18 soon.