Skip to content

generate header file with platform and build configuration macros #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# generated config file
examples/protonect/include/libfreenect2/config.h

# generated resource file
examples/protonect/src/resources.inc

Expand Down
25 changes: 11 additions & 14 deletions examples/protonect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ LIST(APPEND RESOURCES
)

IF(ENABLE_OPENCL AND OPENCL_FOUND)
ADD_DEFINITIONS(-DWITH_OPENCL_SUPPORT)
SET(LIBFREENECT2_WITH_OPENCL_SUPPORT 1)
INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIRS})

LIST(APPEND SOURCES
Expand All @@ -149,6 +149,8 @@ IF(ENABLE_OPENCL AND OPENCL_FOUND)
)
ENDIF(ENABLE_OPENCL AND OPENCL_FOUND)

CONFIGURE_FILE("${MY_DIR}/include/libfreenect2/config.h.in" "${MY_DIR}/include/libfreenect2/config.h" @ONLY)

GENERATE_RESOURCES(${RESOURCES_INC_FILE} ${MY_DIR} ${RESOURCES})

INCLUDE_DIRECTORIES("${MY_DIR}/include")
Expand All @@ -173,17 +175,12 @@ TARGET_LINK_LIBRARIES(Protonect
freenect2
)

CONFIGURE_FILE(freenect2.cmake.in
"${PROJECT_BINARY_DIR}/freenect2Config.cmake" @ONLY)

INSTALL(TARGETS
freenect2 DESTINATION lib)
INSTALL(DIRECTORY
"${MY_DIR}/include/" DESTINATION include)
IF("${LIBFREENECT2_THREADING}" MATCHES "tinythread")
INSTALL(FILES
"${MY_DIR}/src/tinythread/tinythread.h" DESTINATION include/${PROJECT_NAME}/tinythread/)
ENDIF("${LIBFREENECT2_THREADING}" MATCHES "tinythread")
INSTALL(FILES
"${PROJECT_BINARY_DIR}/freenect2Config.cmake" DESTINATION lib/cmake/freenect2/)
CONFIGURE_FILE(freenect2.cmake.in "${PROJECT_BINARY_DIR}/freenect2Config.cmake" @ONLY)

INSTALL(TARGETS freenect2 DESTINATION lib)
INSTALL(DIRECTORY "${MY_DIR}/include/" DESTINATION include PATTERN "*.in" EXCLUDE)
IF(LIBFREENECT2_THREADING_TINYTHREAD)
INSTALL(FILES "${MY_DIR}/src/tinythread/tinythread.h" DESTINATION include/${PROJECT_NAME}/tinythread/)
ENDIF(LIBFREENECT2_THREADING_TINYTHREAD)
INSTALL(FILES "${PROJECT_BINARY_DIR}/freenect2Config.cmake" DESTINATION lib/cmake/freenect2/)

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ IF(LIBFREENECT2_THREADING_STDLIB)
SET(LIBFREENECT2_THREADING_INCLUDE_DIR "")
SET(LIBFREENECT2_THREADING_SOURCE "")
SET(LIBFREENECT2_THREADING_LIBRARIES "")
ADD_DEFINITIONS(-DLIBFREENECT2_THREADING_STDLIB)
SET(LIBFREENECT2_THREADING_STDLIB 1)
ELSE(LIBFREENECT2_THREADING_STDLIB)
SET(LIBFREENECT2_THREADING "tinythread")
SET(LIBFREENECT2_THREADING_INCLUDE_DIR "src/tinythread/")
Expand All @@ -34,7 +34,7 @@ ELSE(LIBFREENECT2_THREADING_STDLIB)
ELSE(NOT WIN32)
SET(LIBFREENECT2_THREADING_LIBRARIES "")
ENDIF(NOT WIN32)
ADD_DEFINITIONS(-DLIBFREENECT2_THREADING_TINYTHREAD)
SET(LIBFREENECT2_THREADING_TINYTHREAD 1)
ENDIF(LIBFREENECT2_THREADING_STDLIB)

MESSAGE(STATUS "using ${LIBFREENECT2_THREADING} as threading library")
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,25 @@
* either License.
*/

