Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

362
Vistas
How cmake judging target_link_libraries item is a library name or a target?

I have some troubles in cmake target_link_libraries function. In my case,there are three projects like this,which means A depends on B,B depends on C

A(exec) --> B(static library) --> C(static library alias C::C)

I write a CMakeLists.txt for B like this:

find_package(C REUQIRED)
add_library(B ...)
target_link_libraries(B PRIVATE C::C)

And it works well ,complie successfully. A's cmake file like this:

find_package(B REQUIRED)
add_exectuable(A ...)
target_link_libraries(A B)

It reports error when linking A,cmake set a linker flags "-lC::C",and then ld said C::C not exist. How it happend?I think C::C is a target and A should know it,but cmake think it is a library name.And I think A should not know B depends on C,it's a private library.

I don't want to write find_packge(C) in A's cmake,because C is a static library,I think B should handle all dependcies of C,that's right?

So anyone knows how to fix it ?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I solved this problem finally. In my case,B using C's funtion in template code,and B does not instantiate this template,so C::C would not link into B's static library.But A would instantiate B's template,so A need C::C,that's why B's PRIVATE flag was useless.

In order to help A found the C::C,I should use find_depecncy(C) in B's config.cmake to let A knows B's depency when use find_package(B).

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda