[CMake] Imported libraries and cyclic dependencies

Rainer Poisel rainer.poisel at gmail.com
Fri Jan 8 01:26:28 EST 2016


Hello,

I am using CMake 3.4.1.

Best regards,
  Rainer


On Fri, Jan 8, 2016 at 2:18 AM, iosif neitzke
<iosif.neitzke+cmake at gmail.com> wrote:
> Which version of CMake are you using?
>
>
> On 01/07/2016 04:28 PM, Rainer Poisel wrote:
>>
>> Hi,
>>
>> I am having troubles with linking a bunch of imported libraries that
>> have cyclic dependencies.
>>
>> This is what I am doing:
>>
>> 8<=======================
>> find_library(ESP8266_SDK_LIB_MAIN main ${ESP8266_SDK_BASE}/lib)
>> add_library(esp8266_main UNKNOWN IMPORTED)
>> set_property(TARGET esp8266_main PROPERTY IMPORTED_LOCATION
>> "${ESP8266_SDK_LIB_MAIN}")
>>
>> find_library(ESP8266_SDK_LIB_PHY phy ${ESP8266_SDK_BASE}/lib)
>> add_library(esp8266_phy UNKNOWN IMPORTED)
>> set_property(TARGET esp8266_phy PROPERTY IMPORTED_LOCATION
>> "${ESP8266_SDK_LIB_PHY}")
>>
>> find_library(ESP8266_SDK_LIB_PP pp ${ESP8266_SDK_BASE}/lib)
>> add_library(esp8266_pp UNKNOWN IMPORTED)
>> set_property(TARGET esp8266_pp PROPERTY IMPORTED_LOCATION
>> "${ESP8266_SDK_LIB_PP}")
>>
>> find_library(ESP8266_SDK_LIB_LWIP lwip ${ESP8266_SDK_BASE}/lib)
>> add_library(esp8266_lwip UNKNOWN IMPORTED)
>> set_property(TARGET esp8266_lwip PROPERTY IMPORTED_LOCATION
>> "${ESP8266_SDK_LIB_LWIP}")
>>
>> target_link_libraries(ESP8266_SDK INTERFACE
>>     gcc
>>     esp8266_lwip
>>     esp8266_main
>>     esp8266_phy
>>     esp8266_pp
>> )
>>
>> target_link_libraries(esp8266_main INTERFACE
>>     esp8266_lwip
>>     esp8266_pp
>>     esp8266_phy
>> )
>> 8<=======================
>>
>> The given example is not complete. However, I hope it is sufficient to
>> give you an idea of what I want to achieve: I would like to specify
>> the dependencies between imported libraries. Subsequently I want to
>> make the linker call mention my libraries several times in order to
>> make the linker resolve all dependency cycles (multiplicity).
>>
>> This is the corresponding error message:
>>
>> 8<=======================
>> CMake Error at external/esp8266-cmake/sdk/nonos-1.4.0.cmake:111
>> (target_link_libraries):
>> Cannot specify link libraries for target "esp8266_main" which is not built
>> by this project.
>> 8<=======================
>>
>> As a workaround I added the -Wl,--start-group (referred to as
>> BUILD_LINK_PREFIX) and the -Wl,--end-group (referred to as
>> BUILD_LINK_SUFFIX) arguments (yes, it is a GCC) directly to the
>> invocation of target_link_libraries() of my executable which has been
>> defined by add_executable() beforehand. But I think that this is just
>> a botch-up.
>>
>> Here is an example of the complete code (using the before-mentioned
>> workaround):
>>   * https://github.com/rpoisel/esp8266-mqtt
>>   *
>> https://github.com/rpoisel/esp8266-cmake/blob/master/main/CMakeLists.txt
>>
>> Thanks for any suggestions in advance,
>>   Rainer
>>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list