← Back to team overview

kicad-developers team mailing list archive

PATCH: use system glm library

 

The attached patch makes changes so that kicad uses an installed
GLM library rather than the glm source code currently in the kicad tree.

The FindGLM.cmake script included has been tested on Debian Linux,
MSYS2, and OSX+MacPorts.

This patch does not delete the include/gal/opengl/glm directory since
that would make the patch unnecessarily large. If these changes are
pushed into the tree, the include/gal/opengl/glm should also be deleted
in the commit.

This patch of course also implies the added dependency on a GLM
installation. Everyone maintaining an automated build system will
need to install GLM. Package installers for GLM are available on
all supported platforms so I see no obstacles to this change.

- Cirilo
=== modified file '3d-viewer/3d_draw.cpp'
--- 3d-viewer/3d_draw.cpp	2015-11-29 06:56:27 +0000
+++ 3d-viewer/3d_draw.cpp	2015-12-06 22:33:50 +0000
@@ -45,7 +45,7 @@
 #include <colors_selection.h>
 #include <convert_basic_shapes_to_polygon.h>
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/gtc/matrix_transform.hpp>
+#include <gtc/matrix_transform.hpp>
 #include <gal/opengl/opengl_compositor.h>
 #ifdef __WINDOWS__
 #include <GL/glew.h>        // must be included before gl.h

=== modified file '3d-viewer/3d_draw_board_body.cpp'
--- 3d-viewer/3d_draw_board_body.cpp	2015-08-23 19:40:33 +0000
+++ 3d-viewer/3d_draw_board_body.cpp	2015-12-06 22:34:32 +0000
@@ -45,7 +45,7 @@
 #include <colors_selection.h>
 #include <convert_basic_shapes_to_polygon.h>
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/gtc/matrix_transform.hpp>
+#include <gtc/matrix_transform.hpp>
 #include <gal/opengl/opengl_compositor.h>
 #ifdef __WINDOWS__
 #include <GL/glew.h>        // must be included before gl.h

=== modified file '3d-viewer/3d_material.h'
--- 3d-viewer/3d_material.h	2015-04-16 07:43:27 +0000
+++ 3d-viewer/3d_material.h	2015-12-06 22:32:14 +0000
@@ -32,7 +32,7 @@
 #include <common.h>
 #include <base_struct.h>
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/glm.hpp>
+#include <glm.hpp>
 
 class S3D_MASTER;
 

=== modified file '3d-viewer/3d_mesh_model.cpp'
--- 3d-viewer/3d_mesh_model.cpp	2015-10-26 07:46:19 +0000
+++ 3d-viewer/3d_mesh_model.cpp	2015-12-06 22:34:44 +0000
@@ -31,8 +31,8 @@
 #include <3d_mesh_model.h>
 #include <boost/geometry/algorithms/area.hpp>
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/gtc/matrix_transform.hpp>
-#include <gal/opengl/glm/glm.hpp>
+#include <gtc/matrix_transform.hpp>
+#include <glm.hpp>
 
 #ifdef __WXMAC__
 #  ifdef __DARWIN__

=== modified file '3d-viewer/3d_mesh_model.h'
--- 3d-viewer/3d_mesh_model.h	2015-04-16 07:43:27 +0000
+++ 3d-viewer/3d_mesh_model.h	2015-12-06 22:32:22 +0000
@@ -34,7 +34,7 @@
 #include <boost/shared_ptr.hpp>
 #include <vector>
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/glm.hpp>
+#include <glm.hpp>
 #include "3d_struct.h"
 #include "3d_material.h"
 #include "CBBox.h"

=== modified file '3d-viewer/3d_read_mesh.cpp'
--- 3d-viewer/3d_read_mesh.cpp	2015-04-10 07:30:21 +0000
+++ 3d-viewer/3d_read_mesh.cpp	2015-12-06 22:33:39 +0000
@@ -34,7 +34,7 @@
 #include <kicad_string.h>
 #include <pgm_base.h>
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/gtc/matrix_transform.hpp>
+#include <gtc/matrix_transform.hpp>
 #include <3d_viewer.h>
 #include <info3d_visu.h>
 #include "3d_struct.h"

