improve static/shared build handling by using CMakes BUILD_SHARED_LIBS variable