Permalink
Browse files

make it possible to build qt with kde enabled and disabled at the sam…

…e time while keeping backward compatiblilty
  • Loading branch information...
yuyichao authored and kuromabo committed Jan 21, 2013
1 parent 78571e7 commit 140011e0165276f04225ae540d679f7a506ae820
Showing with 101 additions and 63 deletions.
  1. +10 −4 .gitignore
  2. +5 −2 CMakeLists.txt
  3. +0 −11 misc/CMakeLists.txt
  4. +1 −1 misc/{hotot-qt.desktop.in → hotot-qt.desktop.in.in}
  5. +84 −43 qt/CMakeLists.txt
  6. +1 −1 qt/common.h
  7. +0 −1 qt/config.h.in
@@ -1,9 +1,15 @@
build/*
*~
build*/
.*
!.git*
.git/
*.tar.*
*.kdev4
.kdev_include_paths
.directory
*.kate-swp
*.orig
tags
astyle.sh
cscope.*
*.part
*.swp
*.pyc
*~
@@ -13,6 +13,7 @@ option(WITH_GTK3 "Enable GTK3 Version" Off)

option(WITH_QT "Enable Qt Version" On)
option(WITH_KDE "Enable KDE4 integration for Qt" On)
option(WITH_KDE_QT "Build Qt and KDE versions at the same time" Off)

option(WITH_CHROME "Enable Chrome Version" Off)

@@ -22,10 +23,12 @@ if(NOT INTLTOOL_MERGE)
message(FATAL_ERROR "intltool-merge required for i18n generation")
endif()

set(INTLTOOL_PO_DIR "${PROJECT_SOURCE_DIR}/po")

function(intltool_merge_translation infile outfile)
add_custom_command(
OUTPUT ${outfile}
COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${PROJECT_SOURCE_DIR}/po
COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u "${INTLTOOL_PO_DIR}"
${infile} ${outfile}
DEPENDS ${infile})
endfunction()
@@ -97,7 +100,7 @@ if(WITH_CHROME)
endif()

##################### Qt Version ######################
if(WITH_QT)
if(WITH_QT OR WITH_KDE_QT)
add_subdirectory(qt)
endif()

@@ -15,14 +15,3 @@ foreach(size ${ICON_SIZE})
install(FILES "${PROJECT_SOURCE_DIR}/data/icons/${size}/apps/hotot.png"
DESTINATION "share/icons/hicolor/${size}/apps/")
endforeach()

intltool_merge_translation(${CMAKE_CURRENT_SOURCE_DIR}/hotot-qt.desktop.in
${CMAKE_CURRENT_BINARY_DIR}/hotot-qt.desktop)

add_custom_target(desktopfile ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/hotot-qt.desktop)

if(WITH_QT)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hotot-qt.desktop
DESTINATION share/applications/)
endif()
@@ -3,6 +3,6 @@ _Name=Hotot Qt
GenericName=Twitter Client
Type=Application
_Comment=Lightweight Twitter client based on Qt and WebKit
Exec=hotot-qt
Exec=@HOTOT_QT_BIN@
Icon=hotot
Categories=Qt;Network;InstantMessaging;
@@ -1,5 +1,9 @@
project(hotot_qt C CXX)

if(WITH_KDE_QT)
set(WITH_KDE On)
endif()

# Setup KDE4 support
if(WITH_KDE)
find_package(KDE4)
@@ -8,22 +12,32 @@ if(WITH_KDE)
include_directories(${KDE4_INCLUDES})
add_definitions(${KDE4_DEFINITIONS})
set(HAVE_KDE 1)
else(KDE4_FOUND)
else()
message(STATUS "KDE4 not found, disabling KDE integration")
endif(KDE4_FOUND)
else(WITH_KDE)
set(WITH_KDE_QT Off)
endif()
else()
message(STATUS "Not enabling KDE4 integration")
endif(WITH_KDE)
endif()

if(NOT HAVE_KDE)
find_package(Qt4 4.7 REQUIRED COMPONENTS QtCore QtGui QtWebkit QtSql)
set(BUILD_QT On)
else()
set(BUILD_KDE On)
if(WITH_KDE_QT)
set(BUILD_QT On)
set(HOTOT_KDE_BIN_NAME hotot-kde)
else()
set(HOTOT_KDE_BIN_NAME hotot-qt)
endif()
endif()

set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -fvisibility=hidden ${CMAKE_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--as-needed ${CMAKE_MODULE_LINKER_FLAGS}")

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
configure_file(config.h.in config.h)

include_directories(${QT_INCLUDE_DIR})
include_directories(${QT_QTCORE_INCLUDE_DIR})
@@ -34,48 +48,75 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

set(Hotot_QT_SRCS
formpost.cpp
hototrequest.cpp
main.cpp
mainwindow.cpp
hototwebpage.cpp
qttraybackend.cpp
)

formpost.cpp
hototrequest.cpp
main.cpp
mainwindow.cpp
hototwebpage.cpp
qttraybackend.cpp
)
set(Hotot_QT_MOC_SRCS
mainwindow.h
formpost.h
hototrequest.h
hototwebpage.h
qttraybackend.h
)
mainwindow.h
formpost.h
hototrequest.h
hototwebpage.h
qttraybackend.h
)

