Skip to content

CMake: Option to build static library with PIC, default ON

Micah requested to merge micahsnyder/bzip2-fork:issue-47-pic-options into master

The static library must be compiled with POSITION_INDEPENDENT_CODE=ON in order to link it into shared libraries.

But some compilers cannot generate position independent code for static libraries.

To solve for both use cases, this commit adds a new CMake option ENABLE_STATIC_LIB_IS_PIC that is ON by default.

You may need to build with -D ENABLE_STATIC_LIB_IS_PIC=OFF if your compiler fails to generate position independent code when compiling the static library.

Resolves: #47 (closed)

Merge request reports