# how to process object file before create static library

**URL:** <https://discourse.cmake.org/t/how-to-process-object-file-before-create-static-library/3754>\
**Category:** Code\
**Tags:** os:linux\
**Created:** [July 14, 2021, 11:43am UTC](https://discourse.cmake.org/t/how-to-process-object-file-before-create-static-library/3754 "2021-07-14T11:43:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiandisuixin](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/6bbea6/32.png) [@tiandisuixin](https://discourse.cmake.org/u/tiandisuixin)\
**Post date:** [July 14, 2021, 11:43am UTC](https://discourse.cmake.org/t/how-to-process-object-file-before-create-static-library/3754/1 "2021-07-14T11:43:10Z")

</div>

To build a static library:  
Common process: add\_library(name source-list ) #xx.c-\> xx.o, xx.o-\>xx.a  
My problem: I need run command "${CMAKE\_OBJCOPY} --prefix-alloc-sections .sram xx.o " to process xx.o file  
The process : C files list → object files list , object files list-\>object files list( loop run : ${CMAKE\_OBJCOPY} --prefix-alloc-sections .sram xx.o) object files list → static library

how to write my CMakeLists.txt to build static library

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [July 14, 2021, 12:11pm UTC](https://discourse.cmake.org/t/how-to-process-object-file-before-create-static-library/3754/2 "2021-07-14T12:11:32Z")

</div>

CMake doesn’t really provide a way to intercept the object files between the compiler and the linker. Someone else here may have tried it and figured something out (the problem sounds vaguely familiar), but I can’t recall details; I’d recommend searching Discourse here.

---

<div class="post-metadata">

**Author:** ![tiandisuixin](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/t/6bbea6/32.png) [@tiandisuixin](https://discourse.cmake.org/u/tiandisuixin)\
**Post date:** [July 15, 2021, 1:51am UTC](https://discourse.cmake.org/t/how-to-process-object-file-before-create-static-library/3754/3 "2021-07-15T01:51:54Z")

</div>

Thank you very much!