=== modified file '3d-viewer/3d_types.h'
--- 3d-viewer/3d_types.h	2015-03-29 10:59:53 +0000
+++ 3d-viewer/3d_types.h	2015-12-06 22:32:29 +0000
@@ -30,7 +30,7 @@
 #define _3D_TYPES_H_
 
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/glm.hpp>
+#include <glm.hpp>
 #include <base_units.h>     // for IU_PER_MILS
 
 

=== modified file '3d-viewer/CBBox.h'
--- 3d-viewer/CBBox.h	2015-03-29 10:59:53 +0000
+++ 3d-viewer/CBBox.h	2015-12-06 22:31:57 +0000
@@ -31,7 +31,7 @@
 #define CBBox_h
 
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/glm.hpp>
+#include <glm.hpp>
 #include <3d_types.h>
 
 

=== modified file '3d-viewer/CMakeLists.txt'
--- 3d-viewer/CMakeLists.txt	2015-07-04 16:38:08 +0000
+++ 3d-viewer/CMakeLists.txt	2015-12-06 22:31:45 +0000
@@ -6,6 +6,7 @@
     ../pcbnew
     ../polygon
     ${GLEW_INCLUDE_DIR}
+    ${GLM_INCLUDE_DIR}
     ${INC_AFTER}
     )
 

=== modified file '3d-viewer/vrml_aux.h'
--- 3d-viewer/vrml_aux.h	2015-04-07 11:52:29 +0000
+++ 3d-viewer/vrml_aux.h	2015-12-06 22:32:07 +0000
@@ -35,7 +35,7 @@
 #include <macros.h>
 #include <base_struct.h>
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/glm.hpp>
+#include <glm.hpp>
 #include <vector>
 #include <kicad_string.h>
 #include <info3d_visu.h>

=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2015-12-03 15:59:02 +0000
+++ CMakeLists.txt	2015-12-06 22:41:15 +0000
@@ -456,6 +456,14 @@
     check_find_package_result( GLEW_FOUND "GLEW" )
 endif()
 
+####################
+# Find GLM library #
+####################
+if( NOT GLM_FOUND )
+    find_package( GLM 0.9.5.4 REQUIRED )
+    check_find_package_result( GLM_FOUND "GLM" )
+endif()
+
 ######################
 # Find Cairo library #
 ######################

