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

Add Qt 6 support to CMake project #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 59 additions & 60 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,106 +1,105 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.16)

if(POLICY CMP0048) # in CMake >= 3.0.0
cmake_policy(SET CMP0048 OLD) # keep project() from clearing VERSION variables
endif(POLICY CMP0048)

set( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules )
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

set(VER_MAJOR "1")
set(VER_MINOR "0")
set(VER_PATCH "1")
set(VER_PATCH "2")
set(API_VER_PATCH "0")
set(CPACK_PACKAGE_VERSION_MAJOR ${VER_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VER_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VER_PATCH})

set(PROJECT_VERSION ${VER_MAJOR}.${VER_MINOR}.${VER_PATCH})
set(API_VERSION ${VER_MAJOR}.${VER_MINOR}.${API_VER_PATCH})

project(o2)
project(o2
LANGUAGES CXX
VERSION ${PROJECT_VERSION}
)

option(o2_WITH_QT5 "Use Qt5" ON)
option(BUILD_SHARED_LIBS "Build shared library" OFF)

set(o2_LIB_SUFFIX "" CACHE STRING "Suffix for install 'lib' directory, e.g. 64 for lib64")

option(o2_SHOW_TRACE "Show debugging messages" OFF)
if(NOT o2_SHOW_TRACE)
add_definitions(-DQT_NO_DEBUG_OUTPUT=1)
option(o2_BUILD_EXAMPLES "Build examples" OFF)
option(o2_SHOW_TRACE "Show debugging messages" ON)

option(o2_WITH_DROPBOX "Authenticate with Dropbox" OFF)
option(o2_WITH_FACEBOOK "Authenticate with Facebook" OFF)
option(o2_WITH_FLICKR "Authenticate with Flickr" OFF)
option(o2_WITH_GOOGLE "Authenticate with Google" OFF)
option(o2_WITH_HUBIC "Authenticate with Hubic" OFF)
option(o2_WITH_MSGRAPH "Authenticate with MSGraph" OFF)
option(o2_WITH_SKYDRIVE "Authenticate with SkyDrive" OFF)
option(o2_WITH_SMUGMUG "Authenticate with SmugMug" OFF)
option(o2_WITH_SPOTIFY "Authenticate with Spotify" OFF)
option(o2_WITH_SURVEYMONKEY "Authenticate with SurveyMonkey" OFF)
option(o2_WITH_TWITTER "Authenticate with Twitter" OFF)
option(o2_WITH_UBER "Authenticate with Uber" OFF)
option(o2_WITH_VIMEO "Authenticate with Vimeo" OFF)

option(o2_WITH_KEYCHAIN "keychain store" OFF)
option(o2_WITH_OAUTH1 "Include OAuth1 authentication" OFF)

if(o2_WITH_TWITTER OR o2_WITH_DROPBOX OR o2_WITH_FLICKR OR o2_WITH_SMUGMUG)
set(o2_WITH_OAUTH1 ON)
endif()

option(o2_WITH_TWITTER "Authenticate with Twitter" OFF)
option(o2_WITH_DROPBOX "Authenticate with Dropbox" OFF)
option(o2_WITH_GOOGLE "Authenticate with Google" OFF)
option(o2_WITH_VIMEO "Authenticate with Vimeo" OFF)
option(o2_WITH_FACEBOOK "Authenticate with Facebook" OFF)
option(o2_WITH_UBER "Authenticate with Uber" OFF)
option(o2_WITH_SKYDRIVE "Authenticate with SkyDrive" OFF)
option(o2_WITH_FLICKR "Authenticate with Flickr" OFF)
option(o2_WITH_HUBIC "Authenticate with Hubic" OFF)
option(o2_WITH_SPOTIFY "Authenticate with Spotify" OFF)
option(o2_WITH_SURVEYMONKEY "Authenticate with SurveyMonkey" OFF)
option(o2_WITH_SMUGMUG "Authenticate with SmugMug" OFF)
option(o2_WITH_MSGRAPH "Authenticate with MSGraph" OFF)
option(o2_WITH_KEYCHAIN "keychain store" ON)
if(NOT o2_SHOW_TRACE)
add_compile_definitions(QT_NO_DEBUG_OUTPUT=1)
endif()

option(o2_WITH_OAUTH1 "Include OAuth1 authentication" OFF)
add_subdirectory(src)

