Skip to content

Commit

Permalink
Added all files worked on. Project is usable.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuzbog committed Nov 18, 2014
1 parent 6602f83 commit 9d3dceb
Show file tree
Hide file tree
Showing 26 changed files with 1,831 additions and 0 deletions.
89 changes: 89 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
project(mixcloud CXX)
cmake_minimum_required(VERSION 2.8.10)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")

# We require g++ 4.9, to avoid ABI breakage with earlier version.
set(cxx_version_required 4.9)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (NOT CMAKE_CXX_COMPILER_VERSION MATCHES "^${cxx_version_required}")
message(FATAL_ERROR "g++ version must be ${cxx_version_required}!")
endif()
endif()

# Set strict and naggy C++ compiler flags, and enable C++11
add_definitions(
-fno-permissive
-std=c++11
-pedantic
-Wall
-Wextra
-fPIC
-DQT_NO_KEYWORDS
)

include(GNUInstallDirs)
find_package(PkgConfig)

# We depend on Boost for string trimming
find_package(
Boost
REQUIRED
)

# Search for our dependencies
pkg_check_modules(
SCOPE
libunity-scopes>=0.6.0
net-cpp>=1.1.0
REQUIRED
)

find_package(Qt5Core REQUIRED)
include_directories(${Qt5Core_INCLUDE_DIRS})

# Add our dependencies to the include paths
include_directories(
"${CMAKE_SOURCE_DIR}/include"
${Boost_INCLUDE_DIRS}
${SCOPE_INCLUDE_DIRS}
)

# Do not remove this line, its required for the correct functionality of the Ubuntu-SDK
set(UBUNTU_MANIFEST_PATH "manifest.json.in" CACHE INTERNAL "Tells QtCreator location and name of the manifest file")
set(UBUNTU_PROJECT_TYPE "Scope" CACHE INTERNAL "Tells QtCreator this is a Scope project")

# Important project paths
set(CMAKE_INSTALL_PREFIX /)
set(SCOPE_INSTALL_DIR "/mixcloudscope")
set(GETTEXT_PACKAGE "mixcloud")

# If we need to refer to the scope's name or package in code, these definitions will help
add_definitions(-DPACKAGE_NAME="com.ubuntu.developer.boghison.mixcloud")
add_definitions(-DSCOPE_NAME="com.ubuntu.developer.boghison.mixcloud_mixcloudscope")
add_definitions(-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}")

#This command figures out the target architecture and puts it into the manifest file
execute_process(
COMMAND dpkg-architecture -qDEB_HOST_ARCH
OUTPUT_VARIABLE CLICK_ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)

# Install the click manifest
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION "/")
install(FILES "mixcloudscope.apparmor" DESTINATION "/")

# Make this file show up in QtCreator
add_custom_target(hidden_files
ALL
SOURCES
manifest.json.in
"mixcloudscope.apparmor"
)

# Add our main directories
add_subdirectory(src)
add_subdirectory(data)
add_subdirectory(po)
337 changes: 337 additions & 0 deletions CMakeLists.txt.user

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions cmake/FindGMock.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Build with system gmock and embedded gtest
set (GMOCK_INCLUDE_DIRS "/usr/include/gmock/include" CACHE PATH "gmock source include directory")
set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory")
set (GTEST_INCLUDE_DIRS "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory")

add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock")

set(GTEST_LIBRARIES gtest)
set(GTEST_MAIN_LIBRARIES gtest_main)
set(GMOCK_LIBRARIES gmock gmock_main)

set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})

