[CMake] config.h, part 2 - full compatibility with autoconf.

This commit makes the file config.h generated by CMake 100% compatible
with the one generated by autoconf/configure.

Fixes in this commit:
 - Set FLTK_DATADIR and FLTK_DOCDIR with the same default values.
   Note: needs some cleanup, option values are not clear, '/fltk'
   is currently appended in export.cmake (needs improvement).
 - Simulation of autoconf macro AC_HEADER_DIRENT for correct
   definition of only one 'dirent' header file.
 - Fix more function checks:
    - dlsym
    - png_get_valid
    - png_set_tRNS_to_alpha
 - Improve "Big Endian" check for __APPLE__ (mac_endianness.h).


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10985 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2015-12-30 21:13:07 +00:00
parent 4f5e6e7732
commit 3beb45165a
5 changed files with 82 additions and 19 deletions

View File

@ -82,10 +82,28 @@ if(UNIX)
)
endif(UNIX)
# prepare some variables for config.h
if(IS_ABSOLUTE "${FLTK_DATADIR}")
set(PREFIX_DATA "${FLTK_DATADIR}/fltk")
else(IS_ABSOLUTE "${FLTK_DATADIR}")
set(PREFIX_DATA "${CMAKE_INSTALL_PREFIX}/${FLTK_DATADIR}/fltk")
endif(IS_ABSOLUTE "${FLTK_DATADIR}")
if(IS_ABSOLUTE "${FLTK_DOCDIR}")
set(PREFIX_DOC "${FLTK_DOCDIR}/fltk")
else(IS_ABSOLUTE "${FLTK_DOCDIR}")
set(PREFIX_DOC "${CMAKE_INSTALL_PREFIX}/${FLTK_DOCDIR}/fltk")
endif(IS_ABSOLUTE "${FLTK_DOCDIR}")
set(CONFIG_H_IN configh.cmake.in)
set(CONFIG_H config.h)
# generate config.h
configure_file(
"${FLTK_SOURCE_DIR}/configh.cmake.in"
"${FLTK_BINARY_DIR}/config.h"
"${FLTK_SOURCE_DIR}/${CONFIG_H_IN}"
"${FLTK_BINARY_DIR}/${CONFIG_H}"
@ONLY
)

View File