if (o2_WITH_TWITTER)
set(HAVE_TWITTER_SUPPORT 1)
if(o2_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

# prepare variables for config header

if (o2_WITH_DROPBOX)
set(HAVE_DROPBOX_SUPPORT 1)
endif()
if (o2_WITH_GOOGLE)
set(HAVE_GOOGLE_SUPPORT 1)
endif()
if (o2_WITH_FACEBOOK)
set(HAVE_FACEBOOK_SUPPORT 1)
endif()
if (o2_WITH_UBER)
set(HAVE_UBER_SUPPORT 1)
endif()
if (o2_WITH_SKYDRIVE)
set(HAVE_SKYDRIVE_SUPPORT 1)
endif()
if (o2_WITH_FLICKR)
set(HAVE_FLICKR_SUPPORT 1)
endif()
if (o2_WITH_GOOGLE)
set(HAVE_GOOGLE_SUPPORT 1)
endif()
if (o2_WITH_HUBIC)
set(HAVE_HUBIC_SUPPORT 1)
endif()
if (o2_WITH_MSGRAPH)
set(HAVE_MSGRAPH_SUPPORT 1)
endif()
if (o2_WITH_SKYDRIVE)
set(HAVE_SKYDRIVE_SUPPORT 1)
endif()
if (o2_WITH_SMUGMUG)
set(HAVE_SMUGMUG_SUPPORT 1)
endif()
if (o2_WITH_SPOTIFY)
set(HAVE_SPOTIFY_SUPPORT 1)
endif()
if (o2_WITH_SURVEYMONKEY)
set(HAVE_SURVEYMONKEY_SUPPORT 1)
endif()
if (o2_WITH_SMUGMUG)
set(HAVE_SMUGMUG_SUPPORT 1)
if (o2_WITH_TWITTER)
set(HAVE_TWITTER_SUPPORT 1)
endif()
if (o2_WITH_MSGRAPH)
set(HAVE_MSGRAPH_SUPPORT 1)
if (o2_WITH_UBER)
set(HAVE_UBER_SUPPORT 1)
endif()
if (o2_WITH_VIMEO)
set(HAVE_VIMEO_SUPPORT 1)
endif()
if (o2_WITH_KEYCHAIN)
set(HAVE_KEYCHAIN_SUPPORT 1)
endif()
if (o2_WITH_OAUTH1)
set(HAVE_OAUTH1_SUPPORT 1)
endif()



if(o2_WITH_TWITTER OR o2_WITH_DROPBOX OR o2_WITH_FLICKR OR o2_WITH_SMUGMUG)
set(o2_WITH_OAUTH1 ON)
endif()

option(o2_BUILD_EXAMPLES "Build examples" OFF)

if(WIN32)
add_definitions(-DO2_DLL_EXPORT)
endif()

add_subdirectory(src)

if(o2_BUILD_EXAMPLES)
add_subdirectory(examples)
endif(o2_BUILD_EXAMPLES)
38 changes: 0 additions & 38 deletions cmake/modules/FindQt5Keychain.cmake

This file was deleted.

39 changes: 0 additions & 39 deletions cmake/modules/FindQtKeychain.cmake

This file was deleted.

11 changes: 6 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.16)

if(o2_WITH_FACEBOOK)
add_subdirectory(facebookdemo)
add_subdirectory(facebookexternalinterceptordemo)
endif(o2_WITH_FACEBOOK)

if(o2_WITH_GOOGLE)
Expand All @@ -12,14 +13,14 @@ if(o2_WITH_TWITTER)
add_subdirectory(twitterdemo)
endif(o2_WITH_TWITTER)

#if(o2_WITH_SPOTIFY)
# add_subdirectory(spotifydemo)
#endif(o2_WITH_SPOTIFY)

if (o2_WITH_VIMEO)
add_subdirectory(vimeodemo)
endif(o2_WITH_VIMEO)

if (o2_WITH_YOUTUBE)
add_subdirectory(youtubedemo)
endif(o2_WITH_YOUTUBE)

if (o2_WITH_MSGRAPH)
add_subdirectory(msgraphdemo)
add_subdirectory(msgraphexternalinterceptordemo)
Expand Down
48 changes: 17 additions & 31 deletions examples/facebookdemo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,44 +1,30 @@
cmake_minimum_required(VERSION 2.8.11)
cmake_minimum_required(VERSION 3.16)

project( fbexample )
project(facebookexample)

set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")

if(o2_WITH_QT5)
# Qt5 packages find their own dependencies.
find_package(Qt5Core REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Script REQUIRED)
find_package(Qt5Network REQUIRED)
else(o2_WITH_QT5)
set(QT_USE_QTNETWORK true)
set(QT_USE_QTSCRIPT true)
find_package(Qt4 REQUIRED)
endif(o2_WITH_QT5)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network Widgets)

if (NOT o2_WITH_QT5)
include( ${QT_USE_FILE} )
endif(NOT o2_WITH_QT5)

include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} "../../src" )

set(fb_SRCS
add_executable(${PROJECT_NAME} WIN32
main.cpp
fbdemo.cpp
fbdemo.h
)

if(NOT o2_WITH_QT5)
add_definitions(${QT4_DEFINITIONS})
endif(NOT o2_WITH_QT5)
target_link_libraries(${PROJECT_NAME}
PRIVATE
o2

add_executable( fbexample ${fb_SRCS} )
Qt${QT_MAJOR_VERSION}::Core
Qt${QT_MAJOR_VERSION}::Network
Qt${QT_MAJOR_VERSION}::Widgets
)

if(o2_WITH_QT5)
qt5_use_modules( fbexample Core Widgets Network )
target_link_libraries( fbexample o2 )
else(o2_WITH_QT5)
target_link_libraries( fbexample ${QT_LIBRARIES} o2 )
endif(o2_WITH_QT5)
if (MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W3)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wall)
endif()
5 changes: 1 addition & 4 deletions examples/facebookdemo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ class Helper : public QObject {
public slots:
void processArgs() {
QStringList argList = qApp->arguments();
QByteArray help = QString(USAGE).arg(OPT_OAUTH_CODE,
OPT_VALIDATE_TOKEN).toLatin1();
const char* helpText = help.constData();
connect(&fbdemo_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed()));
connect(&fbdemo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded()));
if (argList.contains(OPT_OAUTH_CODE)) {
Expand All @@ -36,7 +33,7 @@ public slots:
} else if (argList.contains(OPT_VALIDATE_TOKEN)) {
fbdemo_.validateToken();
} else {
qDebug() << helpText;
qDebug() << QString(USAGE).arg(OPT_OAUTH_CODE, OPT_VALIDATE_TOKEN);
qApp->exit(1);
}
}
Expand Down
Loading