diff options
author | Christopher Degawa <ccom@randomderp.com> | 2021-06-11 20:38:44 (GMT) |
---|---|---|
committer | Christopher Degawa <ccom@randomderp.com> | 2021-07-02 18:33:18 (GMT) |
commit | f3f040118736eb793a2615247ed7e0ed5d5bd939 (patch) | |
tree | a713c14c84b3cb612a529f39f2c57288c167d8ae /Modules/FindGLUT.cmake | |
parent | bece79f9bea1aa61d578429b63da76879ac5e5ba (diff) | |
download | CMake-f3f040118736eb793a2615247ed7e0ed5d5bd939.zip CMake-f3f040118736eb793a2615247ed7e0ed5d5bd939.tar.gz CMake-f3f040118736eb793a2615247ed7e0ed5d5bd939.tar.bz2 |
FindGLUT: Reduce if/else nesting and indentation
Signed-off-by: Christopher Degawa <ccom@randomderp.com>
Diffstat (limited to 'Modules/FindGLUT.cmake')
-rw-r--r-- | Modules/FindGLUT.cmake | 127 |
1 files changed, 59 insertions, 68 deletions
diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 2770c60..53ff727 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -42,7 +42,7 @@ Also defined, but not for general use are: include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) -if (WIN32) +if(WIN32) find_path( GLUT_INCLUDE_DIR NAMES GL/glut.h PATHS ${GLUT_ROOT_PATH}/include ) find_library( GLUT_glut_LIBRARY_RELEASE NAMES glut glut32 freeglut @@ -57,83 +57,74 @@ if (WIN32) ) mark_as_advanced(GLUT_glut_LIBRARY_RELEASE GLUT_glut_LIBRARY_DEBUG) select_library_configurations(GLUT_glut) -else () - - if (APPLE) - find_path(GLUT_INCLUDE_DIR glut.h ${OPENGL_LIBRARY_DIR}) - find_library(GLUT_glut_LIBRARY GLUT DOC "GLUT library for OSX") - find_library(GLUT_cocoa_LIBRARY Cocoa DOC "Cocoa framework for OSX") - mark_as_advanced(GLUT_glut_LIBRARY GLUT_cocoa_LIBRARY) - - if(GLUT_cocoa_LIBRARY AND NOT TARGET GLUT::Cocoa) - add_library(GLUT::Cocoa UNKNOWN IMPORTED) - # Cocoa should always be a Framework, but we check to make sure. - if(GLUT_cocoa_LIBRARY MATCHES "/([^/]+)\\.framework$") - set(_glut_cocoa "${GLUT_cocoa_LIBRARY}/${CMAKE_MATCH_1}") - if(EXISTS "${_glut_cocoa}.tbd") - string(APPEND _glut_cocoa ".tbd") - endif() - set_target_properties(GLUT::Cocoa PROPERTIES - IMPORTED_LOCATION "${_glut_cocoa}") - else() - set_target_properties(GLUT::Cocoa PROPERTIES - IMPORTED_LOCATION "${GLUT_cocoa_LIBRARY}") +elseif(APPLE) + find_path(GLUT_INCLUDE_DIR glut.h ${OPENGL_LIBRARY_DIR}) + find_library(GLUT_glut_LIBRARY GLUT DOC "GLUT library for OSX") + find_library(GLUT_cocoa_LIBRARY Cocoa DOC "Cocoa framework for OSX") + mark_as_advanced(GLUT_glut_LIBRARY GLUT_cocoa_LIBRARY) + + if(GLUT_cocoa_LIBRARY AND NOT TARGET GLUT::Cocoa) + add_library(GLUT::Cocoa UNKNOWN IMPORTED) + # Cocoa should always be a Framework, but we check to make sure. + if(GLUT_cocoa_LIBRARY MATCHES "/([^/]+)\\.framework$") + set(_glut_cocoa "${GLUT_cocoa_LIBRARY}/${CMAKE_MATCH_1}") + if(EXISTS "${_glut_cocoa}.tbd") + string(APPEND _glut_cocoa ".tbd") endif() - endif() - else () - - if (BEOS) - - set(_GLUT_INC_DIR /boot/develop/headers/os/opengl) - set(_GLUT_glut_LIB_DIR /boot/develop/lib/x86) - + set_target_properties(GLUT::Cocoa PROPERTIES + IMPORTED_LOCATION "${_glut_cocoa}") else() - - find_library( GLUT_Xi_LIBRARY Xi - /usr/openwin/lib - ) - mark_as_advanced(GLUT_Xi_LIBRARY) - - find_library( GLUT_Xmu_LIBRARY Xmu - /usr/openwin/lib - ) - mark_as_advanced(GLUT_Xmu_LIBRARY) - - if(GLUT_Xi_LIBRARY AND NOT TARGET GLUT::Xi) - add_library(GLUT::Xi UNKNOWN IMPORTED) - set_target_properties(GLUT::Xi PROPERTIES - IMPORTED_LOCATION "${GLUT_Xi_LIBRARY}") - endif() - - if(GLUT_Xmu_LIBRARY AND NOT TARGET GLUT::Xmu) - add_library(GLUT::Xmu UNKNOWN IMPORTED) - set_target_properties(GLUT::Xmu PROPERTIES - IMPORTED_LOCATION "${GLUT_Xmu_LIBRARY}") - endif() - - endif () - - find_path( GLUT_INCLUDE_DIR GL/glut.h - /usr/include/GL - /usr/openwin/share/include - /usr/openwin/include - /opt/graphics/OpenGL/include - /opt/graphics/OpenGL/contrib/libglut - ${_GLUT_INC_DIR} + set_target_properties(GLUT::Cocoa PROPERTIES + IMPORTED_LOCATION "${GLUT_cocoa_LIBRARY}") + endif() + endif() +else() + if(BEOS) + set(_GLUT_INC_DIR /boot/develop/headers/os/opengl) + set(_GLUT_glut_LIB_DIR /boot/develop/lib/x86) + else() + find_library( GLUT_Xi_LIBRARY Xi + /usr/openwin/lib ) + mark_as_advanced(GLUT_Xi_LIBRARY) - find_library( GLUT_glut_LIBRARY glut + find_library( GLUT_Xmu_LIBRARY Xmu /usr/openwin/lib - ${_GLUT_glut_LIB_DIR} ) - mark_as_advanced(GLUT_glut_LIBRARY) + mark_as_advanced(GLUT_Xmu_LIBRARY) - unset(_GLUT_INC_DIR) - unset(_GLUT_glut_LIB_DIR) + if(GLUT_Xi_LIBRARY AND NOT TARGET GLUT::Xi) + add_library(GLUT::Xi UNKNOWN IMPORTED) + set_target_properties(GLUT::Xi PROPERTIES + IMPORTED_LOCATION "${GLUT_Xi_LIBRARY}") + endif() + + if(GLUT_Xmu_LIBRARY AND NOT TARGET GLUT::Xmu) + add_library(GLUT::Xmu UNKNOWN IMPORTED) + set_target_properties(GLUT::Xmu PROPERTIES + IMPORTED_LOCATION "${GLUT_Xmu_LIBRARY}") + endif() endif () -endif () + find_path( GLUT_INCLUDE_DIR GL/glut.h + /usr/include/GL + /usr/openwin/share/include + /usr/openwin/include + /opt/graphics/OpenGL/include + /opt/graphics/OpenGL/contrib/libglut + ${_GLUT_INC_DIR} + ) + + find_library( GLUT_glut_LIBRARY glut + /usr/openwin/lib + ${_GLUT_glut_LIB_DIR} + ) + + unset(_GLUT_INC_DIR) + unset(_GLUT_glut_LIB_DIR) +endif() +mark_as_advanced(GLUT_glut_LIBRARY) include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_glut_LIBRARY GLUT_INCLUDE_DIR) |