How to use --flto to link STATIC library


I want to build a static library for my project with gnuarm toolchain. To decrease the code size, I set the library CMAKE_C_FLAGS as "-flto", however my project gives the build error about undefined reference symbols from the library as I linked the library with --lto. How to solve this issue?

Best Regards

Jianliang Shen