From 4f5e6e7732553a9689f773715074fc14420f16b0 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Wed, 30 Dec 2015 14:37:35 +0000 Subject: [PATCH] Harmonize configure and CMake build system (part 1). The files "config.h" generated by configure and CMake are now almost identical, except a few comments and some still missing or failing config tests, for instance checks for some functions in libraries. [Note: tested and compared on Linux.] configh.cmake.in: Fixed many #cmakedefine and #cmakedefine01 statements so they #define their variables as 0 or 1, or /* #undef */ it, resp., as it is done in the configure build. Added tests: - libXrender Fixed tests: - function glXGetProcAddressARB Todo (still failing tests in CMake): - HAVE_PNG_GET_VALID - HAVE_PNG_SET_TRNS_TO_ALPHA - HAVE_DLSYM Other remaining issues: - compiler flags introduced in configure/make build - HAVE_SYS_NDIR_H - maybe missing test in configure ? - HAVE_SYS_DIR_H - maybe missing test in configure ? - HAVE_NDIR_H - maybe missing test in configure ? - WORDS_BIGENDIAN and #include ... i.e. Mac OS X specific #include needed or not ? git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10984 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CMake/macros.cmake | 4 +++ CMake/options.cmake | 30 +++++++++++++--- CMake/resources.cmake | 1 + configh.cmake.in | 79 ++++++++++++++++++++++++------------------- configh.in | 6 ++-- fluid/CMakeLists.txt | 4 +++ 6 files changed, 82 insertions(+), 42 deletions(-) diff --git a/CMake/macros.cmake b/CMake/macros.cmake index 86b609d15..aa76375f4 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake @@ -148,6 +148,10 @@ macro(CREATE_EXAMPLE NAME SOURCES LIBRARIES) target_link_libraries(${tname} ${X11_Xinerama_LIB}) endif(HAVE_XINERAMA) + if(HAVE_XRENDER) + target_link_libraries(${tname} ${X11_Xrender_LIB}) + endif(HAVE_XRENDER) + endmacro(CREATE_EXAMPLE NAME SOURCES LIBRARIES) ####################################################################### diff --git a/CMake/options.cmake b/CMake/options.cmake index 1c721d131..0aa687fef 100644 --- a/CMake/options.cmake +++ b/CMake/options.cmake @@ -58,11 +58,8 @@ if((NOT APPLE OR OPTION_APPLE_X11) AND NOT WIN32) set(USE_X11 1) list(APPEND FLTK_LDLIBS -lX11) if (X11_Xext_FOUND) - list(APPEND FLTK_LDLIBS -lXext) + list(APPEND FLTK_LDLIBS -lXext) endif(X11_Xext_FOUND) - if(X11_Xrender_FOUND) - list(APPEND FLTK_LDLIBS -lXrender) - endif(X11_Xrender_FOUND) endif(X11_FOUND) endif((NOT APPLE OR OPTION_APPLE_X11) AND NOT WIN32) @@ -137,7 +134,14 @@ endif(OPTION_USE_GL) if(OPENGL_FOUND) set(CMAKE_REQUIRED_INCLUDES ${OPENGL_INCLUDE_DIR}/GL) set(GLLIB "-lGLU -lGL") + + # check if function glXGetProcAddressARB exists + set(TEMP_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES GLU GL) CHECK_FUNCTION_EXISTS(glXGetProcAddressARB HAVE_GLXGETPROCADDRESSARB) + set(CMAKE_REQUIRED_LIBRARIES ${TEMP_REQUIRED_LIBRARIES}) + unset(TEMP_REQUIRED_LIBRARIES) + set(FLTK_GL_FOUND TRUE) else() set(FLTK_GL_FOUND FALSE) @@ -314,6 +318,24 @@ else() set(FLTK_XFT_FOUND FALSE) endif(OPTION_USE_XFT) +####################################################################### +if(X11_Xrender_FOUND) + option(OPTION_USE_XRENDER "use lib Xrender" ON) +endif(X11_Xrender_FOUND) + +if(OPTION_USE_XRENDER) + set(HAVE_XRENDER ${X11_Xrender_FOUND}) + if(HAVE_XRENDER) + include_directories(${X11_Xrender_INCLUDE_PATH}) + list(APPEND FLTK_LDLIBS -lXrender) + set(FLTK_XRENDER_FOUND TRUE) + else(HAVE_XRENDER) + set(FLTK_XRENDER_FOUND FALSE) + endif(HAVE_XRENDER) +else(OPTION_USE_XRENDER) + set(FLTK_XRENDER_FOUND FALSE) +endif(OPTION_USE_XRENDER) + ####################################################################### if(X11_FOUND) option(OPTION_USE_XDBE "use lib Xdbe" ON) diff --git a/CMake/resources.cmake b/CMake/resources.cmake index c44e36a15..730f19070 100644 --- a/CMake/resources.cmake +++ b/CMake/resources.cmake @@ -49,6 +49,7 @@ mark_as_advanced(HAVE_OPENGL_GLU_H HAVE_PNG_H HAVE_PTHREAD_H) mark_as_advanced(HAVE_STDIO_H HAVE_STRINGS_H HAVE_SYS_DIR_H) mark_as_advanced(HAVE_SYS_NDIR_H HAVE_SYS_SELECT_H) mark_as_advanced(HAVE_SYS_STDTYPES_H HAVE_XDBE_H) +mark_as_advanced(HAVE_X11_XREGION_H) # where to find freetype headers find_path(FREETYPE_PATH freetype.h PATH_SUFFIXES freetype2) diff --git a/configh.cmake.in b/configh.cmake.in index bf0aed077..15a6f0df8 100644 --- a/configh.cmake.in +++ b/configh.cmake.in @@ -64,7 +64,7 @@ * Do you have the OpenGL glXGetProcAddressARB() function? */ -#cmakedefine HAVE_GLXGETPROCADDRESSARB %HAVE_GLXGETPROCADDRESSARB% +#cmakedefine HAVE_GLXGETPROCADDRESSARB 1 /* * USE_COLORMAP: @@ -123,6 +123,14 @@ #cmakedefine01 HAVE_XCURSOR +/* + * HAVE_XRENDER: + * + * Do we have the X render library? + */ + +#cmakedefine01 HAVE_XRENDER + /* * HAVE_X11_XREGION_H: * @@ -134,9 +142,9 @@ /* * __APPLE_QUARTZ__: * - * If __APPLE_QUARTZ__ is defined, FLTK will be - * compiled using Quartz. This flag has no meaning on - * other operating systems than Mac OS X. + * All Apple implementations are now based on Quartz and Cocoa, + * so this flag should always be on for Mac OS X. This flag has + * no meaning on operating systems other than Mac OS X. */ #cmakedefine __APPLE_QUARTZ__ @__APPLE_QUARTZ__@ @@ -149,7 +157,7 @@ * */ -#cmakedefine USE_X11 @USE_X11@ +#cmakedefine USE_X11 1 /* * HAVE_OVERLAY: @@ -197,35 +205,35 @@ * Where is (used only by fl_file_chooser and scandir). */ -#cmakedefine HAVE_DIRENT_H @HAVE_DIRENT_H@ -#cmakedefine HAVE_SYS_NDIR_H @HAVE_SYS_NDIR_H@ -#cmakedefine HAVE_SYS_DIR_H @HAVE_SYS_DIR_H@ -#cmakedefine HAVE_NDIR_H @HAVE_NDIR_H@ -#cmakedefine HAVE_SCANDIR @HAVE_SCANDIR@ -#cmakedefine HAVE_SCANDIR_POSIX @HAVE_SCANDIR_POSIX@ +#cmakedefine HAVE_DIRENT_H 1 +#cmakedefine HAVE_SYS_NDIR_H 1 +#cmakedefine HAVE_SYS_DIR_H 1 +#cmakedefine HAVE_NDIR_H 1 +#cmakedefine HAVE_SCANDIR 1 +#cmakedefine HAVE_SCANDIR_POSIX 1 /* * Possibly missing sprintf-style functions: */ -#cmakedefine HAVE_VSNPRINTF @HAVE_VSNPRINTF@ -#cmakedefine HAVE_SNPRINTF @HAVE_SNPRINTF@ +#cmakedefine HAVE_VSNPRINTF 1 +#cmakedefine HAVE_SNPRINTF 1 /* * String functions and headers... */ -#cmakedefine HAVE_STRINGS_H @HAVE_STRINGS_H@ -#cmakedefine HAVE_STRCASECMP @HAVE_STRCASECMP@ -#cmakedefine HAVE_STRLCAT @HAVE_STRLCAT@ -#cmakedefine HAVE_STRLCPY @HAVE_STRLCPY@ +#cmakedefine HAVE_STRINGS_H 1 +#cmakedefine HAVE_STRCASECMP 1 +#cmakedefine HAVE_STRLCAT 1 +#cmakedefine HAVE_STRLCPY 1 /* * Do we have POSIX locale support? */ -#cmakedefine HAVE_LOCALE_H @HAVE_LOCALE_H@ -#cmakedefine HAVE_LOCALECONV @HAVE_LOCALECONV@ +#cmakedefine HAVE_LOCALE_H 1 +#cmakedefine HAVE_LOCALECONV 1 /* * HAVE_SYS_SELECT_H: @@ -241,7 +249,7 @@ * Whether or not we have the header file. */ -#cmakedefine HAVE_SYS_STDTYPES_H @HAVE_SYS_STDTYPES_H@ +#cmakedefine HAVE_SYS_STDTYPES_H 1 /* * USE_POLL: @@ -255,9 +263,9 @@ * Do we have various image libraries? */ -#cmakedefine HAVE_LIBPNG @HAVE_LIBPNG@ -#cmakedefine HAVE_LIBZ @HAVE_LIBZ@ -#cmakedefine HAVE_LIBJPEG @HAVE_LIBJPEG@ +#cmakedefine HAVE_LIBPNG 1 +#cmakedefine HAVE_LIBZ 1 +#cmakedefine HAVE_LIBJPEG 1 /* * FLTK_USE_CAIRO @@ -266,7 +274,7 @@ * will implies to link cairo.lib in all fltk based apps. */ -#cmakedefine FLTK_USE_CAIRO @FLTK_USE_CAIRO@ +#cmakedefine FLTK_USE_CAIRO 1 /* * FLTK_HAVE_CAIRO @@ -274,39 +282,40 @@ * Do we have the cairo library available? */ -#cmakedefine FLTK_HAVE_CAIRO @FLTK_HAVE_CAIRO@ +#cmakedefine FLTK_HAVE_CAIRO 1 /* * Which header file do we include for libpng? */ -#cmakedefine HAVE_PNG_H @HAVE_PNG_H@ -#cmakedefine HAVE_LIBPNG_PNG_H @HAVE_LIBPNG_PNG_H@ +#cmakedefine HAVE_PNG_H 1 +#cmakedefine HAVE_LIBPNG_PNG_H 1 /* * Do we have the png_xyz() functions? */ -#cmakedefine HAVE_PNG_GET_VALID @HAVE_PNG_GET_VALID@ -#cmakedefine HAVE_PNG_SET_TRNS_TO_ALPHA @HAVE_PNG_SET_TRNS_TO_ALPHA@ +#cmakedefine HAVE_PNG_GET_VALID 1 +#cmakedefine HAVE_PNG_SET_TRNS_TO_ALPHA 1 /* * Do we have POSIX threading? */ -#cmakedefine HAVE_PTHREAD @HAVE_PTHREAD@ -#cmakedefine01 HAVE_PTHREAD_H +#cmakedefine HAVE_PTHREAD 1 +#cmakedefine HAVE_PTHREAD_H 1 /* * Do we have the ALSA library? */ -#cmakedefine HAVE_ALSA_ASOUNDLIB_H @HAVE_ALSA_ASOUNDLIB_H@ +#cmakedefine HAVE_ALSA_ASOUNDLIB_H 1 + /* * Do we have the long long type? */ -#cmakedefine HAVE_LONG_LONG @HAVE_LONG_LONG@ +#cmakedefine HAVE_LONG_LONG 1 #ifdef HAVE_LONG_LONG # define FLTK_LLFMT "%lld" @@ -320,8 +329,8 @@ * Do we have the dlsym() function and header? */ -#cmakedefine HAVE_DLFCN_H @HAVE_DLFCN_H@ -#cmakedefine HAVE_DLSYM @HAVE_DLSYM@ +#cmakedefine HAVE_DLFCN_H 1 +#cmakedefine HAVE_DLSYM 1 /* * End of "$Id$". diff --git a/configh.in b/configh.in index 96e8d1fcf..a60a0ca63 100644 --- a/configh.in +++ b/configh.in @@ -56,7 +56,7 @@ * (many broken Mesa RPMs do not...) */ -#undef HAVE_GL_GLU_H +#define HAVE_GL_GLU_H 0 /* * HAVE_GLXGETPROCADDRESSARB: @@ -143,7 +143,7 @@ * __APPLE_QUARTZ__: * * All Apple implementations are now based on Quartz and Cocoa, - * so this flag should always be on for Mac OS X. This flag has + * so this flag should always be on for Mac OS X. This flag has * no meaning on operating systems other than Mac OS X. */ @@ -245,7 +245,7 @@ * Whether or not select() call has its own header file. */ -#undef HAVE_SYS_SELECT_H +#define HAVE_SYS_SELECT_H 0 /* * HAVE_SYS_STDTYPES_H: diff --git a/fluid/CMakeLists.txt b/fluid/CMakeLists.txt index 7fcd49950..86c7fba13 100644 --- a/fluid/CMakeLists.txt +++ b/fluid/CMakeLists.txt @@ -57,6 +57,10 @@ if(HAVE_XINERAMA) target_link_libraries(fluid ${X11_Xinerama_LIB}) endif(HAVE_XINERAMA) +if(HAVE_XRENDER) + target_link_libraries(fluid ${X11_Xrender_LIB}) +endif(HAVE_XRENDER) + if(APPLE) set_target_properties(fluid PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME}) set_target_properties(fluid PROPERTIES RESOURCE ${ICON_PATH})