Skip to content

Commit

Permalink
Merge pull request #384 from silicon-heaven/cmake-pkg
Browse files Browse the repository at this point in the history
Add proper exports
  • Loading branch information
fvacek authored Nov 27, 2023
2 parents 911293b + a6a3e3a commit e05b757
Show file tree
Hide file tree
Showing 41 changed files with 281 additions and 224 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/necrolog
Submodule necrolog updated 2 files
+14 −4 CMakeLists.txt
+9 −0 necrolog.pc.in
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ if(BUILD_TESTING)
endif()

if (NOT TARGET libnecrolog)
add_subdirectory(3rdparty/necrolog)
if(LIBSHV_USE_LOCAL_NECROLOG)
find_package(necrolog REQUIRED)
else()
add_subdirectory(3rdparty/necrolog)
endif()
endif()

function(check_shv_dep dependent dependent_var dependency dependency_var)
Expand Down
14 changes: 11 additions & 3 deletions libshvbroker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ qt_add_library(libshvbroker
include/shv/broker/clientconnectionnode.h
include/shv/broker/groupmapping.h
)
add_library(libshv::libshvbroker ALIAS libshvbroker)

if(WITH_SHV_WEBSOCKETS)
target_sources(libshvbroker PRIVATE
Expand All @@ -41,12 +42,15 @@ if(OpenLDAP_FOUND)
src/ldap.cpp
src/openldap_dynamic.cpp
)
target_include_directories(libshvbroker PUBLIC "${OpenLDAP_INCLUDE_DIRS}")
target_include_directories(libshvbroker PUBLIC $<BUILD_INTERFACE:${OpenLDAP_INCLUDE_DIRS}>)
target_compile_definitions(libshvbroker PUBLIC WITH_SHV_LDAP)
endif()