#ifndef COMMON_H
#define COMMON_H
#ifndef LIBFREENECT2_CONFIG_H
#define LIBFREENECT2_CONFIG_H

#ifdef _MSC_VER
#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
#define LIBFREENECT2_PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
#else
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#define LIBFREENECT2_PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
#endif

#endif // COMMON_H
#ifdef _WIN32
#define LIBFREENECT2_API __declspec(dllexport)
#else
#define LIBFREENECT2_API
#endif

#cmakedefine LIBFREENECT2_WITH_OPENCL_SUPPORT

#cmakedefine LIBFREENECT2_THREADING_STDLIB

#cmakedefine LIBFREENECT2_THREADING_TINYTHREAD

#endif // LIBFREENECT2_CONFIG_H
3 changes: 2 additions & 1 deletion examples/protonect/include/libfreenect2/data_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
#define DATA_CALLBACK_H_

#include <stddef.h>
#include <libfreenect2/config.h>

namespace libfreenect2
{

class DataCallback
class LIBFREENECT2_API DataCallback
{
public:
virtual void onDataReceived(unsigned char *buffer, size_t n) = 0;
Expand Down
21 changes: 12 additions & 9 deletions examples/protonect/include/libfreenect2/depth_packet_processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,28 @@
#include <stddef.h>
#include <stdint.h>

#include <libfreenect2/config.h>
#include <libfreenect2/frame_listener.hpp>
#include <libfreenect2/packet_processor.h>

namespace libfreenect2
{

struct DepthPacket
struct LIBFREENECT2_API DepthPacket
{
uint32_t sequence;
unsigned char *buffer;
size_t buffer_length;
};

// explicit instantiation and export to make vsc++ happy
template class LIBFREENECT2_API PacketProcessor<DepthPacket>;
typedef PacketProcessor<DepthPacket> BaseDepthPacketProcessor;

class DepthPacketProcessor : public BaseDepthPacketProcessor
class LIBFREENECT2_API DepthPacketProcessor : public BaseDepthPacketProcessor
{
public:
struct Config
struct LIBFREENECT2_API Config
{
float MinDepth;
float MaxDepth;
Expand All @@ -59,7 +62,7 @@ class DepthPacketProcessor : public BaseDepthPacketProcessor
Config();
};

struct Parameters
struct LIBFREENECT2_API Parameters
{
float ab_multiplier;
float ab_multiplier_per_frq[3];
Expand Down Expand Up @@ -109,7 +112,7 @@ class DepthPacketProcessor : public BaseDepthPacketProcessor

class OpenGLDepthPacketProcessorImpl;

class OpenGLDepthPacketProcessor : public DepthPacketProcessor
class LIBFREENECT2_API OpenGLDepthPacketProcessor : public DepthPacketProcessor
{
public:
OpenGLDepthPacketProcessor(void *parent_opengl_context_ptr, bool debug);
Expand Down Expand Up @@ -139,7 +142,7 @@ class OpenGLDepthPacketProcessor : public DepthPacketProcessor
// use pimpl to hide opencv dependency
class CpuDepthPacketProcessorImpl;

class CpuDepthPacketProcessor : public DepthPacketProcessor
class LIBFREENECT2_API CpuDepthPacketProcessor : public DepthPacketProcessor
{
public:
CpuDepthPacketProcessor();
Expand All @@ -165,10 +168,10 @@ class CpuDepthPacketProcessor : public DepthPacketProcessor
CpuDepthPacketProcessorImpl *impl_;
};

#ifdef WITH_OPENCL_SUPPORT
#ifdef LIBFREENECT2_WITH_OPENCL_SUPPORT
class OpenCLDepthPacketProcessorImpl;

class OpenCLDepthPacketProcessor : public DepthPacketProcessor
class LIBFREENECT2_API OpenCLDepthPacketProcessor : public DepthPacketProcessor
{
public:
OpenCLDepthPacketProcessor();
Expand All @@ -191,6 +194,6 @@ class OpenCLDepthPacketProcessor : public DepthPacketProcessor
private:
OpenCLDepthPacketProcessorImpl *impl_;
};
#endif // WITH_OPENCL_SUPPORT
#endif // LIBFREENECT2_WITH_OPENCL_SUPPORT
} /* namespace libfreenect2 */
#endif /* DEPTH_PACKET_PROCESSOR_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@
#include <stddef.h>
#include <stdint.h>

#include <libfreenect2/config.h>

#include <libfreenect2/double_buffer.h>
#include <libfreenect2/depth_packet_processor.h>

#include <libfreenect2/data_callback.h>

#include <libfreenect2/common.h>

namespace libfreenect2
{

PACK(struct DepthSubPacketFooter
LIBFREENECT2_PACK(struct LIBFREENECT2_API DepthSubPacketFooter
{
uint32_t magic0;
uint32_t magic1;
Expand All @@ -51,7 +51,7 @@ PACK(struct DepthSubPacketFooter
uint32_t fields[32];
});

class DepthPacketStreamParser : public DataCallback
class LIBFREENECT2_API DepthPacketStreamParser : public DataCallback
{
public:
DepthPacketStreamParser();
Expand Down
5 changes: 3 additions & 2 deletions examples/protonect/include/libfreenect2/double_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,20 @@
#define DOUBLE_BUFFER_H_

#include <stddef.h>
#include <libfreenect2/config.h>

namespace libfreenect2
{

struct Buffer
struct LIBFREENECT2_API Buffer
{
public:
size_t capacity;
size_t length;
unsigned char* data;
};

class DoubleBuffer
class LIBFREENECT2_API DoubleBuffer
{
public:
DoubleBuffer();
Expand Down
5 changes: 3 additions & 2 deletions examples/protonect/include/libfreenect2/frame_listener.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
#define FRAME_LISTENER_HPP_

#include <cstddef>
#include <libfreenect2/config.h>

namespace libfreenect2
{

struct Frame
struct LIBFREENECT2_API Frame
{
enum Type
{
Expand All @@ -58,7 +59,7 @@ struct Frame
}
};

class FrameListener
class LIBFREENECT2_API FrameListener
{
public:
virtual ~FrameListener();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#define FRAME_LISTENER_IMPL_H_

#include <map>

#include <libfreenect2/config.h>
#include <libfreenect2/frame_listener.hpp>

namespace libfreenect2
Expand All @@ -37,7 +39,7 @@ typedef std::map<Frame::Type, Frame*> FrameMap;

class SyncMultiFrameListenerImpl;

class SyncMultiFrameListener : public FrameListener
class LIBFREENECT2_API SyncMultiFrameListener : public FrameListener
{
public:
SyncMultiFrameListener(unsigned int frame_types);
Expand Down
5 changes: 3 additions & 2 deletions examples/protonect/include/libfreenect2/libfreenect2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
#ifndef LIBFREENECT2_HPP_
#define LIBFREENECT2_HPP_

#include <libfreenect2/config.h>
#include <libfreenect2/frame_listener.hpp>

namespace libfreenect2
{

class PacketPipeline;

class Freenect2Device
class LIBFREENECT2_API Freenect2Device
{
public:
static const unsigned int VendorId = 0x045E;
Expand Down Expand Up @@ -70,7 +71,7 @@ class Freenect2Device

class Freenect2Impl;

class Freenect2
class LIBFREENECT2_API Freenect2
{
public:
Freenect2(void *usb_context = 0);
Expand Down
7 changes: 4 additions & 3 deletions examples/protonect/include/libfreenect2/opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@

#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <libfreenect2/config.h>

namespace libfreenect2
{

struct OpenGLContext
struct LIBFREENECT2_API OpenGLContext
{
GLFWwindow *glfw_ctx;
GLEWContext *glew_ctx;
Expand All @@ -48,7 +49,7 @@ struct OpenGLContext
};


struct ChangeCurrentOpenGLContext
struct LIBFREENECT2_API ChangeCurrentOpenGLContext
{
const OpenGLContext *last_ctx;

Expand All @@ -58,6 +59,6 @@ struct ChangeCurrentOpenGLContext

} /* namespace libfreenect2 */

GLEWContext *glewGetContext();
LIBFREENECT2_API GLEWContext *glewGetContext();

#endif /* OPENGL_H_ */
Loading