Skip to content

Commit a124567

Browse files
committed
Fix libfreenect2 build paths
Remove Protonect definitions from the main CMakeLists.txt to `examples` directory. Fix *.bin paths. A few line-end whitespace deletions.
1 parent 9093bd2 commit a124567

5 files changed

+30
-49
lines changed

CMakeLists.txt

+13-34
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ ENDIF()
1414
PROJECT(libfreenect2)
1515

1616
SET(MY_DIR ${libfreenect2_SOURCE_DIR})
17-
SET(DEPENDS_DIR "${MY_DIR}/../../depends" CACHE STRING "dependency directory must be set to 'false' if external deps are used")
17+
SET(DEPENDS_DIR "${MY_DIR}/depends" CACHE STRING "dependency directory must be set to 'false' if external deps are used")
1818

1919
OPTION(BUILD_SHARED_LIBS "Build shared (ON) or static (OFF) libraries" ON)
2020
OPTION(ENABLE_CXX11 "Enable C++11 support" OFF)
@@ -44,10 +44,10 @@ INCLUDE(SetupLibfreenect2Threading)
4444
INCLUDE(GenerateResources)
4545

4646
#set the default path for built executables to the "bin" directory
47-
SET(EXECUTABLE_OUTPUT_PATH ${MY_DIR}/bin)
47+
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
4848

4949
#set the default path for built libraries to the "lib" directory
50-
SET(LIBRARY_OUTPUT_PATH ${MY_DIR}/lib)
50+
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
5151