131 changes: 131 additions & 0 deletions cmake/FindXGettext.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Copyright (C) 2013 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# This package provides macros that wrap the xgettext program.
#
# An example of common usage is:
#
# set(
# POT_FILE
# "${CMAKE_CURRENT_SOURCE_DIR}/${GETTEXT_PACKAGE}.pot"
# )
#
# file(
# GLOB_RECURSE SRC_FILES
# RELATIVE ${CMAKE_SOURCE_DIR}
# ${SOURCE_DIR}/*.cpp
# ${SOURCE_DIR}/*.c
# ${SOURCE_DIR}/*.h
# )
#
# xgettext_create_pot_file(
# ${POT_FILE}
# CPP
# QT
# INPUT ${SOURCES}
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# ADD_COMMENTS "TRANSLATORS"
# KEYWORDS "_" "N_"
# PACKAGE_NAME ${GETTEXT_PACKAGE}
# COPYRIGHT_HOLDER "Canonical Ltd."
# )

find_package(Gettext REQUIRED)

find_program(XGETTEXT_EXECUTABLE xgettext)

if(XGETTEXT_EXECUTABLE)
execute_process(
COMMAND ${XGETTEXT_EXECUTABLE} --version
OUTPUT_VARIABLE xgettext_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (xgettext_version MATCHES "^xgettext \\(.*\\) [0-9]")
string(
REGEX REPLACE "^xgettext \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1"
XGETTEXT_VERSION_STRING "${xgettext_version}"
)
endif()
unset(xgettext_version)
endif()

include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(
XGettext
REQUIRED_VARS XGETTEXT_EXECUTABLE
VERSION_VAR XGETTEXT_VERSION_STRING
)

function(APPEND_EACH LISTNAME GLUE OUTPUT)
set(_tmp_list "")
foreach(VAL ${${LISTNAME}})
list(APPEND _tmp_list "${GLUE}${VAL}")
endforeach(VAL ${${LISTNAME}})
set(${OUTPUT} "${_tmp_list}" PARENT_SCOPE)
endfunction()

function(XGETTEXT_CREATE_POT_FILE _potFile)
set(_options ALL QT CPP)
set(_oneValueArgs ADD_COMMENTS PACKAGE_NAME COPYRIGHT_HOLDER WORKING_DIRECTORY)
set(_multiValueArgs INPUT KEYWORDS)

cmake_parse_arguments(_ARG "${_options}" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})

set(_QT "")
if(_ARG_QT)
set(_QT "--qt")
endif()

set(_CPP "")
if(_ARG_CPP)
set(_CPP "--c++")
endif()

set(_KEYWORD "")
if(_ARG_KEYWORDS)
append_each(_ARG_KEYWORDS "--keyword=" _KEYWORD)
endif()

set(_ADD_COMMENTS "")
if(_ARG_ADD_COMMENTS)
set(_ADD_COMMENTS --add-comments="${_ARG_ADD_COMMENTS}")
endif()

set(_PACKAGE_NAME "")
if(_ARG_PACKAGE_NAME)
set(_PACKAGE_NAME --package-name="${_ARG_PACKAGE_NAME}")
endif()

set(_COPYRIGHT_HOLDER "")
if(_ARG_COPYRIGHT_HOLDER)
set(_COPYRIGHT_HOLDER --copyright-holder="${_ARG_COPYRIGHT_HOLDER}")
endif()

add_custom_command(
OUTPUT "${_potFile}"
COMMAND ${XGETTEXT_EXECUTABLE} --output="${_potFile}" ${_KEYWORD} ${_PACKAGE_NAME} ${_COPYRIGHT_HOLDER} ${_QT} ${_CPP} ${_ADD_COMMENTS} ${_ARG_INPUT}
WORKING_DIRECTORY ${_ARG_WORKING_DIRECTORY}
)

_GETTEXT_GET_UNIQUE_TARGET_NAME(_potFile _uniqueTargetName)

if(_ARG_ALL)
add_custom_target(${_uniqueTargetName} ALL DEPENDS ${_potFile})
else()
add_custom_target(${_uniqueTargetName} DEPENDS ${_potFile})
endif()

endfunction()

