I'm new to Ubuntu, I have a project just shipped to Ubuntu (which works fine on MSVC), and I write a cmakelist like this:
add_library(libA STATIC
....)
add_library(libB STATIC
....)
target_link_libraries(libB libA)
add_excutable(c
....)
target_link_libraries(c libA)
target_link_libraries(c libB)
when linking, it tells me that some code in "libB" calls functions in "libA" but are undefined references.
I also tried to use only "target_link_libraries(c libB)", but it doesn't work. I also tried to use
add_custom_target(combined ALL
COMMAND ${CMAKE_AR} rc libcombined.a $<TARGET_FILE:libA> $<TARGET_FILE:libB>)
introduced in CMake: include library dependencies in a static library, but it tells me "libcombined.a" is "error adding symbols archive has no index"
I also find a similar question: CMake libraries that depend on each other
But it uses multiple cmakelist files, can I do it in one cmakelist file?
I'm really new to cmake, I need your help, thanks!