From 38cf1fb3ee20b42d8ba948396099dbbf4dcb34f9 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Sat, 20 Jul 2019 19:43:08 +0300 Subject: [PATCH] Improve CMake configuration Don't search for QtSingleApplication library. Fix building on Windows with MinGW. --- .gitignore | 1 + cmake/Modules/FindLibtorrentRasterbar.cmake | 2 +- cmake/Modules/FindQtSingleApplication.cmake | 79 --------------------- cmake/Modules/winconf-mingw.cmake | 12 ++-- cmake/Modules/winconf-msvc.cmake | 17 ++--- cmake/Modules/winconf.cmake | 40 ++++++----- 6 files changed, 36 insertions(+), 115 deletions(-) delete mode 100644 cmake/Modules/FindQtSingleApplication.cmake diff --git a/.gitignore b/.gitignore index 20862ab58..f4cab7b2f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ src/qbittorrent src/qbittorrent-nox src/release src/debug +CMakeLists.txt.user* qbittorrent.pro.user* conf.pri Makefile* diff --git a/cmake/Modules/FindLibtorrentRasterbar.cmake b/cmake/Modules/FindLibtorrentRasterbar.cmake index d3465e862..10f18b8a3 100644 --- a/cmake/Modules/FindLibtorrentRasterbar.cmake +++ b/cmake/Modules/FindLibtorrentRasterbar.cmake @@ -46,7 +46,7 @@ else() if(NOT LibtorrentRasterbar_USE_STATIC_LIBS) list(APPEND LibtorrentRasterbar_DEFINITIONS -DTORRENT_LINKING_SHARED - -DBOOST_SYSTEM_DYN_LINK -DBOOST_CHRONO_DYN_LINK) + -DBOOST_SYSTEM_DYN_LINK) endif() endif() diff --git a/cmake/Modules/FindQtSingleApplication.cmake b/cmake/Modules/FindQtSingleApplication.cmake deleted file mode 100644 index 3420b435f..000000000 --- a/cmake/Modules/FindQtSingleApplication.cmake +++ /dev/null @@ -1,79 +0,0 @@ -# - Try to find the QtSingleApplication includes and library -# which defines -# -# QtSingleApplication_FOUND - system has QtSingleApplication -# QtSingleApplication_INCLUDE_DIR - where to find header QtSingleApplication -# QtSingleApplication_LIBRARIES - the libraries to link against to use QtSingleApplication -# QtSingleApplication_LIBRARY - where to find the QtSingleApplication library (not for general use) - -# copyright (c) 2013 TI_Eugene ti.eugene@gmail.com -# -# Redistribution and use is allowed according to the terms of the FreeBSD license. - -SET(QtSingleApplication_FOUND FALSE) - -if (Qt5Widgets_FOUND) - set(_includeFileName qtsingleapplication.h) -else() - set(_includeFileName qtsinglecoreapplication.h) -endif() - -FOREACH(TOP_INCLUDE_PATH in ${Qt5Core_INCLUDE_DIRS} ${FRAMEWORK_INCLUDE_DIR}) - FIND_PATH(QtSingleApplication_INCLUDE_DIR ${_includeFileName} ${TOP_INCLUDE_PATH}/QtSolutions) - - IF(QtSingleApplication_INCLUDE_DIR) - BREAK() - ENDIF() -ENDFOREACH() - -SET(QtSingleApplication_NAMES ${QtSingleApplication_NAMES} - Qt5Solutions_SingleApplication-2.6 libQt5Solutions_SingleApplication-2.6 - QtSolutions_SingleApplication-2.6 libQtSolutions_SingleApplication-2.6) -GET_TARGET_PROPERTY(_QT5_CORELIBRARY Qt5::Core LOCATION) -GET_FILENAME_COMPONENT(_QT5_CORELIBRARYPATH ${_QT5_CORELIBRARY} PATH) - -FIND_LIBRARY(QtSingleApplication_LIBRARY - NAMES ${QtSingleApplication_NAMES} - PATHS ${_QT5_CORELIBRARYPATH} -) - -IF (QtSingleApplication_LIBRARY AND QtSingleApplication_INCLUDE_DIR) - - SET(QtSingleApplication_LIBRARIES ${QtSingleApplication_LIBRARY}) - SET(QtSingleApplication_FOUND TRUE) - - IF (CYGWIN) - IF(BUILD_SHARED_LIBS) - # No need to define QtSingleApplication_USE_DLL here, because it's default for Cygwin. - ELSE(BUILD_SHARED_LIBS) - SET (QtSingleApplication_DEFINITIONS -DQTSINGLEAPPLICATION_STATIC) - ENDIF(BUILD_SHARED_LIBS) - ENDIF (CYGWIN) - -ENDIF (QtSingleApplication_LIBRARY AND QtSingleApplication_INCLUDE_DIR) - -IF (QtSingleApplication_FOUND) - IF (NOT QtSingleApplication_FIND_QUIETLY) - MESSAGE(STATUS "Found QtSingleApplication: ${QtSingleApplication_LIBRARY}") - MESSAGE(STATUS " includes: ${QtSingleApplication_INCLUDE_DIR}") - ENDIF (NOT QtSingleApplication_FIND_QUIETLY) - if(NOT TARGET QtSingleApplication::QtSingleApplication) - add_library(QtSingleApplication::QtSingleApplication UNKNOWN IMPORTED) - set_target_properties(QtSingleApplication::QtSingleApplication PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${QtSingleApplication_INCLUDE_DIR}" - INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${QtSingleApplication_INCLUDE_DIR}" - ) - if(EXISTS "${QtSingleApplication_LIBRARY}") - set_target_properties(QtSingleApplication::QtSingleApplication PROPERTIES - IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${QtSingleApplication_LIBRARY}") - endif() - endif(NOT TARGET QtSingleApplication::QtSingleApplication) - -ELSE (QtSingleApplication_FOUND) - IF (QtSingleApplication_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find QtSingleApplication library") - ENDIF (QtSingleApplication_FIND_REQUIRED) -ENDIF (QtSingleApplication_FOUND) - -MARK_AS_ADVANCED(QtSingleApplication_INCLUDE_DIR QtSingleApplication_LIBRARY) diff --git a/cmake/Modules/winconf-mingw.cmake b/cmake/Modules/winconf-mingw.cmake index 755742257..5e55d5408 100644 --- a/cmake/Modules/winconf-mingw.cmake +++ b/cmake/Modules/winconf-mingw.cmake @@ -2,13 +2,15 @@ if (STACKTRACE) if (NOT "${WINXXBITS}" STREQUAL "Win64") add_compile_options(-fno-omit-frame-pointer) endif (NOT "${WINXXBITS}" STREQUAL "Win64") - link_libraries(libdbghelp -Wl,--export-all-symbols) + link_libraries(dbghelp -Wl,--export-all-symbols) endif (STACKTRACE) if (("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")) link_libraries(-Wl,--dynamicbase) -endif() +endif () -# LIBS += libadvapi32 libshell32 libuser32 -# LIBS += libcrypto.dll libssl.dll libwsock32 libws2_32 libz libiconv.dll -# LIBS += libpowrprof +list(APPEND LibtorrentRasterbar_CUSTOM_DEFINITIONS + -D__USE_W32_SOCKETS + -D_FILE_OFFSET_BITS=64) + +link_libraries(advapi32 shell32 user32 wsock32 ws2_32 powrprof) diff --git a/cmake/Modules/winconf-msvc.cmake b/cmake/Modules/winconf-msvc.cmake index 89f812b28..4a662d747 100644 --- a/cmake/Modules/winconf-msvc.cmake +++ b/cmake/Modules/winconf-msvc.cmake @@ -1,21 +1,12 @@ if (STACKTRACE) - if ("${WINXXBITS}" STREQUAL "Win64") - add_compile_options(-Zi) - else ("${WINXXBITS}" STREQUAL "Win64") + if (NOT "${WINXXBITS}" STREQUAL "Win64") # i686 arch requires frame pointer preservation add_compile_options(-Oy-) - endif ("${WINXXBITS}" STREQUAL "Win64") - link_libraries(dbghelp.lib) + endif (NOT "${WINXXBITS}" STREQUAL "Win64") + add_compile_options(-Zi) + link_libraries(dbghelp.lib /DEBUG) endif (STACKTRACE) -# Enable Wide characters -add_definitions(-DTORRENT_USE_WPATH) - -if (NOT QT5) - # Qt4 does not detect it itself - add_definitions(-DQ_COMPILER_INITIALIZER_LISTS) -endif (NOT QT5) - include(MacroConfigureMSVCRuntime) set(MSVC_RUNTIME "dynamic") configure_msvc_runtime() diff --git a/cmake/Modules/winconf.cmake b/cmake/Modules/winconf.cmake index 757d84e31..e0bfa96bd 100644 --- a/cmake/Modules/winconf.cmake +++ b/cmake/Modules/winconf.cmake @@ -2,15 +2,22 @@ list(APPEND CMAKE_LIBRARY_PATH "$ENV{LIB}") -# We want to link with static version of -# libtorrent -set(LibtorrentRasterbar_USE_STATIC_LIBS True) set(LibtorrentRasterbar_CUSTOM_DEFINITIONS + -DBOOST_ASIO_DISABLE_CONNECTEX -DBOOST_EXCEPTION_DISABLE - -DBOOST_SYSTEM_STATIC_LINK=1 -DTORRENT_USE_OPENSSL - -D__USE_W32_SOCKETS - -D_FILE_OFFSET_BITS=64) + -DTORRENT_DISABLE_RESOLVE_COUNTRIES) + +set(LibtorrentRasterbar_CUSTOM_BOOST_DEPENDENCIES system) + +# If you want to link with static version of libtorrent +#set(LibtorrentRasterbar_USE_STATIC_LIBS True) +#list(APPEND LibtorrentRasterbar_CUSTOM_DEFINITIONS +# -DBOOST_SYSTEM_STATIC_LINK=1) + +# and boost +#set(Boost_USE_STATIC_LIBS True) +#set(Boost_USE_STATIC_RUNTIME True) add_definitions(-DUNICODE -D_UNICODE @@ -24,9 +31,16 @@ add_definitions(-DUNICODE -D_SCL_SECURE_NO_DEPRECATE -DNOMINMAX ) -# and boost -set(Boost_USE_STATIC_LIBS True) -# set(Boost_USE_STATIC_RUNTIME True) + +# Enable if libtorrent was built with this flag defined +#list(APPEND LibtorrentRasterbar_CUSTOM_DEFINITIONS -DTORRENT_NO_DEPRECATE) + +if (("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") OR ("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")) + list(APPEND LibtorrentRasterbar_CUSTOM_DEFINITIONS + -DTORRENT_DEBUG) +else () + add_definitions(-DNDEBUG) +endif () # Here we assume that all required libraries are installed into the same prefix # with usual unix subdirectories (bin, lib, include) @@ -36,17 +50,9 @@ set(COMMON_INSTALL_PREFIX "c:/usr" CACHE PATH "Prefix used to install all the re list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${COMMON_INSTALL_PREFIX}") # If two version of Qt are installed, separate prefixes are needed most likely -set(QT4_INSTALL_PREFIX "${COMMON_INSTALL_PREFIX}/lib/qt4" CACHE PATH "Prefix where Qt4 is installed") set(QT5_INSTALL_PREFIX "${COMMON_INSTALL_PREFIX}/lib/qt5" CACHE PATH "Prefix where Qt5 is installed") # it is safe to set Qt dirs even if their files are directly in the prefix -# Qt4 -if(NOT QT5) - # for qt 4 we need qmake, Qt5 provides cmake config files - LIST(APPEND CMAKE_PROGRAM_PATH "${QT4_INSTALL_PREFIX}/bin/") -endif(NOT QT5) - -# Qt5 set(Qt5_DIR "${QT5_INSTALL_PREFIX}/lib/cmake/Qt5") # And now we can set specific values for the Boost and libtorrent libraries.