My project is something like this:
project
├── test
│ ├── CMakeLists.txt
│ ├── main.cpp
│ └── test_class1.cpp
├── CMakeLists.txt
├── main.cpp
├── ...
├── class1.h
└── class1.cpp
I want to reuse class1.o which was compiled for project binary. Default CMake behavior compiled it twice for test too. I try to use OBJECT library but it puts all objects in this library variable. Then compiler print
main.cpp:(.text.startup+0x0): multiple definition of `main'
It means that 2 different main.o in one target. And all other *.o files from main project compilation are.
How to exlude unneeded *.o files?