if (HAVE_KDE)
set(Hotot_QT_SRCS
${Hotot_QT_SRCS}
kdetraybackend.cpp
)
set(Hotot_QT_MOC_SRCS
${Hotot_QT_MOC_SRCS}
kdetraybackend.h
)
endif (HAVE_KDE)
set(Hotot_KDE_SRCS
kdetraybackend.cpp
)
set(Hotot_KDE_MOC_SRCS
kdetraybackend.h
)

qt4_wrap_cpp(Hotot_QT_MOCS ${Hotot_QT_MOC_SRCS})
add_executable(hotot-qt ${Hotot_QT_SRCS} ${Hotot_QT_MOCS})

set_target_properties(hotot-qt PROPERTIES LINKER_LANGUAGE CXX)
set(HOTOT_QT_LINKS
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTWEBKIT_LIBRARY}
${QT_QTNETWORK_LIBRARY}
)

target_link_libraries(hotot-qt
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTWEBKIT_LIBRARY}
${QT_QTNETWORK_LIBRARY}
)

if(HAVE_KDE)
target_link_libraries(hotot-qt ${KDE4_KDEUI_LIBRARY} ${KDE4_KIO_LIBS})
install(FILES ../misc/hotot_qt.svg DESTINATION ${KDE4_DATA_INSTALL_DIR}/desktoptheme/default/icons)
endif (HAVE_KDE)
if(BUILD_QT)
add_executable(hotot-qt ${Hotot_QT_SRCS} ${Hotot_QT_MOCS})
set_target_properties(hotot-qt PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(hotot-qt ${HOTOT_QT_LINKS})
install(TARGETS hotot-qt DESTINATION bin)
set(HOTOT_QT_BIN hotot-qt)
configure_file("${PROJECT_SOURCE_DIR}/../misc/hotot-qt.desktop.in.in"
hotot-qt.desktop.in @ONLY)
intltool_merge_translation(
"${CMAKE_CURRENT_BINARY_DIR}/hotot-qt.desktop.in"
"${CMAKE_CURRENT_BINARY_DIR}/hotot-qt.desktop")
add_custom_target(desktopfile-qt ALL
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/hotot-qt.desktop")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/hotot-qt.desktop"
DESTINATION share/applications/)
endif()

install(TARGETS hotot-qt DESTINATION bin)
if(BUILD_KDE)
qt4_wrap_cpp(Hotot_KDE_MOCS ${Hotot_KDE_MOC_SRCS})
add_executable("${HOTOT_KDE_BIN_NAME}"
${Hotot_QT_SRCS} ${Hotot_QT_MOCS}
${Hotot_KDE_SRCS} ${Hotot_KDE_MOCS})
set_target_properties("${HOTOT_KDE_BIN_NAME}"
PROPERTIES LINKER_LANGUAGE CXX COMPILE_DEFINITIONS "HAVE_KDE=1")
target_link_libraries("${HOTOT_KDE_BIN_NAME}" ${HOTOT_QT_LINKS})
target_link_libraries("${HOTOT_KDE_BIN_NAME}"
${KDE4_KDEUI_LIBRARY} ${KDE4_KIO_LIBS})
install(TARGETS "${HOTOT_KDE_BIN_NAME}" DESTINATION bin)
install(FILES ../misc/hotot_qt.svg
DESTINATION ${KDE4_DATA_INSTALL_DIR}/desktoptheme/default/icons)
set(HOTOT_QT_BIN "${HOTOT_KDE_BIN_NAME}")
configure_file("${PROJECT_SOURCE_DIR}/../misc/hotot-qt.desktop.in.in"
"${HOTOT_KDE_BIN_NAME}.desktop.in" @ONLY)
intltool_merge_translation(
"${CMAKE_CURRENT_BINARY_DIR}/${HOTOT_KDE_BIN_NAME}.desktop.in"
"${CMAKE_CURRENT_BINARY_DIR}/${HOTOT_KDE_BIN_NAME}.desktop")
add_custom_target(desktopfile-kde ALL
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${HOTOT_KDE_BIN_NAME}.desktop")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${HOTOT_KDE_BIN_NAME}.desktop"
DESTINATION share/applications/)
endif()
@@ -42,4 +42,4 @@
# endif
#endif

#endif
#endif
@@ -1,2 +1 @@
#define PREFIX "@CMAKE_INSTALL_PREFIX@"
#cmakedefine HAVE_KDE

0 comments on commit 140011e

Please sign in to comment.