5252
# dependencies
5353
FIND_PACKAGE(PkgConfig) # try find PKGConfig as it will be used if found
@@ -71,7 +71,7 @@ SET(SOURCES
7171
include/libfreenect2/protocol/command_transaction.h
7272
include/libfreenect2/protocol/response.h
7373
include/libfreenect2/protocol/usb_control.h
74-
74+
7575
include/libfreenect2/usb/event_loop.h
7676
include/libfreenect2/usb/transfer_pool.h
7777

@@ -93,7 +93,7 @@ SET(SOURCES
9393
include/libfreenect2/rgb_packet_processor.h
9494
include/libfreenect2/rgb_packet_stream_parser.h
9595
include/libfreenect2/threading.h
96-
96+
9797
src/transfer_pool.cpp
9898
src/event_loop.cpp
9999
src/usb_control.cpp
@@ -111,7 +111,7 @@ SET(SOURCES
111111
src/registration.cpp
112112
src/logging.cpp
113113
src/libfreenect2.cpp
114-
114+
115115
${LIBFREENECT2_THREADING_SOURCE}
116116
${RESOURCES_INC_FILE}
117117
)
@@ -123,9 +123,9 @@ SET(LIBRARIES
123123
)
124124

125125
SET(RESOURCES
126-
11to16.bin
127-
xTable.bin
128-
zTable.bin
126+
data/11to16.bin
127+
data/xTable.bin
128+
data/zTable.bin
129129
)
130130

131131
IF(ENABLE_OPENGL)
@@ -144,7 +144,7 @@ IF(ENABLE_OPENGL)
144144
src/flextGL.c
145145
src/opengl_depth_packet_processor.cpp
146146
)
147-
147+
148148
LIST(APPEND RESOURCES
149149
src/shader/debug.fs
150150
src/shader/default.vs
@@ -159,18 +159,18 @@ ENDIF(ENABLE_OPENGL)
159159
IF(ENABLE_OPENCL)
160160
FIND_PACKAGE(OpenCL)
161161

162-
IF(OPENCL_FOUND)
162+
IF(OPENCL_FOUND)
163163
SET(LIBFREENECT2_WITH_OPENCL_SUPPORT 1)
164164
INCLUDE_DIRECTORIES(${OPENCL_INCLUDE_DIRS})
165-
165+
166166
LIST(APPEND SOURCES
167167
src/opencl_depth_packet_processor.cpp
168168
)
169169

170170
LIST(APPEND LIBRARIES
171171
${OPENCL_LIBRARIES}
172172
)
173-
173+
174174
LIST(APPEND RESOURCES
175175
src/opencl_depth_packet_processor.cl
176176
)
@@ -213,27 +213,6 @@ IF(MSVC AND NOT BUILD_SHARED_LIBS)
213213
ENDIF()
214214
MESSAGE(STATUS "Linking with these libraries: ${LIBRARIES}")
215215
TARGET_LINK_LIBRARIES(freenect2 ${LIBRARIES})
216-
217-
SET(Protonect_src
218-
Protonect.cpp
219-
)
220-
221-
IF (ENABLE_OPENGL AND OPENGL_FOUND)
222-
LIST(APPEND Protonect_src
223-
viewer.h
224-
viewer.cpp
225-
src/flextGL.c
226-
)
227-
ENDIF()
228-
229-
ADD_EXECUTABLE(Protonect
230-
${Protonect_src}
231-
232-
)
233-
234-
TARGET_LINK_LIBRARIES(Protonect
235-
freenect2
236-
)
237216

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

cmake_modules/GenerateResources.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FUNCTION(GENERATE_RESOURCES OUTPUT BASE_FOLDER)
22

33
ADD_EXECUTABLE(generate_resources_tool
4-
src/generate_resources.cpp
4+
tools/generate_resources.cpp
55
)
66

77
ADD_CUSTOM_COMMAND(

src/opencl_depth_packet_processor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ class OpenCLDepthPacketProcessorImpl: public WithPerfLogging
532532

533533
bool readProgram(std::string &source) const
534534
{
535-
source = loadCLSource("src/opencl_depth_packet_processor.cl");
535+
source = loadCLSource("opencl_depth_packet_processor.cl");
536536
return !source.empty();
537537
}
538538

src/opengl_depth_packet_processor.cpp

+10-12
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ struct Texture : public WithOpenGLBindings
400400
struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPerfLogging
401401
{
402402
GLFWwindow *opengl_context_ptr;
403-
std::string shader_folder;
404403
libfreenect2::DepthPacketProcessor::Config config;
405404

406405
GLuint square_vbo, square_vao, stage1_framebuffer, filter1_framebuffer, stage2_framebuffer, filter2_framebuffer;
@@ -441,7 +440,6 @@ struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPe
441440

442441
OpenGLDepthPacketProcessorImpl(GLFWwindow *new_opengl_context_ptr, bool debug) :
443442
opengl_context_ptr(new_opengl_context_ptr),
444-
shader_folder("src/shader/"),
445443
square_vao(0),
446444
square_vbo(0),
447445
stage1_framebuffer(0),
@@ -556,40 +554,40 @@ struct OpenGLDepthPacketProcessorImpl : public WithOpenGLBindings, public WithPe
556554
if(do_debug) filter2_debug.allocate(512, 424);
557555
filter2_depth.allocate(512, 424);
558556

559-
stage1.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
560-
stage1.setFragmentShader(loadShaderSource(shader_folder + "stage1.fs"));
557+
stage1.setVertexShader(loadShaderSource("default.vs"));
558+
stage1.setFragmentShader(loadShaderSource("stage1.fs"));
561559
stage1.bindFragDataLocation("Debug", 0);
562560
stage1.bindFragDataLocation("A", 1);
563561
stage1.bindFragDataLocation("B", 2);
564562
stage1.bindFragDataLocation("Norm", 3);
565563
stage1.bindFragDataLocation("Infrared", 4);
566564
stage1.build();
567565

568-
filter1.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
569-
filter1.setFragmentShader(loadShaderSource(shader_folder + "filter1.fs"));
566+
filter1.setVertexShader(loadShaderSource("default.vs"));
567+
filter1.setFragmentShader(loadShaderSource("filter1.fs"));
570568
filter1.bindFragDataLocation("Debug", 0);
571569
filter1.bindFragDataLocation("FilterA", 1);
572570
filter1.bindFragDataLocation("FilterB", 2);
573571
filter1.bindFragDataLocation("MaxEdgeTest", 3);
574572
filter1.build();
575573

576-
stage2.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
577-
stage2.setFragmentShader(loadShaderSource(shader_folder + "stage2.fs"));
574+
stage2.setVertexShader(loadShaderSource("default.vs"));
575+
stage2.setFragmentShader(loadShaderSource("stage2.fs"));
578576
stage2.bindFragDataLocation("Debug", 0);
579577
stage2.bindFragDataLocation("Depth", 1);
580578
stage2.bindFragDataLocation("DepthAndIrSum", 2);
581579
stage2.build();
582580

583-
filter2.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
584-
filter2.setFragmentShader(loadShaderSource(shader_folder + "filter2.fs"));
581+
filter2.setVertexShader(loadShaderSource("default.vs"));
582+
filter2.setFragmentShader(loadShaderSource("filter2.fs"));
585583
filter2.bindFragDataLocation("Debug", 0);
586584
filter2.bindFragDataLocation("FilterDepth", 1);
587585
filter2.build();
588586

589587
if(do_debug)
590588
{
591-
debug.setVertexShader(loadShaderSource(shader_folder + "default.vs"));
592-
debug.setFragmentShader(loadShaderSource(shader_folder + "debug.fs"));
589+
debug.setVertexShader(loadShaderSource("default.vs"));
590+
debug.setFragmentShader(loadShaderSource("debug.fs"));
593591
debug.bindFragDataLocation("Debug", 0);
594592
debug.build();
595593
}

tools/generate_resources.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ int main(int argc, char **argv)
8383

8484
for(int i = 2; i < argc; ++i)
8585
{
86-
cout << " { \"" << argv[i] << "\", resource" << (i - 2) << ", " << "sizeof(resource" << (i - 2) << ") }," << endl;
86+
string path(argv[i]);
87+
size_t last_slash = path.find_last_of("\\/");
88+
if (last_slash != std::string::npos)
89+
path.erase(0, last_slash + 1);
90+
cout << " { \"" << path << "\", resource" << (i - 2) << ", " << "sizeof(resource" << (i - 2) << ") }," << endl;
8791
}
8892

8993
cout << "};" << endl;

0 commit comments

Comments
 (0)