smanders / externpro

build external projects with cmake
MIT License
13 stars 12 forks source link

INTERFACE_LINK_LIBRARIES in cmake-generated targets.cmake #194

Closed smanders closed 6 years ago

smanders commented 6 years ago

externpro has several projects that aren't built via cmake on linux with gcc: boost, wxWidgets, fftw to name a few

we have another externpro-like project that builds internal/proprietary projects which we call internpro

internpro has projects that are built via cmake and depend on boost and wxWidgets

the problem is that the BOOST_LIBRARIES and WXWIDGETS_LIBRARIES returned from their use scripts are hard-coded absolute paths, specific to the system internpro is built on -- and so the cmake-generated targets.cmake files from these projects that depend on boost and wx have INTERFACE_LINK_LIBRARIES like the following:

set_target_properties(mbview PROPERTIES INTERFACE_LINK_LIBRARIES "-L/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib;-pthread;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_gtk3u_aui-3.1.a;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_gtk3u_propgrid-3.1.a;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_gtk3u_richtext-3.1.a;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_gtk3u_gl-3.1.a;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_baseu_net-3.1.a;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_gtk3u_html-3.1.a;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_gtk3u_adv-3.1.a;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_gtk3u_core-3.1.a;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_baseu_xml-3.1.a;/home/smanders/src/externpro/_bld/externpro_18.04.1-4-g6159bb8-gcc640-64/lib/libwx_baseu-3.1.a;-lGL;-lGLU;-lgthread-2.0;-lX11;-lXxf86vm;-lSM;-lgtk-3;-lgdk-3;-lpangocairo-1.0;-lpango-1.0;-latk-1.0;-lcairo-gobject;-lcairo;-lgdk_pixbuf-2.0;-lgio-2.0;-lgobject-2.0;-lglib-2.0;-lwxregexu-3.1;-lwxexpat-3.1;-lwxtiff-3.1;-lwxjpeg-3.1;-lwxpng-3.1;-lwxzlib-3.1;-ldl;-lm" )

I've been working around this by clearing INTERFACE_LINK_LIBRARIES of any externpro libraries and setting it to the internal libraries it depends on, for example the palam library mb depends on async (another palam library) and boost (from externpro), so I set it to only show it depends on async:

set_target_properties(mb PROPERTIES INTERFACE_LINK_LIBRARIES async)

most of the time the linking has worked out and these externpro library dependencies are in the link line in an order that works and things have just worked

except when they didn't... for example I found that I had to add the wx libraries back in the palam use script for mbview:

    if(${lib} STREQUAL mbview AND COMMAND xpGetExtern)
      xpGetExtern(dontcare wxLibs PRIVATE wxWidgets)
      set_target_properties(mbview PROPERTIES
        INTERFACE_LINK_LIBRARIES "${wxLibs};mb"
        )
    endif()

recently a new unit test for a Scheduler library was being developed which depends on the palam async library - and there is a link error (Debug build):

