Skip to content

Commit 8fc26e2

Browse files
committed
Merge pull request #103 from christiankerl/generate_macro_header
generate header file with platform and build configuration macros
2 parents 2cecec0 + 7abff4e commit 8fc26e2

19 files changed

+100
-69
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# generated config file
2+
examples/protonect/include/libfreenect2/config.h
3+
14
# generated resource file
25
examples/protonect/src/resources.inc
36

examples/protonect/CMakeLists.txt

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ LIST(APPEND RESOURCES
133133
)
134134

135135
IF(ENABLE_OPENCL AND OPENCL_FOUND)
136-
ADD_DEFINITIONS(-DWITH_OPENCL_SUPPORT)
136+
SET(LIBFREENECT2_WITH_OPENCL_SUPPORT 1)
137137
INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIRS})
138138

139139
LIST(APPEND SOURCES
@@ -149,6 +149,8 @@ IF(ENABLE_OPENCL AND OPENCL_FOUND)
149149
)
150150
ENDIF(ENABLE_OPENCL AND OPENCL_FOUND)
151151

152+
CONFIGURE_FILE("${MY_DIR}/include/libfreenect2/config.h.in" "${MY_DIR}/include/libfreenect2/config.h" @ONLY)
153+
152154
GENERATE_RESOURCES(${RESOURCES_INC_FILE} ${MY_DIR} ${RESOURCES})
153155

154156
INCLUDE_DIRECTORIES("${MY_DIR}/include")
@@ -173,17 +175,12 @@ TARGET_LINK_LIBRARIES(Protonect
173175
freenect2
174176
)
175177

176-
CONFIGURE_FILE(freenect2.cmake.in
177-
"${PROJECT_BINARY_DIR}/freenect2Config.cmake" @ONLY)
178-
179-
INSTALL(TARGETS
180-
freenect2 DESTINATION lib)
181-
INSTALL(DIRECTORY
182-
"${MY_DIR}/include/" DESTINATION include)
183-
IF("${LIBFREENECT2_THREADING}" MATCHES "tinythread")
184-
INSTALL(FILES
185-
"${MY_DIR}/src/tinythread/tinythread.h" DESTINATION include/${PROJECT_NAME}/tinythread/)
186-
ENDIF("${LIBFREENECT2_THREADING}" MATCHES "tinythread")
187-
INSTALL(FILES
188-
"${PROJECT_BINARY_DIR}/freenect2Config.cmake" DESTINATION lib/cmake/freenect2/)
178+
CONFIGURE_FILE(freenect2.cmake.in "${PROJECT_BINARY_DIR}/freenect2Config.cmake" @ONLY)
179+
180+
INSTALL(TARGETS freenect2 DESTINATION lib)
181+
INSTALL(DIRECTORY "${MY_DIR}/include/" DESTINATION include PATTERN "*.in" EXCLUDE)
182+
IF(LIBFREENECT2_THREADING_TINYTHREAD)
183+
INSTALL(FILES "${MY_DIR}/src/tinythread/tinythread.h" DESTINATION include/${PROJECT_NAME}/tinythread/)
184+
ENDIF(LIBFREENECT2_THREADING_TINYTHREAD)
185+
INSTALL(FILES "${PROJECT_BINARY_DIR}/freenect2Config.cmake" DESTINATION lib/cmake/freenect2/)
189186

examples/protonect/cmake_modules/SetupLibfreenect2Threading.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ IF(LIBFREENECT2_THREADING_STDLIB)
2424
SET(LIBFREENECT2_THREADING_INCLUDE_DIR "")
2525
SET(LIBFREENECT2_THREADING_SOURCE "")
2626
SET(LIBFREENECT2_THREADING_LIBRARIES "")
27-
ADD_DEFINITIONS(-DLIBFREENECT2_THREADING_STDLIB)
27+
SET(LIBFREENECT2_THREADING_STDLIB 1)
2828
ELSE(LIBFREENECT2_THREADING_STDLIB)
2929
SET(LIBFREENECT2_THREADING "tinythread")
3030
SET(LIBFREENECT2_THREADING_INCLUDE_DIR "src/tinythread/")
@@ -34,7 +34,7 @@ ELSE(LIBFREENECT2_THREADING_STDLIB)
3434
ELSE(NOT WIN32)
3535
SET(LIBFREENECT2_THREADING_LIBRARIES "")
3636
ENDIF(NOT WIN32)
37-
ADD_DEFINITIONS(-DLIBFREENECT2_THREADING_TINYTHREAD)
37+
SET(LIBFREENECT2_THREADING_TINYTHREAD 1)
3838
ENDIF(LIBFREENECT2_THREADING_STDLIB)
3939

