[CMake] Work around to use target_link_libraries(PUBLIC) in BUILD_SHARED_LIBS mode.