diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2015-12-30 21:13:07 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2015-12-30 21:13:07 +0000 |
| commit | 3beb45165a4e3aac8ab6a6a4add93eb4cd48eceb (patch) | |
| tree | fd3dbd8adbe84f20044a7ed24485e59e894c11a1 | |
| parent | 4f5e6e7732553a9689f773715074fc14420f16b0 (diff) | |
[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
| -rw-r--r-- | CMake/export.cmake | 22 | ||||
| -rw-r--r-- | CMake/resources.cmake | 56 | ||||
| -rw-r--r-- | CMake/setup.cmake | 2 | ||||
| -rw-r--r-- | configh.cmake.in | 14 | ||||
| -rw-r--r-- | configh.in | 7 |
5 files changed, 82 insertions, 19 deletions
diff --git a/CMake/export.cmake b/CMake/export.cmake index 4fe029ca4..cdf508a64 100644 --- a/CMake/export.cmake +++ b/CMake/export.cmake @@ -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 ) diff --git a/CMake/resources.cmake b/CMake/resources.cmake index 730f19070..0218813c9 100644 --- a/CMake/resources.cmake +++ b/CMake/resources.cmake @@ -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 diff --git a/CMake/setup.cmake b/CMake/setup.cmake index f63782556..c3cd00d13 100644 --- a/CMake/setup.cmake +++ b/CMake/setup.cmake @@ -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.") ####################################################################### diff --git a/configh.cmake.in b/configh.cmake.in index 15a6f0df8..4dff81b49 100644 --- a/configh.cmake.in +++ b/configh.cmake.in @@ -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: diff --git a/configh.in b/configh.in index a60a0ca63..9412de3c5 100644 --- a/configh.in +++ b/configh.in @@ -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: @@ -184,7 +183,7 @@ * * Byte order of your machine: 1 = big-endian, 0 = little-endian. */ - + #ifdef __APPLE__ #include <mac_endianness.h> #else |