=== added file 'CMakeModules/FindGLM.cmake'
--- CMakeModules/FindGLM.cmake	1970-01-01 00:00:00 +0000
+++ CMakeModules/FindGLM.cmake	2015-12-06 22:19:17 +0000
@@ -0,0 +1,68 @@
+if( ${CMAKE_MAJOR_VERSION} STREQUAL "2" AND ${CMAKE_MINOR_VERSION} STREQUAL "8"
+    AND ( ${CMAKE_PATCH_VERSION} STREQUAL "2" OR ${CMAKE_PATCH_VERSION} STREQUAL "7"
+    OR ${CMAKE_PATCH_VERSION} STREQUAL "10" ) )
+    
+    message( FATAL_ERROR "\nThis version of CMake is known to not work\n"
+        "Known bad versions: 2.8.2, 2.8.7, 2.8.10\n" )
+    
+endif()
+
+
+find_path( GLM_INCLUDE_DIR glm.hpp PATH_SUFFIXES glm )
+
+
+if( NOT ${GLM_INCLUDE_DIR} STREQUAL "" )
+   
+    # attempt to extract the GLM Version information from setup.hpp
+    find_file( GLM_SETUP setup.hpp PATHS ${GLM_INCLUDE_DIR} PATH_SUFFIXES core detail NO_DEFAULT_PATH )
+
+    if( GLM_SETUP )
+        # extract the "#define GLM_VERSION*" lines
+        file( STRINGS ${GLM_SETUP} _version REGEX "^#define.*GLM_VERSION.*" )
+        
+        foreach( SVAR ${_version} )
+            string( REGEX MATCH GLM_VERSION_[M,A,J,O,R,I,N,P,T,C,H,E,V,I,S]* _VARNAME ${SVAR} )
+            string( REGEX MATCH [0-9]+ _VALUE ${SVAR} )
+            
+            if( NOT ${_VARNAME} STREQUAL "" AND NOT ${_VALUE} STREQUAL "" )
+                set( _${_VARNAME} ${_VALUE} )
+            endif()
+            
+        endforeach()
+        
+        #ensure that NOT GLM_VERSION* will evaluate to '0'
+        if( NOT _GLM_VERSION_MAJOR )
+            set( _GLM_VERSION_MAJOR 0 )
+        endif()
+
+        if( NOT _GLM_VERSION_MINOR )
+            set( _GLM_VERSION_MINOR 0 )
+        endif()
+
+        if( NOT _GLM_VERSION_PATCH )
+            set( _GLM_VERSION_PATCH 0 )
+        endif()
+
+        if( NOT _GLM_VERSION_REVISION )
+            set( _GLM_VERSION_REVISION 0 )
+        endif()
+
+        set( GLM_VERSION ${_GLM_VERSION_MAJOR}.${_GLM_VERSION_MINOR}.${_GLM_VERSION_PATCH}.${_GLM_VERSION_REVISION} )
+        unset( GLM_SETUP CACHE )
+        
+    endif( GLM_SETUP )
+    
+endif( NOT ${GLM_INCLUDE_DIR} STREQUAL "" )
+
+
+include( FindPackageHandleStandardArgs )
+FIND_PACKAGE_HANDLE_STANDARD_ARGS( GLM
+    REQUIRED_VARS GLM_INCLUDE_DIR
+    VERSION_VAR GLM_VERSION )
+
+    
+mark_as_advanced( GLM_INCLUDE_DIR )
+set( GLM_VERSION_MAJOR ${_GLM_VERSION_MAJOR} CACHE INTERNAL "" )
+set( GLM_VERSION_MINOR ${_GLM_VERSION_MINOR} CACHE INTERNAL "" )
+set( GLM_VERSION_PATCH ${_GLM_VERSION_PATCH} CACHE INTERNAL "" )
+set( GLM_VERSION_TWEAK ${_GLM_VERSION_REVISION} CACHE INTERNAL "" )

=== modified file 'common/CMakeLists.txt'
--- common/CMakeLists.txt	2015-11-24 10:05:34 +0000
+++ common/CMakeLists.txt	2015-12-06 22:28:30 +0000
@@ -4,6 +4,7 @@
     ./dialog_about
     ${CAIRO_INCLUDE_DIR}
     ${GLEW_INCLUDE_DIR}
+    ${GLM_INCLUDE_DIR}
     ../3d-viewer
     ../pcbnew
     ../polygon

=== modified file 'cvpcb/CMakeLists.txt'
--- cvpcb/CMakeLists.txt	2015-10-29 19:43:04 +0000
+++ cvpcb/CMakeLists.txt	2015-12-06 22:48:06 +0000
@@ -10,6 +10,7 @@
 
 include_directories( BEFORE ${INC_BEFORE} )
 include_directories(
+    ${GLM_INCLUDE_DIR}
     ./dialogs
     ../3d-viewer
     ../pcbnew

=== modified file 'include/gal/opengl/vertex_manager.h'
--- include/gal/opengl/vertex_manager.h	2013-10-14 14:13:35 +0000
+++ include/gal/opengl/vertex_manager.h	2015-12-06 22:29:20 +0000
@@ -32,8 +32,8 @@
 #define VERTEX_MANAGER_H_
 
 #define GLM_FORCE_RADIANS
-#include <gal/opengl/glm/gtc/matrix_transform.hpp>
-#include <gal/opengl/glm/glm.hpp>
+#include <gtc/matrix_transform.hpp>
+#include <glm.hpp>
 #include <gal/opengl/vertex_common.h>
 #include <gal/color4d.h>
 #include <stack>

=== modified file 'pcbnew/CMakeLists.txt'
--- pcbnew/CMakeLists.txt	2015-10-29 19:43:04 +0000
+++ pcbnew/CMakeLists.txt	2015-12-06 22:49:29 +0000
@@ -33,6 +33,7 @@
 
 include_directories( BEFORE ${INC_BEFORE} )
 include_directories(
+    ${GLM_INCLUDE_DIR}
     ./dialogs
     ./autorouter
     ../3d-viewer


Follow ups