4040
MESSAGE(STATUS "using ${LIBFREENECT2_THREADING} as threading library")

examples/protonect/include/libfreenect2/common.h renamed to examples/protonect/include/libfreenect2/config.h.in

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,25 @@
2424
* either License.
2525
*/
2626

27-
#ifndef COMMON_H
28-
#define COMMON_H
27+
#ifndef LIBFREENECT2_CONFIG_H
28+
#define LIBFREENECT2_CONFIG_H
2929

3030
#ifdef _MSC_VER
31-
#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
31+
#define LIBFREENECT2_PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
3232
#else
33-
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
33+
#define LIBFREENECT2_PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
3434
#endif
3535

36-
#endif // COMMON_H
36+
#ifdef _WIN32
37+
#define LIBFREENECT2_API __declspec(dllexport)
38+
#else
39+
#define LIBFREENECT2_API
40+
#endif
41+
42+
#cmakedefine LIBFREENECT2_WITH_OPENCL_SUPPORT
43+
44+
#cmakedefine LIBFREENECT2_THREADING_STDLIB
45+
46+
#cmakedefine LIBFREENECT2_THREADING_TINYTHREAD
47+
48+
#endif // LIBFREENECT2_CONFIG_H

examples/protonect/include/libfreenect2/data_callback.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@
2929
#define DATA_CALLBACK_H_
3030

3131
#include <stddef.h>
32+
#include <libfreenect2/config.h>
3233

