Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTERFACE_LINK_LIBRARIES in cmake-generated targets.cmake #194

Closed
smanders opened this issue Jun 12, 2018 · 3 comments
Closed

INTERFACE_LINK_LIBRARIES in cmake-generated targets.cmake #194

smanders opened this issue Jun 12, 2018 · 3 comments
Assignees
Labels
Milestone

Comments

@smanders
Copy link
Owner

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 smanders added the bug label Jun 12, 2018
@smanders smanders added this to the current milestone Jun 12, 2018
@smanders smanders mentioned this issue Jun 12, 2018
53 tasks
smanders pushed a commit that referenced this issue Jun 12, 2018
* use add_library() with IMPORTED and set IMPORTED_LOCATION rather than optimized/debug
* this follows what cmake-generated targets.cmake files do

issues
* provides pattern to fix issue #194
* also helps with debug libraries #132 so Debug build can use fftw Release lib
smanders pushed a commit that referenced this issue Jun 12, 2018
* use Boost::<C> targets from FindBoost.cmake instead of Boost_LIBRARIES from find_package
* Boost_LIBRARIES introduces hard-coded absolute paths and wrecks havoc on cmake-generated targets.cmake files

see issue #194
smanders pushed a commit that referenced this issue Jun 13, 2018
issue #197 (comment)
* wxcmakeover for MSW build (wxcmake31.patch), including NAMESPACE wx:: (which also effects non-MSW)
* set_target_properties INTERFACE_LINK_LIBRARIES to build up wx library dependency graph, including gtk and system libs

issue #194
* no longer using wxWidgets_LIBRARIES from find_package/FindwxWidgets.cmake
* using wx::<C> targets from add_library with IMPORTED and IMPORTED_LOCATION

issue #183 (comment)
* removed include of the wxWidgets use file
* there is still a question of whether wxWidgets_CXX_FLAGS (-pthread on linux) is needed
@smanders smanders self-assigned this Jun 14, 2018
@smanders
Copy link
Owner Author

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

@smanders
Copy link
Owner Author

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 smanders reopened this Jun 20, 2018
smanders pushed a commit that referenced this issue Jun 20, 2018
* still not sure if we need to add wxWidgets_CXX_FLAGS (-pthread) to CMAKE_CXX_FLAGS
* https://stackoverflow.com/questions/2127797/significance-of-pthread-flag-when-compiling
* holding off, hoping we don't have to modify global CMAKE_CXX_FLAGS - cmake is ready to go, just commented-out
* see issue #194 (comment)
@smanders
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant