Commit 1f99e93d authored by Wouter's avatar Wouter

Build system install rules and target exports

Also makes the include directories better, instead of depending on the
exact location in this build tree
parent f3c13e41
......@@ -14,10 +14,44 @@ find_package(Qt5Widgets)
add_definitions(-DQT_USE_QSTRINGBUILDER)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
# Determine installation path for CMake files
if(WIN32 AND NOT CYGWIN)
set(INSTALL_CMAKE_DIR CMake)
else()
set(INSTALL_CMAKE_DIR lib/cmake/QJsonIntrospect)
endif()
# Version information
set(QJsonIntrospect_MAJOR_VERSION 1)
set(QJsonIntrospect_MINOR_VERSION 0)
set(QJsonIntrospect_PATCH_VERSION 0)
set(QJsonIntrospect_VERSION
${QJsonIntrospect_MAJOR_VERSION}.${QJsonIntrospect_MINOR_VERSION}.${QJsonIntrospect_PATCH_VERSION})
add_subdirectory(grantlee)
add_subdirectory(lib)
add_subdirectory(gui)
add_subdirectory(cli)
include(CMakePackageConfigHelpers)
set(QJsonIntrospect_BINARY_PATH "bin/qjsonintrospect-cli${CMAKE_EXECUTABLE_SUFFIX}")
configure_package_config_file(QJsonIntrospectConfig.cmake.in
"${PROJECT_BINARY_DIR}/QJsonIntrospectConfig.cmake"
PATH_VARS QJsonIntrospect_BINARY_PATH
INSTALL_DESTINATION "${INSTALL_CMAKE_DIR}")
write_basic_package_version_file("${PROJECT_BINARY_DIR}/QJsonIntrospectVersion.cmake" VERSION ${QJsonIntrospect_VERSION} COMPATIBILITY SameMajorVersion)
install(
FILES
"${PROJECT_BINARY_DIR}/QJsonIntrospectConfig.cmake"
"${PROJECT_BINARY_DIR}/QJsonIntrospectVersion.cmake"
DESTINATION ${INSTALL_CMAKE_DIR}
COMPONENT dev)
install(EXPORT QJsonIntrospectTargets
DESTINATION "${INSTALL_CMAKE_DIR}"
COMPONENT dev
)
# - Config file for the LibDbpf package
#
# Once done, this will define:
# LibDbpf_FOUND - system has LibDbpf
# LibDbpf_INCLUDE_DIRS - the LibDbpf include directory
# LibDbpf_LIBRARY - LibDbpf library
# LibDbpf_PLUGIN_PATH - Plugin installation path
# LibDbpf_CMAKE_UTILS - Path to the CMake utilities file (LibDbpfUtils.cmake)
#
# Copyright (C) 2014-2015 Wouter Haffmans <wouter@simply-life.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
set(QJsonIntrospect_VERSION "@QJsonIntrospect_VERSION@")
@PACKAGE_INIT@
# Find dependencies
find_package(Qt5Core REQUIRED)
include(${CMAKE_CURRENT_LIST_DIR}/QJsonIntrospectTargets.cmake)
# These are IMPORTED targets created by LibDbpfTargets.cmake
get_target_property(QJsonIntrospect_EXECUTABLE qjsonintrospect-cli LOCATION)
set(QJsonIntrospect_LIBRARY qjsonintrospect)
get_target_property(QJsonIntrospect_INCLUDE_DIRS qjsonintrospect INTERFACE_INCLUDE_DIRECTORIES)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
project(qjsonintrospect-cli)
cmake_minimum_required(VERSION 3.0)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(QJsonIntrospect_CLI_SRCS
introspectorcli.cpp
......@@ -7,4 +11,12 @@ set(QJsonIntrospect_CLI_SRCS
add_executable(qjsonintrospect-cli ${QJsonIntrospect_CLI_SRCS})
target_link_libraries(qjsonintrospect-cli
Qt5::Core Grantlee5::Templates qjsonintrospect)
qjsonintrospect
Grantlee5::Templates
)
install(TARGETS qjsonintrospect-cli
EXPORT QJsonIntrospectTargets
RUNTIME DESTINATION bin
COMPONENT app
)
......@@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "cli/introspectorcli.h"
#include "introspectorcli.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
......@@ -26,8 +26,8 @@
#include <QtCore/QCommandLineParser>
#include <QtCore/QCommandLineOption>
#include "lib/introspector.h"
#include <lib/config.h>
#include <introspector.h>
#include <config.h>
using namespace QJsonIntrospect;
......
#include <QtCore/QCoreApplication>
#include <QtCore/QTimer>
#include "cli/introspectorcli.h"
#include "introspectorcli.h"
int main(int argc, char** argv)
......
......@@ -20,7 +20,7 @@
#include "filters.h"
#include "helpers.h"
#include "lib/metacode/type.h"
#include "../lib/metacode/type.h"
#include <QtCore/QRegExp>
#include <QtCore/QFileInfo>
......
......@@ -14,3 +14,9 @@ qt5_wrap_ui(QJsonIntrospect_GUI_UIS introspectorgui.ui)
add_executable(qjsonintrospect-gui ${QJsonIntrospect_GUI_SRCS} ${QJsonIntrospect_GUI_UIS})
target_link_libraries(qjsonintrospect-gui
Qt5::Core Qt5::Widgets Grantlee5::Templates qjsonintrospect)
install(TARGETS qjsonintrospect-gui
EXPORT QJsonIntrospectTargets
RUNTIME DESTINATION bin
COMPONENT app
)
......@@ -17,9 +17,9 @@
*
*/
#include "gui/introspectorgui.h"
#include "introspectorgui.h"
#include "qvariantmodel.h"
#include "lib/introspector.h"
#include <introspector.h>
#include <QtCore/QDebug>
#include <QtCore/QByteArray>
......@@ -30,10 +30,10 @@
#include <QtWidgets/QFileSystemModel>
#include <QtWidgets/QMessageBox>
#include "gui/ui_introspectorgui.h"
#include "gui/typefilterproxymodel.h"
#include "lib/classwriter.h"
#include "lib/metacode/typeregistry.h"
#include "ui_introspectorgui.h"
#include "typefilterproxymodel.h"
#include "classwriter.h"
#include "metacode/typeregistry.h"
using namespace QJsonIntrospect;
......
#include <QtWidgets/QApplication>
#include "gui/introspectorgui.h"
#include "introspectorgui.h"
int main(int argc, char** argv)
{
......
......@@ -17,7 +17,7 @@
*
*/
#include "gui/typefilterproxymodel.h"
#include "typefilterproxymodel.h"
using namespace QJsonIntrospect;
......
project(qjsonintrospect)
cmake_minimum_required(VERSION 3.0)
add_subdirectory(metacode)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
set(libQJsonIntrospect_SRCS
basenametemplateloader.cpp
codewriter.cpp
......@@ -15,6 +20,29 @@ set(libQJsonIntrospect_SRCS
introspector.cpp
)
# TODO These may not all have to be public
set(libQJsonIntrospect_HDRS
basenametemplateloader.h
codewriter.h
classwriter.h
arraywriter.h
wrapperwriter.h
unionwriter.h
projectwriter.h
config.h
introspector.h
)
add_library(qjsonintrospect SHARED ${libQJsonIntrospect_SRCS})
target_link_libraries(qjsonintrospect
Qt5::Core Grantlee5::Templates metacode)
set_property(TARGET qjsonintrospect APPEND PROPERTY PUBLIC_HEADER
${libQJsonIntrospect_HDRS})
install(TARGETS qjsonintrospect
EXPORT QJsonIntrospectTargets
RUNTIME DESTINATION bin COMPONENT app
LIBRARY DESTINATION lib COMPONENT app
PUBLIC_HEADER DESTINATION include/qjsonintrospect COMPONENT dev
)
......@@ -17,9 +17,9 @@
*
*/
#include "lib/arraywriter.h"
#include "arraywriter.h"
#include "lib/metacode/array.h"
#include "metacode/array.h"
using namespace QJsonIntrospect;
......
......@@ -20,8 +20,8 @@
#ifndef QJSONINTROSPECT_ARRAYWRITER_H
#define QJSONINTROSPECT_ARRAYWRITER_H
#include "lib/codewriter.h"
#include "lib/metacode/typereference.h"
#include "codewriter.h"
#include "metacode/typereference.h"
namespace QJsonIntrospect {
......
......@@ -17,7 +17,7 @@
*
*/
#include "lib/basenametemplateloader.h"
#include "basenametemplateloader.h"
#include <QtCore/QDir>
......
#include "lib/classwriter.h"
#include "classwriter.h"
#include <QtCore/QQueue>
#include <QtCore/QDebug>
#include <grantlee/context.h>
#include "lib/metacode/class.h"
#include "lib/metacode/type.h"
#include "lib/metacode/typereference.h"
#include "lib/metacode/typeregistry.h"
#include "metacode/class.h"
#include "metacode/type.h"
#include "metacode/typereference.h"
#include "metacode/typeregistry.h"
using namespace QJsonIntrospect;
......
#ifndef QJSONINTROSPECT_CLASSWRITER_H
#define QJSONINTROSPECT_CLASSWRITER_H
#include "lib/codewriter.h"
#include "codewriter.h"
#include <QtCore/QObject>
#include <QtCore/QHash>
......@@ -14,9 +14,9 @@
#include <QtCore/QTextStream>
#include <grantlee/metatype.h>
#include "lib/metacode/type.h"
#include "lib/metacode/typereference.h"
#include "lib/metacode/classmember.h"
#include "metacode/type.h"
#include "metacode/typereference.h"
#include "metacode/classmember.h"
class QTextStream;
......
......@@ -16,13 +16,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "lib/codewriter.h"
#include "codewriter.h"
#include <QtCore/QDebug>
#include <QtCore/QBuffer>
#include <grantlee/engine.h>
#include "lib/metacode/typeregistry.h"
#include "metacode/typeregistry.h"
using namespace QJsonIntrospect;
......
......@@ -24,8 +24,8 @@
#include <QtCore/QDir>
#include <QtCore/QTextStream>
#include "lib/basenametemplateloader.h"
#include "lib/metacode/type.h"
#include "basenametemplateloader.h"
#include "metacode/type.h"
class QBuffer;
......
#include "lib/config.h"
#include "config.h"
#include <QtCore/QSettings>
#include <QtCore/QtDebug>
......
#include "lib/introspector.h"
#include "introspector.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDateTime>
......@@ -10,25 +10,25 @@
#include <qjson/parser.h>
#include <grantlee/metatype.h>
#include "lib/config.h"
#include "lib/classwriter.h"
#include "lib/arraywriter.h"
#include "lib/wrapperwriter.h"
#include "lib/unionwriter.h"
#include "lib/projectwriter.h"
#include "lib/metacode/array.h"
#include "lib/metacode/class.h"
#include "lib/metacode/classmember.h"
#include "lib/metacode/method.h"
#include "lib/metacode/property.h"
#include "lib/metacode/constructor.h"
#include "lib/metacode/innertype.h"
#include "lib/metacode/notification.h"
#include "lib/metacode/rpcmethod.h"
#include "lib/metacode/wrappertype.h"
#include "lib/metacode/uniontype.h"
#include "lib/metacode/type.h"
#include "lib/metacode/typeregistry.h"
#include "config.h"
#include "classwriter.h"
#include "arraywriter.h"
#include "wrapperwriter.h"
#include "unionwriter.h"
#include "projectwriter.h"
#include "metacode/array.h"
#include "metacode/class.h"
#include "metacode/classmember.h"
#include "metacode/method.h"
#include "metacode/property.h"
#include "metacode/constructor.h"
#include "metacode/innertype.h"
#include "metacode/notification.h"
#include "metacode/rpcmethod.h"
#include "metacode/wrappertype.h"
#include "metacode/uniontype.h"
#include "metacode/type.h"
#include "metacode/typeregistry.h"
using namespace QJsonIntrospect;
......
......@@ -20,5 +20,34 @@ set(libMetacode_SRCS
uniontype.cpp
)
add_library(metacode SHARED ${libMetacode_SRCS})
set(libMetacode_HDRS
type.h
typereference.h
typeregistry.h
class.h
classmember.h
innertype.h
method.h
constructor.h
initializer.h
field.h
property.h
rpcmethod.h
notification.h
array.h
wrappertype.h
uniontype.h
)
add_library(metacode STATIC ${libMetacode_SRCS})
target_link_libraries(metacode Qt5::Core Grantlee5::Templates)
set_property(TARGET metacode APPEND PROPERTY PUBLIC_HEADER
${libMetacode_HDRS})
install(TARGETS metacode
EXPORT QJsonIntrospectTargets
ARCHIVE DESTINATION lib COMPONENT dev
PUBLIC_HEADER DESTINATION include/qjsonintrospect COMPONENT dev
)
......@@ -17,7 +17,7 @@
*
*/
#include "lib/metacode/array.h"
#include "array.h"
using namespace QJsonIntrospect;
......
......@@ -20,7 +20,7 @@
#ifndef QJSONINTROSPECT_ARRAY_H
#define QJSONINTROSPECT_ARRAY_H
#include "lib/metacode/type.h"
#include "type.h"
namespace QJsonIntrospect {
......
......@@ -17,19 +17,19 @@
*
*/
#include "lib/metacode/class.h"
#include "class.h"
#include <QtCore/QQueue>
#include "lib/metacode/typeregistry.h"
#include "lib/metacode/classmember.h"
#include "lib/metacode/field.h"
#include "lib/metacode/method.h"
#include "lib/metacode/rpcmethod.h"
#include "lib/metacode/notification.h"
#include "lib/metacode/constructor.h"
#include "lib/metacode/innertype.h"
#include "lib/metacode/property.h"
#include "typeregistry.h"
#include "classmember.h"
#include "field.h"
#include "method.h"
#include "rpcmethod.h"
#include "notification.h"
#include "constructor.h"
#include "innertype.h"
#include "property.h"
using namespace QJsonIntrospect;
......
......@@ -26,9 +26,9 @@
#include <QtCore/QList>
#include <grantlee/metatype.h>
#include "lib/metacode/type.h"
#include "lib/metacode/typereference.h"
#include "lib/metacode/classmember.h"
#include "type.h"
#include "typereference.h"
#include "classmember.h"
namespace QJsonIntrospect {
class Field;
......
......@@ -17,9 +17,9 @@
*/
#include "lib/metacode/classmember.h"
#include "classmember.h"
#include "lib/metacode/class.h"
#include "class.h"
using namespace QJsonIntrospect;
......
......@@ -25,9 +25,9 @@
#include <QtCore/QMetaEnum>
#include <grantlee/metatype.h>
#include "lib/metacode/typereference.h"
#include "lib/metacode/type.h"
#include "lib/metacode/grantlee_enum.h"
#include "typereference.h"
#include "type.h"
#include "grantlee_enum.h"
namespace QJsonIntrospect {
......
#include "lib/metacode/constructor.h"
#include "constructor.h"
#include "lib/metacode/class.h"
#include "lib/metacode/property.h"
#include "class.h"
#include "property.h"
using namespace QJsonIntrospect;
......
#ifndef QJSONINTROSPECT_CONSTRUCTOR_H
#define QJSONINTROSPECT_CONSTRUCTOR_H
#include "lib/metacode/method.h"
#include "method.h"
#include <QtCore/QString>
#include <QtCore/QStringList>
#include "lib/metacode/initializer.h"
#include "lib/metacode/class.h"
#include "initializer.h"
#include "class.h"
namespace QJsonIntrospect {
......
#include "lib/metacode/class.h"
#include "lib/metacode/field.h"
#include "lib/metacode/method.h"
#include "lib/metacode/typeregistry.h"
#include "class.h"
#include "field.h"
#include "method.h"
#include "typeregistry.h"
using namespace QJsonIntrospect;
......
#ifndef QJSONINTROSPECT_FIELD_H
#define QJSONINTROSPECT_FIELD_H
#include "lib/metacode/classmember.h"
#include "classmember.h"
namespace QJsonIntrospect {
......
......@@ -17,7 +17,7 @@
*
*/
#include "lib/metacode/initializer.h"
#include "initializer.h"
using namespace QJsonIntrospect;
......
......@@ -24,7 +24,7 @@
#include <QtCore/QMetaType>
#include <QStringList>
#include "lib/metacode/type.h"
#include "type.h"
namespace QJsonIntrospect {
......
......@@ -17,9 +17,9 @@
*/
#include "lib/metacode/innertype.h"
#include "innertype.h"
#include "lib/metacode/class.h"
#include "class.h"
using namespace QJsonIntrospect;
......
......@@ -20,7 +20,7 @@
#ifndef QJSONINTROSPECT_INNERCLASS_H
#define QJSONINTROSPECT_INNERCLASS_H
#include "lib/metacode/classmember.h"
#include "classmember.h"
namespace QJsonIntrospect {
......
#include "lib/metacode/method.h"
#include "method.h"
#include <QtCore/QStringList>
#include <QtCore/QDebug>
#include "lib/metacode/class.h"
#include "lib/metacode/field.h"
#include "lib/metacode/type.h"
#include "lib/metacode/typeregistry.h"
#include "class.h"
#include "field.h"
#include "type.h"
#include "typeregistry.h"
using namespace QJsonIntrospect;
......
#ifndef QJSONINTROSPECT_METHOD_H
#define QJSONINTROSPECT_METHOD_H
#include "lib/metacode/classmember.h"
#include "classmember.h"
#include <QtCore/QFlags>
......
......@@ -17,7 +17,7 @@
*
*/
#include "lib/metacode/notification.h"
#include "notification.h"
using namespace QJsonIntrospect;
......
......@@ -20,7 +20,7 @@
#ifndef QJSONINTROSPECT_NOTIFICATION_H
#define QJSONINTROSPECT_NOTIFICATION_H
#include "lib/metacode/method.h"
#include "method.h"
namespace QJsonIntrospect {
......
......@@ -17,10 +17,10 @@
*/
#include "lib/metacode/property.h"
#include "property.h"
#include "lib/metacode/method.h"
#include "lib/metacode/type.h"
#include "method.h"
#include "type.h"
using namespace QJsonIntrospect;
......
......@@ -20,7 +20,7 @@
#ifndef QJSONINTROSPECT_PROPERTY_H
#define QJSONINTROSPECT_PROPERTY_H
#include "lib/metacode/field.h"
#include "field.h"
namespace QJsonIntrospect {
......
......@@ -20,7 +20,7 @@
#ifndef QJSONINTROSPECT_RPCMETHOD_H
#define QJSONINTROSPECT_RPCMETHOD_H
#include "lib/metacode/method.h"
#include "method.h"
namespace QJsonIntrospect {
......
......@@ -17,12 +17,12 @@
*/
#include "lib/metacode/type.h"
#include "type.h"
#include <QtDebug>
#include <QtCore/QQueue>
#include "lib/metacode/typeregistry.h"
#include "typeregistry.h"
using namespace QJsonIntrospect;
......
......@@ -24,8 +24,8 @@
#include <QtCore/QMetaType>
#include <grantlee/metatype.h>
#include "lib/metacode/grantlee_enum.h"
#include "lib/metacode/typereference.h"
#include "grantlee_enum.h"
#include "typereference.h"
namespace QJsonIntrospect {
......
......@@ -17,11 +17,11 @@
*/
#include "lib/metacode/typereference.h"
#include "typereference.h"
#include <QtDebug>
#include "lib/metacode/type.h"
#include "type.h"
using namespace QJsonIntrospect;
......
......@@ -17,15 +17,15 @@
*
*/
#include "lib/metacode/typeregistry.h"
#include "typeregistry.h"