@@ -115,6 +115,17 @@ option( KICAD_UPDATE_CHECK
115
115
"Build in update check"
116
116
ON )
117
117
118
+ # EGL is only needed on Linux with Wayland
119
+ cmake_dependent_option( KICAD_USE_EGL
120
+ "Build KiCad with EGL backend support for Wayland."
121
+ OFF "UNIX_NOT_APPLE"
122
+ OFF )
123
+
124
+ cmake_dependent_option( KICAD_USE_BUNDLED_GLEW
125
+ "Use the bundled version of GLEW - only available when KICAD_USE_EGL is set"
126
+ ON "KICAD_USE_EGL"
127
+ OFF )
128
+
118
129
cmake_dependent_option( KICAD_WAYLAND
119
130
"Support Wayland features"
120
131
ON "KICAD_USE_EGL"
@@ -275,6 +286,16 @@ add_compile_definitions( $<$<BOOL:${KICAD_GAL_PROFILE}>:KICAD_GAL_PROFILE> )
275
286
add_compile_definitions ( $<$<BOOL :${KICAD_WIN32_VERIFY_CODESIGN} >:KICAD_WIN32_VERIFY_CODESIGN> )
276
287
add_compile_definitions ( $<$<BOOL :${KICAD_UPDATE_CHECK} >:KICAD_UPDATE_CHECK> )
277
288
289
+ if ( KICAD_USE_EGL )
290
+ message ( STATUS "Configuring KiCad for the wxGLCanvas EGL backend" )
291
+ add_compile_definitions ( KICAD_USE_EGL )
292
+ endif ()
293
+
294
+ if ( KICAD_WAYLAND )
295
+ message ( STATUS "Configuring KiCad to support Wayland features" )
296
+ add_compile_definitions ( KICAD_WAYLAND )
297
+ endif ()
298
+
278
299
if ( KICAD_IPC_API )
279
300
add_definitions ( -DKICAD_IPC_API )
280
301
endif ()
@@ -734,6 +755,50 @@ if( KICAD_BUILD_I18N )
734
755
find_package ( Gettext REQUIRED )
735
756
endif ()
736
757
758
+ #
759
+ # Find OpenGL library, required
760
+ #
761
+ if ( KICAD_USE_EGL )
762
+ find_package ( OpenGL REQUIRED COMPONENTS OpenGL EGL )
763
+ else ()
764
+ set ( OpenGL_GL_PREFERENCE "LEGACY" ) # CMake 3.11+ setting; see 'cmake --help-policy CMP0072'
765
+ find_package ( OpenGL REQUIRED )
766
+ endif ()
767
+
768
+ #
769
+ # Find GLEW library, required
770
+ #
771
+ # The EGL canvas on GTK requires the use of a GLEW version compiled with an EGL flag.
772
+ # The one built in the thirdparty directory has the flag for EGL set, so we use it unless told
773
+ # otherwise. Then we search for the system GLEW version and use that instead.
774
+ #
775
+ if ( KICAD_USE_EGL AND KICAD_USE_BUNDLED_GLEW AND UNIX AND NOT APPLE )
776
+ if ( OpenGL_EGL_FOUND )
777
+ message ( STATUS "Found OpenGL EGL library: ${OPENGL_egl_LIBRARY} " )
778
+ else ()
779
+ message ( FATAL_ERROR "OpenGL EGL library not found" )
780
+ endif ()
781
+
782
+ # Add the custom GLEW target
783
+ add_subdirectory ( thirdparty/glew )
784
+
785
+ # Set the standard package variables to point to our custom target to mimic the system version.
786
+ set ( GLEW_LIBRARIES glew )
787
+ set ( GLEW_FOUND TRUE )
788
+ include_directories ( SYSTEM $<TARGET_PROPERTY:glew,INCLUDE_DIRECTORIES > )
789
+ else ()
790
+ find_package ( GLEW REQUIRED )
791
+ check_find_package_result( GLEW_FOUND "GLEW" )
792
+ include_directories ( SYSTEM ${GLEW_INCLUDE_DIR} )
793
+ endif ()
794
+
795
+ #
796
+ # Find GLM library, required
797
+ #
798
+ find_package ( GLM 0.9.8 REQUIRED )
799
+ add_compile_definitions ( GLM_FORCE_CTOR_INIT )
800
+ include_directories ( SYSTEM ${GLM_INCLUDE_DIR} )
801
+
737
802
#
738
803
# Find zlib library, required
739
804
#
@@ -1012,8 +1077,6 @@ else()
1012
1077
message ( FATAL_ERROR "Unable to detect wxWidgets port" )
1013
1078
endif ()
1014
1079
1015
- message (STATUS "wxUSE_GLCANVAS_EGL=${wxWidgets_GLCANVAS_EGL} " )
1016
-
1017
1080
if ( NOT MSVC )
1018
1081
if ( ${wxWidgets_VERSION_STRING} VERSION_LESS 3.2 )
1019
1082
message ( FATAL_ERROR "wxWidgets 3.2.0 or greater is required" )
@@ -1048,45 +1111,6 @@ if( APPLE )
1048
1111
)
1049
1112
endif ()
1050
1113
1051
- #
1052
- # Find OpenGL library, required
1053
- #
1054
- if ( wxWidgets_GLCANVAS_EGL EQUAL 1 )
1055
- set ( KICAD_USE_EGL ON )
1056
- find_package ( OpenGL REQUIRED COMPONENTS OpenGL EGL )
1057
- else ()
1058
- set ( KICAD_USE_EGL OFF )
1059
- set ( OpenGL_GL_PREFERENCE "LEGACY" ) # CMake 3.11+ setting; see 'cmake --help-policy CMP0072'
1060
- find_package ( OpenGL REQUIRED )
1061
- endif ()
1062
- if ( NOT OPENGL_GLU_FOUND )
1063
- MESSAGE ( FATAL_ERROR "The OpenGL GLU library is required." )
1064
- endif ()
1065
-
1066
- if ( KICAD_USE_EGL )
1067
- message ( STATUS "Configuring KiCad for the wxGLCanvas EGL backend" )
1068
- add_compile_definitions ( KICAD_USE_EGL )
1069
- endif ()
1070
-
1071
- if ( KICAD_WAYLAND )
1072
- message ( STATUS "Configuring KiCad to support Wayland features" )
1073
- add_compile_definitions ( KICAD_WAYLAND )
1074
- endif ()
1075
-
1076
- #
1077
- # Find Epoxy library, required
1078
- #
1079
- find_package ( epoxy REQUIRED )
1080
- check_find_package_result( EPOXY_FOUND "epoxy" )
1081
- include_directories ( SYSTEM ${epoxy_INCLUDE_DIR} )
1082
-
1083
- #
1084
- # Find GLM library, required
1085
- #
1086
- find_package ( GLM 0.9.8 REQUIRED )
1087
- add_compile_definitions ( GLM_FORCE_CTOR_INIT )
1088
- include_directories ( SYSTEM ${GLM_INCLUDE_DIR} )
1089
-
1090
1114
1091
1115
if ( KICAD_USE_SENTRY )
1092
1116
set ( KICAD_SENTRY_DSN "" CACHE STRING "The sentry DSN used with sentry integration" )
0 commit comments