3334
namespace libfreenect2
3435
{
3536

36-
class DataCallback
37+
class LIBFREENECT2_API DataCallback
3738
{
3839
public:
3940
virtual void onDataReceived(unsigned char *buffer, size_t n) = 0;

examples/protonect/include/libfreenect2/depth_packet_processor.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,28 @@
3030
#include <stddef.h>
3131
#include <stdint.h>
3232

33+
#include <libfreenect2/config.h>
3334
#include <libfreenect2/frame_listener.hpp>
3435
#include <libfreenect2/packet_processor.h>
3536

3637
namespace libfreenect2
3738
{
3839

39-
struct DepthPacket
40+
struct LIBFREENECT2_API DepthPacket
4041
{
4142
uint32_t sequence;
4243
unsigned char *buffer;
4344
size_t buffer_length;
4445
};
4546

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

48-
class DepthPacketProcessor : public BaseDepthPacketProcessor
51+
class LIBFREENECT2_API DepthPacketProcessor : public BaseDepthPacketProcessor
4952
{
5053
public:
51-
struct Config
54+
struct LIBFREENECT2_API Config
5255
{
5356
float MinDepth;
5457
float MaxDepth;
@@ -59,7 +62,7 @@ class DepthPacketProcessor : public BaseDepthPacketProcessor
5962
Config();
6063
};
6164

62-
struct Parameters
65+
struct LIBFREENECT2_API Parameters
6366
{
6467
float ab_multiplier;
6568
float ab_multiplier_per_frq[3];
@@ -109,7 +112,7 @@ class DepthPacketProcessor : public BaseDepthPacketProcessor
109112

110113
class OpenGLDepthPacketProcessorImpl;
111114

112-
class OpenGLDepthPacketProcessor : public DepthPacketProcessor
115+
class LIBFREENECT2_API OpenGLDepthPacketProcessor : public DepthPacketProcessor
113116
{
114117
public:
115118
OpenGLDepthPacketProcessor(void *parent_opengl_context_ptr, bool debug);
@@ -139,7 +142,7 @@ class OpenGLDepthPacketProcessor : public DepthPacketProcessor
139142
// use pimpl to hide opencv dependency
140143
class CpuDepthPacketProcessorImpl;
141144

142-
class CpuDepthPacketProcessor : public DepthPacketProcessor
145+
class LIBFREENECT2_API CpuDepthPacketProcessor : public DepthPacketProcessor
143146
{
144147
public:
145148
CpuDepthPacketProcessor();
@@ -165,10 +168,10 @@ class CpuDepthPacketProcessor : public DepthPacketProcessor
165168
CpuDepthPacketProcessorImpl *impl_;
166169
};
167170

168-
#ifdef WITH_OPENCL_SUPPORT
171+
#ifdef LIBFREENECT2_WITH_OPENCL_SUPPORT
169172
class OpenCLDepthPacketProcessorImpl;
170173

171-
class OpenCLDepthPacketProcessor : public DepthPacketProcessor
174+
class LIBFREENECT2_API OpenCLDepthPacketProcessor : public DepthPacketProcessor
172175
{
173176
public:
174177
OpenCLDepthPacketProcessor(const int deviceId = -1);
@@ -191,6 +194,6 @@ class OpenCLDepthPacketProcessor : public DepthPacketProcessor
191194
private:
192195
OpenCLDepthPacketProcessorImpl *impl_;
193196
};
194-
#endif // WITH_OPENCL_SUPPORT
197+
#endif // LIBFREENECT2_WITH_OPENCL_SUPPORT
195198
} /* namespace libfreenect2 */
196199
#endif /* DEPTH_PACKET_PROCESSOR_H_ */

examples/protonect/include/libfreenect2/depth_packet_stream_parser.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030
#include <stddef.h>
3131
#include <stdint.h>
3232

33+
#include <libfreenect2/config.h>
34+
3335
#include <libfreenect2/double_buffer.h>
3436
#include <libfreenect2/depth_packet_processor.h>
3537

3638
#include <libfreenect2/data_callback.h>
3739

38-
#include <libfreenect2/common.h>
39-
4040
namespace libfreenect2
4141
{
4242

43-
PACK(struct DepthSubPacketFooter
43+
LIBFREENECT2_PACK(struct LIBFREENECT2_API DepthSubPacketFooter
4444
{
4545
uint32_t magic0;
4646
uint32_t magic1;
@@ -51,7 +51,7 @@ PACK(struct DepthSubPacketFooter
5151
uint32_t fields[32];
5252
});
5353

54-
class DepthPacketStreamParser : public DataCallback
54+
class LIBFREENECT2_API DepthPacketStreamParser : public DataCallback
5555
{
5656
public:
5757
DepthPacketStreamParser();

examples/protonect/include/libfreenect2/double_buffer.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,20 @@
2828
#define DOUBLE_BUFFER_H_
2929

3030
#include <stddef.h>
31+
#include <libfreenect2/config.h>
3132

3233
namespace libfreenect2
3334
{
3435

35-
struct Buffer
36+
struct LIBFREENECT2_API Buffer
3637
{
3738
public:
3839
size_t capacity;
3940
size_t length;
4041
unsigned char* data;
4142
};
4243

43-
class DoubleBuffer
44+
class LIBFREENECT2_API DoubleBuffer
4445
{
4546
public:
4647
DoubleBuffer();

examples/protonect/include/libfreenect2/frame_listener.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@
2828
#define FRAME_LISTENER_HPP_
2929

3030
#include <cstddef>
31+
#include <libfreenect2/config.h>
3132

3233
namespace libfreenect2
3334
{
3435

35-
struct Frame
36+
struct LIBFREENECT2_API Frame
3637
{
3738
enum Type
3839
{
@@ -58,7 +59,7 @@ struct Frame
5859
}
5960
};
6061

61-
class FrameListener
62+
class LIBFREENECT2_API FrameListener
6263
{
6364
public:
6465
virtual ~FrameListener();

examples/protonect/include/libfreenect2/frame_listener_impl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#define FRAME_LISTENER_IMPL_H_
2929

3030
#include <map>
31+
32+
#include <libfreenect2/config.h>
3133
#include <libfreenect2/frame_listener.hpp>
3234

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

3840
class SyncMultiFrameListenerImpl;
3941

40-
class SyncMultiFrameListener : public FrameListener
42+
class LIBFREENECT2_API SyncMultiFrameListener : public FrameListener
4143
{
4244
public:
4345
SyncMultiFrameListener(unsigned int frame_types);

0 commit comments

Comments
 (0)