These are chat archives for symengine/symengine

13th
Jan 2016
Ondřej Čertík
@certik
Jan 13 2016 20:07

@isuruf with #755 and #756 in, the LibFindMacros.cmake starts to look pretty simple. In fact, the last two lines to yank are:

        add_library(${libname} UNKNOWN IMPORTED)
        set_property(TARGET ${libname} PROPERTY IMPORTED_LOCATION ${${LIBNAME}_LIBRARY})

introduced in #581, specifically in the isuruf/symengine@2b71e34 commit. So I guess we need to figure out what the canonical way is to include 3rd party libraries in cmake. Currently what the code above does is that it first finds the library using find_library and then it adds it as a new (imported) target using add_library, but this line just adds a new target, without knowing where the library is (correct?), so the next line sets the IMPORTED_LOCATION property to assign the actual path to the library with the target. From then on, we should just associate the imported target with our symengine targets that need it. Do I understand it correctly? It seems like a clean approach, but it sucks that you have to do all this work manually.

Also, there is actually an if statement:

    if (NOT TARGET ${libname})
        add_library(${libname} UNKNOWN IMPORTED)
        set_property(TARGET ${libname} PROPERTY IMPORTED_LOCATION ${${LIBNAME}_LIBRARY})
    endif()

when can ${libname} be an already defined TARGET? I assume when you run libfind_library more than once on a given library? When does that happen?