Handle BUILD_SHARED_LIBS properly