99 changes: 99 additions & 0 deletions cmake/UseXGettext.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright (C) 2013 Canonical Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# Example usage:
#
# include(UseXGettext)
#
# add_translations_directory(${GETTEXT_PACKAGE})
#
# add_translations_catalog(
# GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
# COPYRIGHT_HOLDER "Canonical Ltd."
# SOURCE_DIRECTORIES "${CMAKE_SOURCE_DIR}/src"
# )

cmake_minimum_required(VERSION 2.8.9)

find_package(XGettext REQUIRED)

macro(add_translations_directory GETTEXT_PACKAGE)
set(
_POT_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/${GETTEXT_PACKAGE}.pot"
)

file(
GLOB _PO_FILES
${CMAKE_CURRENT_SOURCE_DIR}/*.po
)

gettext_create_translations(
${_POT_FILE}
ALL
${_PO_FILES}
)
endmacro(add_translations_directory)

macro(add_translations_catalog)
set(_oneValueArgs GETTEXT_PACKAGE COPYRIGHT_HOLDER)
set(_multiValueArgs SOURCE_DIRECTORIES)

cmake_parse_arguments(_ARG "" "${_oneValueArgs}" "${_multiValueArgs}" ${ARGN})

set(_GETTEXT_PACKAGE ${PROJECT})
if(_ARG_GETTEXT_PACKAGE)
set(_GETTEXT_PACKAGE ${_ARG_GETTEXT_PACKAGE})
endif()

set(
_POT_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/${_GETTEXT_PACKAGE}.pot"
)

add_custom_target (pot
COMMENT “Building translation catalog.”
DEPENDS ${_POT_FILE}
)

set(_SOURCES "")

foreach(DIR ${_ARG_SOURCE_DIRECTORIES})
file(
GLOB_RECURSE _DIR_SOURCES
RELATIVE ${CMAKE_SOURCE_DIR}
${DIR}/*.cpp
${DIR}/*.cc
${DIR}/*.cxx
${DIR}/*.vala
${DIR}/*.c
${DIR}/*.h
)
set (_SOURCES ${_SOURCES} ${_DIR_SOURCES})
endforeach()

xgettext_create_pot_file(
${_POT_FILE}
ALL
CPP
QT
INPUT ${_SOURCES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
ADD_COMMENTS "TRANSLATORS"
KEYWORDS "_" "_:1,2" "N_" "N_:1,2"
PACKAGE_NAME ${_GETTEXT_PACKAGE}
COPYRIGHT_HOLDER ${_ARG_COPYRIGHT_HOLDER}
)
endmacro()

22 changes: 22 additions & 0 deletions data/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
configure_file(
"com.ubuntu.developer.boghison.mixcloud_mixcloudscope-settings.ini"
"${CMAKE_BINARY_DIR}/src/com.ubuntu.developer.boghison.mixcloud_mixcloudscope-settings.ini"
)
# Install the scope ini file
install(
FILES
"com.ubuntu.developer.boghison.mixcloud_mixcloudscope.ini"
"com.ubuntu.developer.boghison.mixcloud_mixcloudscope-settings.ini"
DESTINATION ${SCOPE_INSTALL_DIR}
)

# Install the scope images
install(
FILES
"art.png"
"logo.svg"
"mixcloud.svg"
DESTINATION
"${SCOPE_INSTALL_DIR}"
)

Binary file added data/art.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[showNew]
type = boolean
defaultValue = true
displayName = Show New Cloudcasts

[getExtra]
type = boolean
defaultValue = false
displayName = Use double requests to get extra metadata
13 changes: 13 additions & 0 deletions data/com.ubuntu.developer.boghison.mixcloud_mixcloudscope.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[ScopeConfig]
DisplayName = MixCloud Scope
Description = This is a MixCloud scope
Art = art.png
Author = Firstname Lastname
Icon = icon.png

[Appearance]
PageHeader.Logo = logo.svg
PageHeader.DividerColor = #33475f
ForegroundColor = #33475f
PreviewButtonColor = #33475f
BackgroundColor = #ffffff
Loading

0 comments on commit 9d3dceb

Please sign in to comment.