cmake: convert erasure_code and json_spirit to OBJECT libraries
Changes
- convert erasure_code and json_spirit to OBJECT libraries
- do not link erasure unittests against erasure_code which has been
already included by ceph-common. otherwise we'd have two copies of
erasure_code in these unit test executables. this violates the ODR,
and leds to undefined behaviors like segment fault as static variables
would be destructed twice.
This resolves a circular dependency issue where:
- ceph-common was linked against erasure_code and json_spirit static libraries
- These static libraries were incorrectly marked PUBLIC, causing executables
linking against ceph-common to also link against them directly
- The static libraries themselves referenced symbols from ceph-common,
creating an unresolvable circular dependency
The circular dependency manifested as linker errors in tests like
ceph_test_ino_release_cb, where libjson_spirit.a and liberasure_code.a
contained undefined references to ceph-common symbols (e.g.,
ceph::__ceph_assert_fail and get_str_list) that couldn't be resolved
due to the linking order.
By converting these to OBJECT libraries, we ensure their object files
are incorporated directly into ceph-common during linking, breaking
the circular dependency and preventing the public propagation of
these dependencies to downstream targets.
For instance, ceph_test_ino_release_cb failed to link, because it was
linked against libjson_spirit.a:
```
/usr/bin/c++ -g -O2 -ffile-prefix-map=/home/kefu/dev/ceph=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-z,relro -rdynamic -Wl,--dependency-file=CMakeFiles/ceph_tes
t_ino_release_cb.dir/link.d CMakeFiles/ceph_test_ino_release_cb.dir/test_ino_release_cb.cc.o -o ../../../bin/ceph_test_ino_release_cb -Wl,-rpath,/home/kefu/dev/ceph/obj-x86_64-linux-gnu/lib: ../../../lib/libcephfs.so.2.0.0 ../../../lib/libceph-common.so.
2 ../../../lib/libjson_spirit.a ../../../lib/libcommon_utf8.a ../../../lib/liberasure_code.a ../../../lib/libextblkdev.a -lcap -lresolv ../../../boost/lib/libboost_thread.a ../../../boost/lib/libboost_chrono.a ../../../boost/lib/libboost_atomic.a ../../..
/boost/lib/libboost_system.a ../../../boost/lib/libboost_random.a ../../../boost/lib/libboost_program_options.a ../../../boost/lib/libboost_date_time.a ../../../boost/lib/libboost_iostreams.a ../../../boost/lib/libboost_regex.a ../../../lib/libfmt.a /usr/
lib/x86_64-linux-gnu/libblkid.so /usr/lib/x86_64-linux-gnu/libcrypto.so -ldl /usr/lib/x86_64-linux-gnu/libudev.so /usr/lib/x86_64-linux-gnu/libibverbs.so /usr/lib/x86_64-linux-gnu/librdmacm.so /usr/lib/x86_64-linux-gnu/libz.so ../../opentelemetry-cpp/sdk/
src/trace/libopentelemetry_trace.a ../../opentelemetry-cpp/sdk/src/resource/libopentelemetry_resources.a ../../opentelemetry-cpp/sdk/src/common/libopentelemetry_common.a ../../opentelemetry-cpp/exporters/jaeger/libopentelemetry_exporter_jaeger_trace.a ../
../opentelemetry-cpp/ext/src/http/client/curl/libopentelemetry_http_client_curl.a /usr/lib/x86_64-linux-gnu/libcurl.so /usr/lib/x86_64-linux-gnu/libthrift.so ../../breakpad_project-prefix/lib/libbreakpad_client.a -Wl,--as-needed -latomic
make -f src/test/msgr/CMakeFiles/ceph_perf_msgr_client.dir/build.make src/test/msgr/CMakeFiles/ceph_perf_msgr_client.dir/depend `
/usr/bin/ld: ../../../lib/libcephfs.so.2.0.0: undefined reference to symbol '_ZN4ceph18__ceph_assert_failERKNS_11assert_dataE'
/usr/bin/ld: ../../../lib/libceph-common.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [src/test/fs/CMakeFiles/ceph_test_ino_release_cb.dir/build.make:134: bin/ceph_test_ino_release_cb] Error 1
```
while libjson_spirit.a does reference symbol(s) exposed by ceph-common:
```
$ nm -C ../../../lib/libjson_spirit.a | grep __ceph_assert_fail\(ceph::assert_data
U ceph::__ceph_assert_fail(ceph::assert_data const&)
U ceph::__ceph_assert_fail(ceph::assert_data const&)`
```