Skip to content

Commit

Permalink
First demo
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Feb 26, 2018
1 parent 132c4e7 commit 5763b17
Show file tree
Hide file tree
Showing 62 changed files with 5,259 additions and 1,136 deletions.
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,18 @@
# CopyPolicy: Released under the terms of the GNU GPL v2.0.

cmake_minimum_required(VERSION 3.3)
project(WB-Toolbox)
project(WB-Toolbox LANGUAGES CXX VERSION 3.1)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Add custom functions / macros
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

find_package(YCM REQUIRED)
include(YCMDefaultDirs)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(WB-TOOLBOX_SHARE_DIR "${CMAKE_INSTALL_PREFIX}/share/WB-Toolbox")

add_subdirectory(MxAnyType)
add_subdirectory(toolbox)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/images DESTINATION ${WB-TOOLBOX_SHARE_DIR})

include(AddUninstallTarget)
58 changes: 39 additions & 19 deletions MxAnyType/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_policy(SET CMP0048 NEW)
project(MxAnyType LANGUAGES CXX VERSION 0.1)
# set (PROJECT_VERSION 0.1) # TODO
cmake_minimum_required(VERSION 3.0.2)

# Configure the project
Expand All @@ -10,42 +11,61 @@ include(GNUInstallDirs)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

# Use a general prefix for the project
set(VARS_PREFIX ${PROJECT_NAME})
# set(VARS_PREFIX "MxAnyType")
# set(VARS_PREFIX ${PROJECT_NAME})
set(VARS_PREFIX "MxAnyType")

# TODO: when exporting this folder to a new repository, this will become
# a new project. Uncomment the project line and the alternative
# VARS_PREFIX.

# Build the library
# =================

# Export the includes needed to who inherits this library
# Set this up properly for handling either BUILD and INSTALL trees
set(${VARS_PREFIX}_INCLUDE_BUILD ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(${VARS_PREFIX}_INCLUDE_INSTALL ${CMAKE_INSTALL_INCLUDEDIR}/${VARS_PREFIX})

# Add the target
add_library(${VARS_PREFIX} STATIC ${CMAKE_CURRENT_SOURCE_DIR}/include/AnyType.h
add_library(${VARS_PREFIX} SHARED ${CMAKE_CURRENT_SOURCE_DIR}/include/AnyType.h
${CMAKE_CURRENT_SOURCE_DIR}/include/MxAnyType.h
${CMAKE_CURRENT_SOURCE_DIR}/src/MxAnyType.cpp)

set_target_properties(${VARS_PREFIX} PROPERTIES
VERSION ${PROJECT_VERSION} # This is for the symlink of the .so
PUBLIC_HEADER "include/AnyType.h;include/MxAnyType.h"
)

# TODO: temporary, waiting the library becomes a shared
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set_target_properties(${VARS_PREFIX} PROPERTIES COMPILE_FLAGS "-fPIC")
endif()
# if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
# set_target_properties(${VARS_PREFIX} PROPERTIES COMPILE_FLAGS "-fPIC")
# endif()

# Find Matlab resources
find_package(Matlab REQUIRED MX_LIBRARY)
target_include_directories(${VARS_PREFIX} SYSTEM PUBLIC "${Matlab_INCLUDE_DIRS}")
target_include_directories(${VARS_PREFIX} SYSTEM PUBLIC ${Matlab_INCLUDE_DIRS})

# Setup the include directories
# TODO why in the how to was INTERFACE?
target_include_directories(${VARS_PREFIX} PUBLIC
$<BUILD_INTERFACE:${${VARS_PREFIX}_INCLUDE_BUILD}>
$<INSTALL_INTERFACE:${${VARS_PREFIX}_INCLUDE_INSTALL}>)

# Assign some useful properties
# set_target_properties(${VARS_PREFIX} PROPERTIES VERSION ${PROJECT_VERSION}
# PUBLIC_HEADER MxAnyType.h)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${VARS_PREFIX}>)

# Build tests
# ===========

# add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)

# Install
# =======

install(TARGETS MxAnyType
#EXPORT WBToolboxSimulinkCoder
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${VARS_PREFIX}
)

# TODO: when splitting this library from the toolbox, this will provide find_package support
# include(InstallBasicPackageFiles)
# install_basic_package_files(WBToolboxSimulinkCoder
# VERSION ${PROJECT_VERSION}
# COMPATIBILITY AnyNewerVersion
# TARGETS_PROPERTY MxAnyType
# NO_CHECK_REQUIRED_COMPONENTS_MACRO
# )
7 changes: 3 additions & 4 deletions MxAnyType/include/AnyType.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef ANYTYPE_H
#define ANYTYPE_H

#include <vector>
#include <unordered_map>
#include <memory>
#include <unordered_map>
#include <vector>

class AnyType;

Expand All @@ -14,13 +14,12 @@ typedef std::unordered_map<std::string, AnyTypeSPtr> AnyStruct;
class AnyType
{
protected:

public:
AnyType() = default;
virtual ~AnyType() = default;

// Integers
virtual bool asInt(int& i) = 0;
virtual bool asInt(int& i) = 0;
// virtual bool asInt8(int8_t& i) = 0;
// virtual bool asInt16(int16_t& i) = 0;
virtual bool asInt32(int32_t& i) = 0;
Expand Down
12 changes: 7 additions & 5 deletions MxAnyType/include/MxAnyType.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#ifndef MXANYTYPE_H
#define MXANYTYPE_H

#include <vector>
#include "AnyType.h"

#include <cassert>
#include <matrix.h>
#include <string>
#include <unordered_map>
#include <cassert>
#include "AnyType.h"
#include "matrix.h"
#include <vector>

class MxAnyType;

// If needed in the future
// class MxAnyCell : public AnyCell {};
// class MxAnyStruct : public AnyStruct {};

struct MxArrayMetadata {
struct MxArrayMetadata
{
mxClassID id;
bool isScalar;
size_t rows;
Expand Down
Loading

0 comments on commit 5763b17

Please sign in to comment.