target_link_libraries(libshvbroker PUBLIC Qt::Sql libshviotqt)
target_include_directories(libshvbroker PUBLIC include)
target_include_directories(libshvbroker PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(libshvbroker PRIVATE SHVBROKER_BUILD_DLL)

if(BUILD_TESTING)
Expand All @@ -60,4 +64,8 @@ if(BUILD_TESTING)
add_shvbroker_test(aclmanager)
endif()

install(TARGETS libshvbroker)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/shv" TYPE INCLUDE)

install(TARGETS libshvbroker EXPORT libshvConfig)
export(TARGETS libshvbroker NAMESPACE libshv:: FILE "${CMAKE_CURRENT_BINARY_DIR}/libshvConfig.cmake")
install(EXPORT libshvConfig DESTINATION share/libshv/cmake NAMESPACE libshv::)
15 changes: 12 additions & 3 deletions libshvchainpack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ add_library(libshvchainpack-cpp
src/chainpack/utils.cpp
include/shv/chainpack/crc32.h
)
add_library(libshv::libshvchainpack-cpp ALIAS libshvchainpack-cpp)

if (NOT WIN32)
target_sources(libshvchainpack-cpp PRIVATE src/chainpack/socketrpcdriver.cpp)
endif()

target_link_libraries(libshvchainpack-cpp libnecrolog libshvchainpack-c)
target_include_directories(libshvchainpack-cpp PUBLIC include)
target_link_libraries(libshvchainpack-cpp libnecrolog::libnecrolog libshvchainpack-c)
target_include_directories(libshvchainpack-cpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

target_compile_definitions(libshvchainpack-cpp PRIVATE SHVCHAINPACK_BUILD_DLL)

function(add_shv_test test_name)
Expand Down Expand Up @@ -71,4 +76,8 @@ if(BUILD_TESTING)
endif()
endif()

install(TARGETS libshvchainpack-cpp)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/shv" TYPE INCLUDE)

install(TARGETS libshvchainpack-cpp EXPORT libshvConfig)
export(TARGETS libshvchainpack-cpp NAMESPACE libshv:: FILE "${CMAKE_CURRENT_BINARY_DIR}/libshvConfig.cmake")
install(EXPORT libshvConfig DESTINATION share/libshv/cmake NAMESPACE libshv::)
10 changes: 8 additions & 2 deletions libshvchainpack/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ add_library(libshvchainpack-c STATIC
ccpcp_convert.c
ccpon.c
)
target_include_directories(libshvchainpack-c PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(libshvchainpack-c PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

function(add_shv_test test_name)
add_executable(test_${test_name}
Expand All @@ -18,4 +20,8 @@ if(BUILD_TESTING)
add_shv_test(ccpcp)
endif()

install(TARGETS libshvchainpack-c)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/shv" TYPE INCLUDE)

install(TARGETS libshvchainpack-c EXPORT libshvConfig)
export(TARGETS libshvchainpack-c NAMESPACE libshvchainpack-c:: FILE "${CMAKE_CURRENT_BINARY_DIR}/libshvConfig.cmake")
install(EXPORT libshvConfig DESTINATION "share/libshv/cmake" NAMESPACE libshv::)
2 changes: 1 addition & 1 deletion libshvchainpack/c/cchainpack.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cchainpack.h"
#include <shv/chainpack/cchainpack.h>

#include <string.h>
#include <limits.h>
Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/c/ccpcp.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "ccpcp.h"
#include <shv/chainpack/ccpcp.h>

#include <string.h>

Expand Down
4 changes: 2 additions & 2 deletions libshvchainpack/c/ccpcp_convert.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "cchainpack.h"
#include "ccpon.h"
#include <shv/chainpack/cchainpack.h>
#include <shv/chainpack/ccpon.h>

#include <assert.h>

Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/c/ccpon.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "ccpon.h"
#include <shv/chainpack/ccpon.h>

#include <string.h>
#include <math.h>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions libshvchainpack/c/tests/test_ccpcp.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#define _GNU_SOURCE
#include <ccpcp.h>
#include <ccpon.h>
#include <cchainpack.h>
#include <ccpcp_convert.h>
#include <shv/chainpack/ccpcp.h>
#include <shv/chainpack/ccpon.h>
#include <shv/chainpack/cchainpack.h>
#include <shv/chainpack/ccpcp_convert.h>

#include <time.h>
#include <stdio.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <shv/chainpack/rpcvalue.h>
#include "../../../c/ccpcp.h"
#include <shv/chainpack/ccpcp.h>

#include <istream>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include <shv/chainpack/rpcvalue.h>
#include "../../../c/ccpcp.h"
#include <shv/chainpack/ccpcp.h>

#include <ostream>

Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/include/shv/chainpack/chainpack.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "rpcvalue.h"
#include "../../../c/cchainpack.h"
#include <shv/chainpack/cchainpack.h>

namespace shv {
namespace chainpack {
Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/src/chainpack/chainpackreader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <shv/chainpack/chainpackreader.h>
#include <shv/chainpack/utils.h>
#include "../../c/cchainpack.h"
#include <shv/chainpack/cchainpack.h>

#include <iostream>
#include <cmath>
Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/src/chainpack/chainpackwriter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <shv/chainpack/chainpackwriter.h>
#include <shv/chainpack/exception.h>

#include "../../c/cchainpack.h"
#include <shv/chainpack/cchainpack.h>

#include <iostream>
#include <cmath>
Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/src/chainpack/cponreader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <shv/chainpack/cponreader.h>
#include <shv/chainpack/exception.h>
#include "../../c/ccpon.h"
#include <shv/chainpack/ccpon.h>

#include <iostream>
#include <fstream>
Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/src/chainpack/cponwriter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <shv/chainpack/cponwriter.h>
#include <shv/chainpack/exception.h>

#include "../../c/ccpon.h"
#include <shv/chainpack/ccpon.h>

#include <cmath>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion libshvchainpack/src/chainpack/rpcvalue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <shv/chainpack/exception.h>
#include <shv/chainpack/utils.h>

#include "../../c/ccpon.h"
#include <shv/chainpack/ccpon.h>

#include <necrolog.h>

Expand Down
12 changes: 10 additions & 2 deletions libshvcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ add_library(libshvcore
src/utils/shvurl.cpp
src/utils/versioninfo.cpp
)
add_library(libshv::libshvcore ALIAS libshvcore)

target_link_libraries(libshvcore libshvchainpack-cpp)
target_include_directories(libshvcore PUBLIC include)
target_include_directories(libshvcore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(libshvcore PRIVATE SHVCORE_BUILD_DLL)

function(add_shvcore_test test_name)
Expand All @@ -52,4 +56,8 @@ if(BUILD_TESTING)
endif()
endif()

install(TARGETS libshvcore)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/shv" TYPE INCLUDE)

install(TARGETS libshvcore EXPORT libshvConfig)
export(TARGETS libshvcore NAMESPACE libshv:: FILE "${CMAKE_CURRENT_BINARY_DIR}/libshvConfig.cmake")
install(EXPORT libshvConfig DESTINATION share/libshv/cmake NAMESPACE libshv::)
13 changes: 11 additions & 2 deletions libshvcoreqt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ qt_add_library(libshvcoreqt
include/shv/coreqt/utils.h
include/shv/coreqt/exception.h
)
add_library(libshv::libshvcoreqt ALIAS libshvcoreqt)

target_link_libraries(libshvcoreqt PUBLIC Qt::Core libshvcore)
target_include_directories(libshvcoreqt PUBLIC include)
target_include_directories(libshvcoreqt PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(libshvcoreqt PRIVATE SHVCOREQT_BUILD_DLL)

function(add_shvcoreqt_test test_name)
Expand All @@ -34,4 +39,8 @@ if(BUILD_TESTING)
add_shvcoreqt_test(utils)
endif()

install(TARGETS libshvcoreqt)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/shv" TYPE INCLUDE)

install(TARGETS libshvcoreqt EXPORT libshvConfig)
export(TARGETS libshvcoreqt NAMESPACE libshv:: FILE "${CMAKE_CURRENT_BINARY_DIR}/libshvConfig.cmake")
install(EXPORT libshvConfig DESTINATION share/libshv/cmake NAMESPACE libshv::)
13 changes: 11 additions & 2 deletions libshviotqt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ qt_add_library(libshviotqt
include/shv/iotqt/rpc/socketrpcconnection.h
include/shv/iotqt/utils.h
)
add_library(libshv::libshviotqt ALIAS libshviotqt)

target_link_libraries(libshviotqt PUBLIC Qt::Network libshvcoreqt)

if(NOT EMSCRIPTEN)
Expand All @@ -52,7 +54,10 @@ if(NOT EMSCRIPTEN)
)
endif()

target_include_directories(libshviotqt PUBLIC include)
target_include_directories(libshviotqt PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(libshviotqt PRIVATE SHVIOTQT_BUILD_DLL)

if(WITH_SHV_WEBSOCKETS)
Expand Down Expand Up @@ -81,4 +86,8 @@ if(BUILD_TESTING)
set_property(TEST test_iotqt_serialportsocket APPEND PROPERTY ENVIRONMENT "TESTS_DIR=${CMAKE_CURRENT_BINARY_DIR}/test_serialportsocket")
endif()

install(TARGETS libshviotqt)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/shv" TYPE INCLUDE)

install(TARGETS libshviotqt EXPORT libshvConfig)
export(TARGETS libshviotqt NAMESPACE libshv:: FILE "${CMAKE_CURRENT_BINARY_DIR}/libshvConfig.cmake")
install(EXPORT libshvConfig DESTINATION share/libshv/cmake NAMESPACE libshv::)
12 changes: 10 additions & 2 deletions libshvvisu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ add_library(libshvvisu
include/shv/visu/svgscene/groupitem.h
include/shv/visu/errorlogmodel.h
)
add_library(libshv::libshvvisu ALIAS libshvvisu)

target_link_libraries(libshvvisu PUBLIC Qt::Widgets libshviotqt)
target_include_directories(libshvvisu PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(libshvvisu PUBLIC include)
target_include_directories(libshvvisu PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(libshvvisu PRIVATE SHVVISU_BUILD_DLL)

install(TARGETS libshvvisu)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/shv" TYPE INCLUDE)

install(TARGETS libshvvisu EXPORT libshvConfig)
export(TARGETS libshvvisu NAMESPACE libshv:: FILE "${CMAKE_CURRENT_BINARY_DIR}/libshvConfig.cmake")
install(EXPORT libshvConfig DESTINATION share/libshv/cmake NAMESPACE libshv::)
35 changes: 34 additions & 1 deletion libshvvisu/include/shv/visu/errorlogmodel.h
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
#include "../../../src/logwidget/errorlogmodel.h"
#pragma once

#include <shv/visu/logtablemodelbase.h>

#include <shv/visu/shvvisuglobal.h>

#include <necrologlevel.h>

namespace shv {
namespace visu {

class SHVVISU_DECL_EXPORT ErrorLogModel : public LogTableModelBase
{
Q_OBJECT

using Super = LogTableModelBase;
public:
ErrorLogModel(QObject *parent = nullptr);

enum Cols {Level, TimeStamp, Message, UserData, Count};

QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;

QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;

NecroLogLevel level(int row) const;

void addLogRow(NecroLogLevel level, const std::string &msg, const QVariant &user_data = QVariant());

};

}}

45 changes: 44 additions & 1 deletion libshvvisu/include/shv/visu/logtablemodelbase.h
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
#include "../../../src/logwidget/logtablemodelbase.h"
#pragma once

#include <shv/visu/shvvisuglobal.h>

#include <shv/coreqt/utils.h>

#include <QAbstractTableModel>

namespace shv {
namespace visu {

class SHVVISU_DECL_EXPORT LogTableModelRow : public QVector<QVariant>
{
public:
explicit LogTableModelRow(int size = 0);
};

class SHVVISU_DECL_EXPORT LogTableModelBase : public QAbstractTableModel
{
Q_OBJECT
private:
typedef QAbstractTableModel Super;
public:
LogTableModelBase(QObject *parent = nullptr);

enum class Direction {AppendToTop, AppendToBottom};

SHV_PROPERTY_IMPL2(Direction, d, D, irection, Direction::AppendToBottom)
SHV_PROPERTY_IMPL2(int, m, M, aximumRowCount, 1000)

int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;

void clear();
LogTableModelRow rowAt(int row) const;
void addLogRow(const LogTableModelRow &row);
Q_SIGNAL void logRowInserted(int row_no);
protected:
QList<LogTableModelRow> m_rows;
};

}}


Loading

0 comments on commit e05b757

Please sign in to comment.