Skip to content

Commit 01f50d4

Browse files
committed
Clean up FindGLFW3.cmake
1 parent 72eb75a commit 01f50d4

File tree

2 files changed

+48
-34
lines changed

2 files changed

+48
-34
lines changed

examples/protonect/CMakeLists.txt

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ PROJECT(libfreenect2)
1414
SET(CMAKE_BUILD_TYPE RelWithDebInfo)
1515

1616
SET(MY_DIR ${libfreenect2_SOURCE_DIR})
17-
SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${MY_DIR}/../../depends/libusb/lib/pkgconfig/:${MY_DIR}/../../depends/glfw/lib/pkgconfig/" )
17+
SET(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${MY_DIR}/../../depends/libusb/lib/pkgconfig/")
1818

1919
OPTION(ENABLE_CXX11 "Enable C++11 support" OFF)
2020
OPTION(ENABLE_OPENCL "Enable OpenCL support" ON)
@@ -130,34 +130,16 @@ SET(RESOURCES
130130
)
131131

132132
IF(ENABLE_OPENGL)
133-
auto_detect_lib(GLFW3)
134-
135-
#Assuming local build witout global deps, ugly to to this automatic but to keep backward compatibiliy
136-
if(NOT GLFW3_FOUND)
137-
138-
MESSAGE(STATUS "Building local GLFW")
139-
# GLFW
140-
SET(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries")
141-
SET(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "Build the GLFW example programs")
142-
SET(GLFW_BUILD_TESTS OFF CACHE BOOL "Build the GLFW test programs")
143-
SET(GLFW_BUILD_DOCS OFF CACHE BOOL "Build the GLFW documentation")
144-
145-
ADD_SUBDIRECTORY(${MY_DIR}/../../depends/glfw_src/ ${MY_DIR}/../../depends/glfw)
146-
INCLUDE_DIRECTORIES(${MY_DIR}/../../depends/glfw_src/include/)
147-
148-
LIST(APPEND LIBRARIES
149-
glfw
150-
)
151-
152-
else()
133+
FIND_PACKAGE(GLFW3)
134+
FIND_PACKAGE(OpenGL)
135+
IF(GLFW3_FOUND)
153136
INCLUDE_DIRECTORIES(${GLFW3_INCLUDE_DIRS})
154137

155138
LINK_DIRECTORIES(${GLFW3_LIBRARY_DIRS})
156139
LIST(APPEND LIBRARIES
157140
${GLFW3_LIBRARIES}
141+
${OPENGL_gl_LIBRARY}
158142
)
159-
endif()
160-
161143
SET(LIBFREENECT2_WITH_OPENGL_SUPPORT 1)
162144
LIST(APPEND SOURCES
163145
src/flextGL.c
@@ -172,6 +154,7 @@ IF(ENABLE_OPENGL)
172154
src/shader/stage1.fs
173155
src/shader/stage2.fs
174156
)
157+
ENDIF()
175158
ENDIF(ENABLE_OPENGL)
176159

177160
IF(ENABLE_OPENCL)
Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,52 @@
11
# - Try to find GLFW3
22
#
3+
# If no pkgconfig, define GLFW_ROOT to installation tree
34
# Will define the following:
45
# GLFW3_FOUND
56
# GLFW3_INCLUDE_DIRS
67
# GLFW3_LIBRARIES
78

8-
include(FindPackageHandleStandardArgs)
9+
IF(PKG_CONFIG_FOUND)
10+
IF(APPLE)
11+
# homebrew or macports pkgconfig locations
12+
SET(ENV{PKG_CONFIG_PATH} "/usr/local/opt/glfw3/lib/pkgconfig:/opt/local/lib/pkgconfig")
13+
ENDIF()
14+
SET(ENV{PKG_CONFIG_PATH} "${CMAKE_SOURCE_DIR}/../../depends/glfw/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
15+
PKG_CHECK_MODULES(GLFW3 glfw3)
916

10-
IF(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
11-
find_path(GLFW3_INCLUDE_DIRS
12-
glfw/glfw3.h
13-
DOC "GLFW include directory "
14-
PATHS $ENV{ProgramW6432}/glfw/include $ENV{GLFW_ROOT}/include)
15-
16-
find_library(GLFW3_LIBRARIES
17-
NAMES glfw3.lib glfw3dll.lib
18-
PATHS $ENV{ProgramW6432}/glfw/lib/ $ENV{GLFW_ROOT}/lib/)
17+
RETURN()
1918
ENDIF()
2019

21-
find_package_handle_standard_args(GLFW3 "Could not find GLFW3 - try adding GLFW_ROOT in enviroment variables." GLFW3_INCLUDE_DIRS GLFW3_LIBRARIES)
20+
FIND_PATH(GLFW3_INCLUDE_DIRS
21+
GLFW/glfw3.h
22+
DOC "GLFW include directory "
23+
PATHS
24+
"${CMAKE_SOURCE_DIR}/../../depends/glfw"
25+
"$ENV{ProgramW6432}/glfw"
26+
ENV GLFW_ROOT
27+
PATH_SUFFIXES
28+
include
29+
)
30+
31+
# directories in the official binary package
32+
IF(MINGW)
33+
SET(_SUFFIX lib-mingw)
34+
ELSEIF(MSVC11)
35+
SET(_SUFFIX lib-vc2012)
36+
ELSEIF(MSVC)
37+
SET(_SUFFIX lib-vc2013)
38+
ENDIF()
39+
40+
FIND_LIBRARY(GLFW3_LIBRARIES
41+
NAMES glfw3dll glfw3
42+
PATHS
43+
"${CMAKE_SOURCE_DIR}/../../depends/glfw"
44+
"$ENV{ProgramW6432}/glfw"
45+
ENV GLFW_ROOT
46+
PATH_SUFFIXES
47+
lib
48+
${_SUFFIX}
49+
)
50+
51+
INCLUDE(FindPackageHandleStandardArgs)
52+
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLFW3 "Could NOT find GLFW3 - try adding GLFW_ROOT in enviroment variables." GLFW3_LIBRARIES GLFW3_INCLUDE_DIRS)

0 commit comments

Comments
 (0)