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 /CMake/resources.cmake | |
| 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
Diffstat (limited to 'CMake/resources.cmake')
| -rw-r--r-- | CMake/resources.cmake | 56 |
1 files changed, 48 insertions, 8 deletions
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 |
