-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Good GLEW/GLUT search. Sample to show the fonts
I created a simple sample. And I created the cmake stuff to correctly find and compile with GLUT & GLEW. I tried to anticipate many situations where GLEW/GLUT install might lead to a PITA. GLEW_LOCATION and GLUT_LOCATION are welcome to help this sample to run.
- Loading branch information
Showing
17 changed files
with
3,344 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,3 +161,6 @@ pip-log.txt | |
|
||
# Mac crap | ||
.DS_Store | ||
|
||
#specific to the project | ||
cmake_built |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
cmake_minimum_required(VERSION 2.8) | ||
|
||
PROJECT( OpenGLText ) | ||
|
||
# Specify the list of directories to search for cmake modules. | ||
set(CMAKE_MODULE_PATH | ||
${CMAKE_CURRENT_SOURCE_DIR}/cmake | ||
) | ||
|
||
set( CMAKE_PROGRAM_PATH "$ENV{PATH}") | ||
|
||
if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) | ||
set (ARCH "x64" CACHE STRING "CPU Architecture") | ||
else () | ||
set (ARCH "x86" CACHE STRING "CPU Architecture") | ||
endif() | ||
|
||
set(EXECUTABLE_OUTPUT_PATH | ||
${PROJECT_BINARY_DIR}/bin | ||
CACHE PATH | ||
"Directory where executables will be stored" | ||
) | ||
|
||
if(UNIX) | ||
set(OS "linux") | ||
add_definitions(-DLINUX) | ||
else(UNIX) | ||
if(APPLE) | ||
else(APPLE) | ||
if(WIN32) | ||
set(OS "win") | ||
add_definitions(-DNOMINMAX) | ||
endif(WIN32) | ||
endif(APPLE) | ||
endif(UNIX) | ||
|
||
# Macro for adding files close to the executable | ||
macro(_copy_files_to_target target thefiles) | ||
if(WIN32) | ||
foreach (FFF ${thefiles} ) | ||
add_custom_command( | ||
TARGET ${target} POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E copy_if_different | ||
"${PROJECT_SOURCE_DIR}/${FFF}" | ||
$<TARGET_FILE_DIR:${target}> | ||
VERBATIM | ||
) | ||
endforeach() | ||
endif() | ||
|
||
endmacro() | ||
|
||
|
||
find_package(OpenGL) | ||
# ===============> GLUT | ||
find_package(GLUT) | ||
if(NOT GLUT_FOUND) | ||
message(WARNING "Try to set GLUT_LOCATION") | ||
endif() | ||
# ===============> GLEW | ||
if (NOT APPLE) | ||
find_package(GLEW REQUIRED) | ||
endif() | ||
|
||
add_subdirectory(example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# | ||
|
||
# Try to find GLEW library and include path. | ||
# Once done this will define | ||
# | ||
# GLEW_FOUND | ||
# GLEW_INCLUDE_DIR | ||
# GLEW_LIBRARY | ||
# GLEW_SOURCE | ||
# | ||
|
||
include(FindPackageHandleStandardArgs) | ||
|
||
if (WIN32) | ||
find_path( GLEW_INCLUDE_DIR | ||
NAMES | ||
GL/glew.h | ||
PATHS | ||
${GLEW_LOCATION}/include | ||
$ENV{GLEW_LOCATION}/include | ||
$ENV{PROGRAMFILES}/GLEW/include | ||
${PROJECT_SOURCE_DIR}/extern/glew/include | ||
DOC "The directory where GL/glew.h resides" ) | ||
find_file( GLEW_SOURCE | ||
NAMES | ||
glew.c | ||
PATHS | ||
${GLEW_LOCATION}/src | ||
$ENV{GLEW_LOCATION}/src | ||
$ENV{PROGRAMFILES}/GLEW/src | ||
${PROJECT_SOURCE_DIR}/extern/glew/src | ||
DOC "The directory where GL/glew.c resides" ) | ||
if(ARCH STREQUAL "x86") | ||
find_library( GLEW_LIBRARY | ||
NAMES | ||
glew GLEW glew32s glew32 | ||
PATHS | ||
${GLEW_LOCATION}/lib | ||
${GLEW_LOCATION}/lib/x86 | ||
${GLEW_LOCATION}/lib/win32 | ||
$ENV{GLEW_LOCATION}/lib | ||
$ENV{GLEW_LOCATION}/lib/x86 | ||
$ENV{GLEW_LOCATION}/lib/win32 | ||
$ENV{PROGRAMFILES}/GLEW/lib | ||
$ENV{PROGRAMFILES}/GLEW/lib/x86 | ||
$ENV{PROGRAMFILES}/GLEW/lib/win32 | ||
${PROJECT_SOURCE_DIR}/extern/glew/bin | ||
${PROJECT_SOURCE_DIR}/extern/glew/lib | ||
${PROJECT_SOURCE_DIR}/extern/glew/lib/x86 | ||
${PROJECT_SOURCE_DIR}/extern/glew/lib/win32 | ||
DOC "The GLEW library") | ||
else() | ||
find_library( GLEW_LIBRARY | ||
NAMES | ||
glew GLEW glew32s glew32 | ||
PATHS | ||
${GLEW_LOCATION}/lib/x64 | ||
$ENV{GLEW_LOCATION}/lib/x64 | ||
$ENV{PROGRAMFILES}/GLEW/lib/x64 | ||
${PROJECT_SOURCE_DIR}/extern/glew/bin | ||
${PROJECT_SOURCE_DIR}/extern/glew/lib/x64 | ||
${GLEW_LOCATION}/lib | ||
$ENV{GLEW_LOCATION}/lib | ||
$ENV{PROGRAMFILES}/GLEW/lib | ||
${PROJECT_SOURCE_DIR}/extern/glew/lib | ||
DOC "The GLEW library") | ||
endif() | ||
endif () | ||
|
||
if (${CMAKE_HOST_UNIX}) | ||
find_path( GLEW_INCLUDE_DIR | ||
NAMES | ||
GL/glew.h | ||
PATHS | ||
${GLEW_LOCATION}/include | ||
$ENV{GLEW_LOCATION}/include | ||
/usr/include | ||
/usr/local/include | ||
/sw/include | ||
/opt/local/include | ||
NO_DEFAULT_PATH | ||
DOC "The directory where GL/glew.h resides" | ||
) | ||
find_library( GLEW_LIBRARY | ||
NAMES | ||
GLEW glew | ||
PATHS | ||
${GLEW_LOCATION}/lib | ||
$ENV{GLEW_LOCATION}/lib | ||
/usr/lib64 | ||
/usr/lib | ||
/usr/local/lib64 | ||
/usr/local/lib | ||
/sw/lib | ||
/opt/local/lib | ||
NO_DEFAULT_PATH | ||
DOC "The GLEW library") | ||
endif () | ||
|
||
if (GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h") | ||
|
||
file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" GLEW_4_2 REGEX "^#define GL_VERSION_4_2.*$") | ||
if (GLEW_4_2) | ||
SET(OPENGL_4_2_FOUND TRUE) | ||
else () | ||
message(WARNING | ||
"glew-1.7.0 or newer needed for supporting OpenGL 4.2 dependent features" | ||
) | ||
endif () | ||
|
||
file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" GLEW_4_3 REGEX "^#define GL_VERSION_4_3.*$") | ||
if (GLEW_4_3) | ||
SET(OPENGL_4_3_FOUND TRUE) | ||
else () | ||
message(WARNING | ||
"glew-1.9.0 or newer needed for supporting OpenGL 4.3 dependent features" | ||
) | ||
endif () | ||
|
||
endif () | ||
|
||
if(GLEW_SOURCE) | ||
find_package_handle_standard_args(GLEW DEFAULT_MSG | ||
GLEW_INCLUDE_DIR | ||
GLEW_SOURCE | ||
) | ||
else() | ||
find_package_handle_standard_args(GLEW DEFAULT_MSG | ||
GLEW_INCLUDE_DIR | ||
GLEW_LIBRARY | ||
) | ||
endif() | ||
|
||
mark_as_advanced( GLEW_FOUND ) |
Oops, something went wrong.