/usr/bin/c++  -std=c++14 -fPIC -msse3 -fstack-protector-strong -Wall -Wno-maybe-uninitialized -Wextra -Wcast-align -pedantic -Wformat=2 -Wfloat-equal -Wno-unknown-pragmas -Wno-psabi -Werror -fvisibility=hidden -Wl,--exclude-libs,ALL -g --coverage -O0  -fPIC -Wl,-R,$ORIGIN CMakeFiles/SchedulerLibTest.dir/ReadyQueueTest.cpp.o CMakeFiles/SchedulerLibTest.dir/ResourceAllocatorTest.cpp.o CMakeFiles/SchedulerLibTest.dir/ResourceGroupTest.cpp.o CMakeFiles/SchedulerLibTest.dir/SchedulerIntegrationTest.cpp.o CMakeFiles/SchedulerLibTest.dir/SchedulerTestMain.cpp.o  -o SchedulerLibTest  -L/opt/extern/externpro-18.04.1-gcc640-64-Linux/lib  -L/opt/extern/internpro-18.05.1-gcc640-64-Linux/lib -Wl,-rpath,/opt/extern/externpro-18.04.1-gcc640-64-Linux/lib:/opt/extern/internpro-18.05.1-gcc640-64-Linux/lib ../libScheduler-d.a ../../../SdasyncLIB/Sdasync/libSdasync-d.a ../../../SdbaseLIB/Sdbase/libSdbase-d.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_log_setup-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_coroutine-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_coroutine-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_log-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_log-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_timer-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_timer-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_chrono-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_chrono-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_filesystem-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_filesystem-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_graph-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_graph-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_random-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_random-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_thread-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_thread-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_wserialization-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_wserialization-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_atomic-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_atomic-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_container-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_container-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_context-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_context-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_date_time-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_date_time-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_exception-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_exception-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_iostreams-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_iostreams-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_program_options-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_program_options-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_python-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_python-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_regex-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_regex-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_serialization-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_serialization-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_signals-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_signals-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_system-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_system-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_test_exec_monitor-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_test_exec_monitor-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_unit_test_framework-gcc64-mt-s-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libboost_unit_test_framework-gcc64-mt-sd-1_63.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libz_1.2.8-d.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libbz2_1.0.6-d.a -lpthread /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libgeotrans_2.4.2-d.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/liblua_5.2.3-d.a -lm /opt/extern/internpro-18.05.1-gcc640-64-Linux/lib/libpalam_ut-d_v124.a /opt/extern/internpro-18.05.1-gcc640-64-Linux/lib/libpalam_mbview-d_v124.a /opt/extern/internpro-18.05.1-gcc640-64-Linux/lib/libpalam_mb-d_v124.a /opt/extern/internpro-18.05.1-gcc640-64-Linux/lib/libpalam_async-d_v124.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libprotobuf_3.0.0-beta-1-d.a -lpthread -L/opt/extern/externpro-18.04.1-gcc640-64-Linux/lib -pthread /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_gtk3u_aui-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_gtk3u_propgrid-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_gtk3u_richtext-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_gtk3u_gl-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_baseu_net-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_gtk3u_html-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_gtk3u_adv-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_gtk3u_core-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_baseu_xml-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwx_baseu-3.1.a -lGL -lGLU -lgthread-2.0 -lX11 -lXxf86vm -lSM -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lwxregexu-3.1 -lwxexpat-3.1 -lwxtiff-3.1 -lwxjpeg-3.1 -lwxpng-3.1 -lwxzlib-3.1 -ldl -lm /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwxx_gtk3ud_plotctrl-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwxx_gtk3ud_things-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libwxx_gtk3ud_tlc-3.1.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libcurl_7.42.1-d.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libssh2_1.5.0-d.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libssl_1.0.2a-d.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libcrypto_1.0.2a-d.a -ldl /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libz_1.2.8-d.a /opt/extern/externpro-18.04.1-gcc640-64-Linux/lib/libcares_1.10.0-d.a -lrt -lnsl 
/opt/extern/internpro-18.05.1-gcc640-64-Linux/lib/libpalam_async-d_v124.a(ChronoQueue.cpp.o): In function `__static_initialization_and_destruction_0(int, int)':
/opt/extern/externpro-18.04.1-gcc640-64-Linux/include/boost-1_63/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/opt/extern/externpro-18.04.1-gcc640-64-Linux/include/boost-1_63/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/opt/extern/externpro-18.04.1-gcc640-64-Linux/include/boost-1_63/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
/opt/extern/internpro-18.05.1-gcc640-64-Linux/lib/libpalam_async-d_v124.a(ChronoQueue.cpp.o): In function `boost::asio::error::get_system_category()':
/opt/extern/externpro-18.04.1-gcc640-64-Linux/include/boost-1_63/boost/asio/error.hpp:230: undefined reference to `boost::system::system_category()'
/opt/extern/internpro-18.05.1-gcc640-64-Linux/lib/libpalam_async-d_v124.a(ChronoQueueServerImpl.cpp.o): In function `__static_initialization_and_destruction_0(int, int)':
/opt/extern/externpro-18.04.1-gcc640-64-Linux/include/boost-1_63/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'
/opt/extern/externpro-18.04.1-gcc640-64-Linux/include/boost-1_63/boost/system/error_code.hpp:222: undefined reference to `boost::system::generic_category()'
/opt/extern/externpro-18.04.1-gcc640-64-Linux/include/boost-1_63/boost/system/error_code.hpp:223: undefined reference to `boost::system::system_category()'
/opt/extern/internpro-18.05.1-gcc640-64-Linux/lib/libpalam_async-d_v124.a(ChronoQueueServerImpl.cpp.o): In function `boost::system::error_code::error_code()':
/opt/extern/externpro-18.04.1-gcc640-64-Linux/include/boost-1_63/boost/system/error_code.hpp:322: undefined reference to `boost::system::system_category()'

what you can see from the link line is that the boost libraries are there, the async library is there - but the boost libraries come first - and the link error is from the palam async library complaining that it's missing some boost things:

/opt/extern/internpro-18.05.1-gcc640-64-Linux/lib/libpalam_async-d_v124.a(ChronoQueue.cpp.o): In function `__static_initialization_and_destruction_0(int, int)':
/opt/extern/externpro-18.04.1-gcc640-64-Linux/include/boost-1_63/boost/system/error_code.hpp:221: undefined reference to `boost::system::generic_category()'

perhaps there are some hacks to put on top of the hacks to solve link issues like this...

but the real solution, to me, is to stop clearing out the INTERFACE_LINK_LIBRARIES and figure out a way to not have hard-coded, absolute, build-system-specific paths in the targets.cmake files

smanders commented 6 years ago

I believe this issue is complete with the commits referenced above - if not, other commits will also reference this issue...

smanders commented 6 years ago

additional system libraries are needed for wxWidgets

/usr/bin/x86_64-linux-gnu-ld: /home/smanders/src/externpro/_bld/externpro_18.04.1-13-g49aabf4-gcc640-64/lib/libwx_baseu-3.1.a(baselib_threadpsx.o): undefined reference to symbol 'pthread_mutexattr_settype@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libpthread.so.0: error adding symbols: DSO missing from command line
smanders commented 6 years ago

links with info on last commit (see details) regarding -pthread