Browse Source

Merge pull request #6279 from evsh/cmake

cmake: compilation fixes
adaptive-webui-19844
sledgehammer999 8 years ago committed by GitHub
parent
commit
9225d9ab2b
  1. 45
      cmake/Modules/FindLibtorrentRasterbar.cmake
  2. 12
      cmake/Modules/MacroLinkQtComponents.cmake
  3. 12
      src/base/CMakeLists.txt

45
cmake/Modules/FindLibtorrentRasterbar.cmake

@ -14,6 +14,11 @@
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(PkgConfig QUIET) find_package(PkgConfig QUIET)
macro(_detect_boost_components _outComponets librariesList)
string(REGEX MATCHALL "boost_[a-z_]+[-a-z]*" _boost_libraries "${librariesList}")
string(REGEX REPLACE "boost_([a-z_]+)[-a-z]*" "\\1" ${_outComponets} "${_boost_libraries}")
endmacro()
if(PKG_CONFIG_FOUND) if(PKG_CONFIG_FOUND)
pkg_check_modules(PC_LIBTORRENT_RASTERBAR QUIET libtorrent-rasterbar) pkg_check_modules(PC_LIBTORRENT_RASTERBAR QUIET libtorrent-rasterbar)
endif() endif()
@ -62,13 +67,34 @@ endif()
set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIR}) set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIR})
if(NOT Boost_SYSTEM_FOUND OR NOT Boost_CHRONO_FOUND OR NOT Boost_RANDOM_FOUND) # Without pkg-config, we can't possibly figure out the correct boost dependencies
find_package(Boost REQUIRED COMPONENTS date_time system chrono random thread) if (LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES)
set(LibtorrentRasterbar_LIBRARIES string(REPLACE ";" " " _boost_components "${LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES}")
${LibtorrentRasterbar_LIBRARIES} ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) else(LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES)
set(LibtorrentRasterbar_INCLUDE_DIRS if(PC_LIBTORRENT_RASTERBAR_FOUND)
${LibtorrentRasterbar_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) _detect_boost_components(_boost_cmpnts "${PC_LIBTORRENT_RASTERBAR_LIBRARIES}")
endif() else()
# all possible boost dependencies
set(_boost_cmpnts
date_time
system
chrono
random
thread
)
endif()
list(SORT _boost_cmpnts)
message(STATUS "Libtorrent Boost dependencies: ${_boost_cmpnts}")
string(REPLACE ";" " " _boost_components "${_boost_cmpnts}")
endif(LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES)
find_package(Boost REQUIRED COMPONENTS ${_boost_components})
set(LibtorrentRasterbar_LIBRARIES ${LibtorrentRasterbar_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
foreach(_boost_cmpnt IN LISTS _boost_components)
list(APPEND LibtorrentRasterbar_LIBRARIES "Boost::${_boost_cmpnt}")
endforeach(_boost_cmpnt)
set(LibtorrentRasterbar_INCLUDE_DIRS ${LibtorrentRasterbar_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
list(FIND LibtorrentRasterbar_DEFINITIONS -DTORRENT_USE_OPENSSL LibtorrentRasterbar_ENCRYPTION_INDEX) list(FIND LibtorrentRasterbar_DEFINITIONS -DTORRENT_USE_OPENSSL LibtorrentRasterbar_ENCRYPTION_INDEX)
if(LibtorrentRasterbar_ENCRYPTION_INDEX GREATER -1) if(LibtorrentRasterbar_ENCRYPTION_INDEX GREATER -1)
@ -83,10 +109,7 @@ include(FindPackageHandleStandardArgs)
# if all listed variables are TRUE # if all listed variables are TRUE
find_package_handle_standard_args(LibtorrentRasterbar DEFAULT_MSG find_package_handle_standard_args(LibtorrentRasterbar DEFAULT_MSG
LibtorrentRasterbar_LIBRARY LibtorrentRasterbar_LIBRARY
LibtorrentRasterbar_INCLUDE_DIR LibtorrentRasterbar_INCLUDE_DIR)
Boost_SYSTEM_FOUND
Boost_CHRONO_FOUND
Boost_RANDOM_FOUND)
mark_as_advanced(LibtorrentRasterbar_INCLUDE_DIR LibtorrentRasterbar_LIBRARY mark_as_advanced(LibtorrentRasterbar_INCLUDE_DIR LibtorrentRasterbar_LIBRARY
LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES LibtorrentRasterbar_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES

12
cmake/Modules/MacroLinkQtComponents.cmake

@ -5,11 +5,23 @@
macro (target_link_qt_components target) macro (target_link_qt_components target)
if (QT4_FOUND) if (QT4_FOUND)
foreach(_cmp ${ARGN}) foreach(_cmp ${ARGN})
if ("${_cmp}" STREQUAL "PRIVATE" OR
"${_cmp}" STREQUAL "PUBLIC" OR
"${_cmp}" STREQUAL "INTERFACE")
list(APPEND _QT_CMPNTS "${_cmp}")
else()
list(APPEND _QT_CMPNTS "Qt4::Qt${_cmp}") list(APPEND _QT_CMPNTS "Qt4::Qt${_cmp}")
endif()
endforeach() endforeach()
else (QT4_FOUND) else (QT4_FOUND)
foreach(_cmp ${ARGN}) foreach(_cmp ${ARGN})
if ("${_cmp}" STREQUAL "PRIVATE" OR
"${_cmp}" STREQUAL "PUBLIC" OR
"${_cmp}" STREQUAL "INTERFACE")
list(APPEND _QT_CMPNTS "${_cmp}")
else()
list(APPEND _QT_CMPNTS "Qt5::${_cmp}") list(APPEND _QT_CMPNTS "Qt5::${_cmp}")
endif()
endforeach() endforeach()
endif (QT4_FOUND) endif (QT4_FOUND)
target_link_libraries(${target} ${_QT_CMPNTS}) target_link_libraries(${target} ${_QT_CMPNTS})

12
src/base/CMakeLists.txt

@ -117,24 +117,24 @@ tristatebool.cpp
) )
add_library(qbt_base STATIC ${QBT_BASE_HEADERS} ${QBT_BASE_SOURCES}) add_library(qbt_base STATIC ${QBT_BASE_HEADERS} ${QBT_BASE_SOURCES})
target_link_libraries(qbt_base ZLIB::ZLIB LibtorrentRasterbar::LibTorrent) target_link_libraries(qbt_base PRIVATE ZLIB::ZLIB PUBLIC LibtorrentRasterbar::LibTorrent)
target_link_qt_components(qbt_base Core Network Xml) target_link_qt_components(qbt_base PUBLIC Core Network Xml)
if (QT4_FOUND) if (QT4_FOUND)
if (GUI) if (GUI)
target_link_libraries(qbt_base Qt4::QtGui) target_link_libraries(qbt_base PUBLIC Qt4::QtGui)
endif (GUI) endif (GUI)
else (QT4_FOUND) else (QT4_FOUND)
if (GUI) if (GUI)
target_link_libraries(qbt_base Qt5::Gui Qt5::Widgets) target_link_libraries(qbt_base PUBLIC Qt5::Gui Qt5::Widgets)
endif (GUI) endif (GUI)
endif (QT4_FOUND) endif (QT4_FOUND)
if (DBUS) if (DBUS)
target_link_qt_components(qbt_base DBus) target_link_qt_components(qbt_base PRIVATE DBus)
endif () endif ()
if (APPLE) if (APPLE)
find_library(IOKit_LIBRARY IOKit) find_library(IOKit_LIBRARY IOKit)
find_library(Carbon_LIBRARY Carbon) find_library(Carbon_LIBRARY Carbon)
target_link_libraries(qbt_base ${Carbon_LIBRARY} ${IOKit_LIBRARY}) target_link_libraries(qbt_base PRIVATE ${Carbon_LIBRARY} ${IOKit_LIBRARY})
endif (APPLE) endif (APPLE)

Loading…
Cancel
Save