X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=CMakeLists.txt;h=34873c1b2a195a31148b79e50bf2ae321838a993;hb=cae6701c343e3a42bc9504f14e6d83e4ca9d8119;hp=377f2f0aade708c40e756a02137f86bc25df3709;hpb=5b4cdcec3031957288d98686c6721df125683dd9;p=freeglut diff --git a/CMakeLists.txt b/CMakeLists.txt index 377f2f0..34873c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR) PROJECT(freeglut) +# for multiarch LIBDIR support (requires cmake>=2.8.8) +INCLUDE(GNUInstallDirs) + # NOTE: On Windows and Cygwin, the dll's are placed in the # CMAKE_RUNTIME_OUTPUT_DIRECTORY, while their corresponding import # libraries end up in CMAKE_ARCHIVE_OUTPUT_DIRECTORY. On other @@ -49,8 +52,12 @@ ENDIF() # OpenGL ES support OPTION(FREEGLUT_GLES "Use OpenGL ES (requires EGL)" OFF) -# option to build either as "glut" (ON) or "freeglut" (OFF) -OPTION(FREEGLUT_REPLACE_GLUT "Be a replacement for GLUT" ON) +IF(NOT WIN32) + # Wayland support + OPTION(FREEGLUT_WAYLAND "Use Wayland (no X11)" OFF) + # option to build either as "glut" (ON) or "freeglut" (OFF) + OPTION(FREEGLUT_REPLACE_GLUT "Be a replacement for GLUT" ON) +ENDIF() SET(FREEGLUT_HEADERS @@ -162,36 +169,60 @@ ELSEIF(ANDROID OR BLACKBERRY) src/blackberry/fg_window_blackberry.c ) ENDIF() + ELSE() - LIST(APPEND FREEGLUT_SRCS - src/x11/fg_cursor_x11.c - src/x11/fg_ext_x11.c - src/x11/fg_gamemode_x11.c - src/x11/fg_glutfont_definitions_x11.c - src/x11/fg_init_x11.c - src/x11/fg_internal_x11.h - src/x11/fg_input_devices_x11.c - src/x11/fg_joystick_x11.c - src/x11/fg_main_x11.c - src/x11/fg_menu_x11.c - src/x11/fg_spaceball_x11.c - src/x11/fg_state_x11.c - src/x11/fg_structure_x11.c - src/x11/fg_window_x11.c - src/x11/fg_xinput_x11.c - ) - IF(NOT(FREEGLUT_GLES)) + # UNIX (Wayland) + IF(FREEGLUT_WAYLAND) + LIST(APPEND FREEGLUT_SRCS + src/wayland/fg_cursor_wl.c + src/wayland/fg_ext_wl.c + src/wayland/fg_gamemode_wl.c + src/wayland/fg_init_wl.c + src/wayland/fg_internal_wl.h + src/wayland/fg_input_devices_wl.c + src/wayland/fg_main_wl.c + src/wayland/fg_state_wl.c + src/wayland/fg_structure_wl.c + src/wayland/fg_window_wl.c + # font, serial port & joystick code are agnostic + src/x11/fg_glutfont_definitions_x11.c + src/x11/fg_input_devices_x11.c + src/x11/fg_joystick_x11.c + ) + # UNIX (X11) + ELSE() LIST(APPEND FREEGLUT_SRCS - src/x11/fg_internal_x11_glx.h - src/x11/fg_display_x11_glx.c - src/x11/fg_state_x11_glx.c - src/x11/fg_state_x11_glx.h - src/x11/fg_window_x11_glx.c - src/x11/fg_window_x11_glx.h + src/x11/fg_cursor_x11.c + src/x11/fg_ext_x11.c + src/x11/fg_gamemode_x11.c + src/x11/fg_glutfont_definitions_x11.c + src/x11/fg_init_x11.c + src/x11/fg_internal_x11.h + src/x11/fg_input_devices_x11.c + src/x11/fg_joystick_x11.c + src/x11/fg_main_x11.c + src/x11/fg_menu_x11.c + src/x11/fg_spaceball_x11.c + src/x11/fg_state_x11.c + src/x11/fg_structure_x11.c + src/x11/fg_window_x11.c + src/x11/fg_xinput_x11.c ) + IF(NOT(FREEGLUT_GLES)) + LIST(APPEND FREEGLUT_SRCS + src/x11/fg_internal_x11_glx.h + src/x11/fg_display_x11_glx.c + src/x11/fg_state_x11_glx.c + src/x11/fg_state_x11_glx.h + src/x11/fg_window_x11_glx.c + src/x11/fg_window_x11_glx.h + ) + ENDIF() ENDIF() ENDIF() -IF(FREEGLUT_GLES) + +# OpenGL ES requires EGL, and so does Wayland +IF(FREEGLUT_GLES OR FREEGLUT_WAYLAND) LIST(APPEND FREEGLUT_SRCS src/egl/fg_internal_egl.h src/egl/fg_display_egl.c @@ -221,6 +252,12 @@ ELSE() INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) ENDIF() +# For Wayland: compile with -DFREEGLUT_WAYLAND and pull EGL +IF(FREEGLUT_WAYLAND) + ADD_DEFINITIONS(-DFREEGLUT_WAYLAND) + LIST(APPEND LIBS wayland-client wayland-cursor wayland-egl EGL xkbcommon) +ENDIF() + # lib m for math, not needed on windows IF (NOT WIN32) # For compilation: @@ -243,15 +280,16 @@ ENDIF() IF(CMAKE_COMPILER_IS_GNUCC) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") - IF(NOT(ANDROID OR BLACKBERRY)) + IF(NOT(ANDROID OR BLACKBERRY OR FREEGLUT_WAYLAND)) # not setting -ansi as EGL/KHR headers doesn't support it SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic") ENDIF() ENDIF(CMAKE_COMPILER_IS_GNUCC) INCLUDE(CheckIncludeFiles) -IF(UNIX AND NOT(ANDROID OR BLACKBERRY)) +IF(UNIX AND NOT(ANDROID OR BLACKBERRY OR FREEGLUT_WAYLAND)) FIND_PACKAGE(X11 REQUIRED) + INCLUDE_DIRECTORIES(${X11_INCLUDE_DIR}) LIST(APPEND LIBS ${X11_LIBRARIES}) IF(X11_Xrandr_FOUND) SET(HAVE_X11_EXTENSIONS_XRANDR_H TRUE) @@ -259,10 +297,6 @@ IF(UNIX AND NOT(ANDROID OR BLACKBERRY)) ENDIF() IF(X11_xf86vmode_FOUND) SET(HAVE_X11_EXTENSIONS_XF86VMODE_H TRUE) - # Work-around http://www.cmake.org/Bug/bug_view_page.php?bug_id=6976 - IF(NOT "${X11_Xxf86vm_LIB}") - SET(X11_Xxf86vm_LIB "Xxf86vm") - ENDIF() LIST(APPEND LIBS ${X11_Xxf86vm_LIB}) ENDIF() IF(X11_Xinput_FOUND) @@ -323,7 +357,7 @@ ENDIF() # ensure that all CMake-generated files are kept away from the main source tree. # As a result, the build directory must to be added to the include path list. CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h) -INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src) +INCLUDE_DIRECTORIES(BEFORE ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/src) ADD_DEFINITIONS(-DHAVE_CONFIG_H) IF(WIN32) # we also have to generate freeglut.rc, which contains the version @@ -411,8 +445,8 @@ ENDIF() IF(FREEGLUT_BUILD_SHARED_LIBS) INSTALL(TARGETS freeglut RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) IF(INSTALL_PDB) INSTALL(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/freeglut${CMAKE_DEBUG_POSTFIX}.pdb @@ -423,8 +457,8 @@ ENDIF() IF(FREEGLUT_BUILD_STATIC_LIBS) INSTALL(TARGETS freeglut_static RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) IF(INSTALL_PDB) INSTALL(FILES ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/Debug/freeglut_static${CMAKE_DEBUG_POSTFIX}.pdb @@ -504,11 +538,17 @@ ELSEIF(FREEGLUT_GLES) ELSE() SET(PC_LIBS_PRIVATE "-lbps -lslog2 -lscreen -lGLESv2 -lGLESv1_CM -lEGL -lm") ENDIF() + ELSEIF(FREEGLUT_WAYLAND) + SET(PC_LIBS_PRIVATE "-lwayland-client -lwayland-cursor -lwayland-egl -lGLESv2 -lGLESv1_CM -lEGL -lxkbcommon -lm") ELSE() SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lGLESv1_CM -lEGL -lm") ENDIF() ELSE() - SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGL -lm") + IF(FREEGLUT_WAYLAND) + SET(PC_LIBS_PRIVATE "-lwayland-client -lwayland-cursor -lwayland-egl -lGL -lxkbcommon -lm") + ELSE() + SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGL -lm") + ENDIF() ENDIF() # Client applications need to define FreeGLUT GLES version to # bootstrap headers inclusion in freeglut_std.h: @@ -520,6 +560,6 @@ IF(FREEGLUT_GLES) SET(PC_FILENAME "freeglut-gles.pc") ENDIF() CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freeglut.pc.in ${CMAKE_BINARY_DIR}/freeglut.pc @ONLY) -INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION share/pkgconfig/ RENAME ${PC_FILENAME}) +INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig/ RENAME ${PC_FILENAME}) # TODO: change the library and .pc name when building for GLES, # e.g. -lglut-GLES