[CMake] Problem with creating shared library

Eric Noulard eric.noulard at gmail.com
Tue Aug 21 13:29:06 EDT 2018


Le lun. 20 août 2018 à 19:05, Damir Porobic <damir_porobic at live.com> a
écrit :

> Hi Eric,
>
>
> yes, this is the project. I have pushed my current state to this branch
> https://github.com/DamirPorobic/kImageAnnotator/tree/sharedLibTestBranch
>
> I've tried also without the generate_export_headers (cleaned everything up
> before trying out) but I get the same result.
>
>
> KImageAnnotator::KImageAnnotator(QPixmap const&)should be exposed by the
> handwritten file, that's true, I think I got something mixed up there and I
> don't actually need the generate_export_headers, but as said, even
> without the line, it's not working.
>

I'm quite lost with the file layout.

in example/main.cpp you do:
#include <kImageAnnotator/KImageAnnotator.h>
so I guess you expect that
target_link_libraries(kImageAnnotator-example PRIVATE
kImageAnnotator::kImageAnnotator)

will bring you the include path to "kImageAnnotator/KImageAnnotator.h"
along with the [imported] target

in your main tree (not in example) there is a trick because you did:

add_library(kImageAnnotator::kImageAnnotator ALIAS kImageAnnotator)

and then in the test directory you do:

target_link_libraries(${UnitTestName} Qt5::Test kimageannotator_LIB)

with

add_library(kimageannotator_LIB STATIC ${kimageannotator_SRCS})

so AFAIU you compile your kImageAnnotator library twice. Once for building
the target you expect to use in example/ subdir
and another time as a STATIC lib for the unit test. So the unit test is not
linking to the same object lib at all ??

I am not used to KDE development but all this seems very fuzzy to me.

May be you could get more precise help from people who know better about
KDE dev and the specific CMake machinery that comes along
like ECM (https://github.com/KDE/extra-cmake-modules) you seems to be using.

-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180821/de8a131e/attachment.html>


More information about the CMake mailing list