@ -22,26 +22,41 @@
#######################################################################
# headers
find_file(HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h)
find_file(HAVE_DIRENT_H dirent.h)
find_file(HAVE_DLFCN_H dlfcn.h)
find_file(HAVE_FREETYPE_H freetype.h PATH_SUFFIXES freetype2 freetype2/freetype)
find_file(HAVE_GL_GL_H GL/gl.h)
find_file(HAVE_GL_GLU_H GL/glu.h)
find_file(HAVE_LIBPNG_PNG_H libpng/png.h)
find_file(HAVE_LOCALE_H locale.h)
find_file(HAVE_NDIR_H ndir.h)
find_file(HAVE_OPENGL_GLU_H OpenGL/glu.h)
find_file(HAVE_PNG_H png.h)
find_file(HAVE_PTHREAD_H pthread.h)
find_file(HAVE_STDIO_H stdio.h)
find_file(HAVE_STRINGS_H strings.h)
find_file(HAVE_SYS_DIR_H sys/dir.h)
find_file(HAVE_SYS_NDIR_H sys/ndir.h)
find_file(HAVE_SYS_SELECT_H sys/select.h)
find_file(HAVE_SYS_STDTYPES_H sys/stdtypes.h)
find_file(HAVE_X11_XREGION_H X11/Xregion.h)
find_path(HAVE_XDBE_H Xdbe.h PATH_SUFFIXES X11/extensions extensions)
# Simulate the behavior of autoconf macro AC_HEADER_DIRENT, see:
# https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Particular-Headers.html
# "Check for the following header files. For the first one that is found
# and defines DIR, define the listed C preprocessor macro ..."
#
# Note: we don't check if it really defines 'DIR', but we stop processing
# once we found the first suitable header file.
find_file(HAVE_DIRENT_H dirent.h)
if(NOT HAVE_DIRENT_H)
find_file(HAVE_SYS_NDIR_H sys/ndir.h)
if(NOT HAVE_SYS_NDIR_H)
find_file(HAVE_SYS_DIR_H sys/dir.h)
if(NOT HAVE_SYS_DIR_H)
find_file(HAVE_NDIR_H ndir.h)
endif(NOT HAVE_SYS_DIR_H)
endif(NOT HAVE_SYS_NDIR_H)
endif(NOT HAVE_DIRENT_H)
mark_as_advanced(HAVE_ALSA_ASOUNDLIB_H HAVE_DIRENT_H HAVE_DLFCN_H)
mark_as_advanced(HAVE_FREETYPE_H HAVE_GL_GL_H HAVE_GL_GLU_H)
mark_as_advanced(HAVE_LIBPNG_PNG_H HAVE_LOCALE_H HAVE_NDIR_H)
@ -79,15 +94,32 @@ mark_as_advanced(LIB_jpeg LIB_png LIB_zlib)
# functions
include(CheckFunctionExists)
# save CMAKE_REQUIRED_LIBRARIES (is this really necessary ?)
if(DEFINED CMAKE_REQUIRED_LIBRARIES)
set(SAVED_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
else(DEFINED CMAKE_REQUIRED_LIBRARIES)
unset(SAVED_REQUIRED_LIBRARIES)
endif(DEFINED CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES)
if(HAVE_DLFCN_H)
set(HAVE_DLFCN_H 1)
endif(HAVE_DLFCN_H)
CHECK_FUNCTION_EXISTS(dlsym HAVE_DLSYM)
CHECK_FUNCTION_EXISTS(localeconv HAVE_LOCALECONV)
if(LIB_dl)
set(CMAKE_REQUIRED_LIBRARIES ${LIB_dl})
CHECK_FUNCTION_EXISTS(dlsym HAVE_DLSYM)
set(CMAKE_REQUIRED_LIBRARIES)
endif(LIB_dl)
CHECK_FUNCTION_EXISTS(png_get_valid HAVE_PNG_GET_VALID)
CHECK_FUNCTION_EXISTS(png_set_tRNS_to_alpha HAVE_PNG_SET_TRNS_TO_ALPHA)
CHECK_FUNCTION_EXISTS(localeconv HAVE_LOCALECONV)
if(LIB_png)
set(CMAKE_REQUIRED_LIBRARIES ${LIB_png})
CHECK_FUNCTION_EXISTS(png_get_valid HAVE_PNG_GET_VALID)
CHECK_FUNCTION_EXISTS(png_set_tRNS_to_alpha HAVE_PNG_SET_TRNS_TO_ALPHA)
set(CMAKE_REQUIRED_LIBRARIES)
endif(LIB_png)
CHECK_FUNCTION_EXISTS(scandir HAVE_SCANDIR)
CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
@ -120,6 +152,14 @@ if(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX)
endif(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX)
mark_as_advanced(HAVE_SCANDIR_POSIX)
# restore CMAKE_REQUIRED_LIBRARIES (is this really necessary ?)
if(DEFINED SAVED_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
unset(SAVED_REQUIRED_LIBRARIES)
else(DEFINED SAVED_REQUIRED_LIBRARIES)
unset(CMAKE_REQUIRED_LIBRARIES)
endif(DEFINED SAVED_REQUIRED_LIBRARIES)
#######################################################################
# packages

View File

@ -60,6 +60,8 @@ set(FLTK_DATADIR ${CMAKE_INSTALL_DATADIR} CACHE PATH
"Non-arch data install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
set(FLTK_MANDIR ${CMAKE_INSTALL_MANDIR} CACHE PATH
"Manual install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
set(FLTK_DOCDIR ${CMAKE_INSTALL_DATADIR}/doc CACHE PATH
"Non-arch doc install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.")
#######################################################################

View File

@ -1,8 +1,8 @@
/* @CONFIG_H@. Generated from @CONFIG_H_IN@ by CMake. */
/*
* "$Id$"
*
* Configuration file for the Fast Light Tool Kit (FLTK).
* @configure_input@
*
* Copyright 1998-2015 by Bill Spitzak and others.
*
@ -21,8 +21,8 @@
* Where to find files...
*/
#define FLTK_DATADIR "@PREFIX_DATA@"
#define FLTK_DOCDIR "@PREFIX_DOC@"
#define FLTK_DATADIR "@PREFIX_DATA@"
#define FLTK_DOCDIR "@PREFIX_DOC@"
/*
* BORDER_WIDTH:
@ -147,7 +147,7 @@
* no meaning on operating systems other than Mac OS X.
*/
#cmakedefine __APPLE_QUARTZ__ @__APPLE_QUARTZ__@
#cmakedefine __APPLE_QUARTZ__ 1
/*
@ -185,7 +185,11 @@
* Byte order of your machine: 1 = big-endian, 0 = little-endian.
*/
#define WORDS_BIGENDIAN @WORDS_BIGENDIAN@
#ifdef __APPLE__
#include <mac_endianness.h>
#else
#cmakedefine01 WORDS_BIGENDIAN
#endif
/*
* U16, U32, U64:

View File

@ -2,7 +2,6 @@
* "$Id$"
*
* Configuration file for the Fast Light Tool Kit (FLTK).
* @configure_input@
*
* Copyright 1998-2015 by Bill Spitzak and others.
*
@ -21,8 +20,8 @@
* Where to find files...
*/
#define FLTK_DATADIR ""
#define FLTK_DOCDIR ""
#define FLTK_DATADIR ""
#define FLTK_DOCDIR ""
/*
* BORDER_WIDTH: