From 1ca225e19da3653cba2cd94543ab3f9019e83f3f Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 13 Sep 2004 02:12:41 +0000 Subject: Added (unsupported) CMake files (STR #499) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@3829 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CMake/CheckFunctionWithHeaderExists.cmake | 54 +++++++++++++++++++++ CMake/FLTKConfig.cmake.in | 32 ++++++++++++ CMake/PlatformTests.cxx | 81 +++++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+) create mode 100644 CMake/CheckFunctionWithHeaderExists.cmake create mode 100644 CMake/FLTKConfig.cmake.in create mode 100644 CMake/PlatformTests.cxx (limited to 'CMake') diff --git a/CMake/CheckFunctionWithHeaderExists.cmake b/CMake/CheckFunctionWithHeaderExists.cmake new file mode 100644 index 000000000..7d824cd96 --- /dev/null +++ b/CMake/CheckFunctionWithHeaderExists.cmake @@ -0,0 +1,54 @@ +# +# Check if the symbol exists in include files +# +# CHECK_FUNCTIONWITHHEADER_EXISTS - macro which checks the symbol exists in include files. +# SYMBOL - symbol +# FILES - include files to check +# VARIABLE - variable to return result +# + +MACRO(CHECK_FUNCTIONWITHHEADER_EXISTS SYMBOL FILES VARIABLE) + IF("${VARIABLE}" MATCHES "^${VARIABLE}$") + SET(CHECK_SYMBOL_EXISTS_CONTENT "/* */\n") + SET(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS}) + IF(CMAKE_REQUIRED_LIBRARIES) + SET(CHECK_SYMBOL_EXISTS_LIBS + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + ENDIF(CMAKE_REQUIRED_LIBRARIES) + FOREACH(FILE ${FILES}) + SET(CHECK_SYMBOL_EXISTS_CONTENT + "${CHECK_SYMBOL_EXISTS_CONTENT}#include <${FILE}>\n") + ENDFOREACH(FILE) + SET(CHECK_SYMBOL_EXISTS_CONTENT + "${CHECK_SYMBOL_EXISTS_CONTENT}\nint main()\n{\n${SYMBOL};return 0;\n}\n") + + FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c + "${CHECK_SYMBOL_EXISTS_CONTENT}") + + MESSAGE(STATUS "Looking for ${SYMBOL}") + TRY_COMPILE(${VARIABLE} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c + CMAKE_FLAGS + -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS} + "${CHECK_SYMBOL_EXISTS_LIBS}" + OUTPUT_VARIABLE OUTPUT) + IF(${VARIABLE}) + MESSAGE(STATUS "Looking for ${SYMBOL} - found") + SET(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL}") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log + "Determining if the ${SYMBOL} " + "exist passed with the following output:\n" + "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c:\n" + "${CHECK_SYMBOL_EXISTS_CONTENT}\n") + ELSE(${VARIABLE}) + MESSAGE(STATUS "Looking for ${SYMBOL} - not found.") + SET(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}") + FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log + "Determining if the ${SYMBOL} " + "exist failed with the following output:\n" + "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckSymbolExists.c:\n" + "${CHECK_SYMBOL_EXISTS_CONTENT}\n") + ENDIF(${VARIABLE}) + ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$") +ENDMACRO(CHECK_FUNCTIONWITHHEADER_EXISTS) diff --git a/CMake/FLTKConfig.cmake.in b/CMake/FLTKConfig.cmake.in new file mode 100644 index 000000000..3f53597cc --- /dev/null +++ b/CMake/FLTKConfig.cmake.in @@ -0,0 +1,32 @@ +#----------------------------------------------------------------------------- +# +# FLTKConfig.cmake - FLTK CMake configuration file for external projects. +# +# This file is configured by FLTK and used by the UseFLTK.cmake module +# to load FLTK's settings for an external project. + +# The FLTK source tree. +SET(FLTK_SOURCE_DIR "@FLTK_SOURCE_DIR@") + +# The FLTK include file directories. +SET(FLTK_EXECUTABLE_DIRS "@FLTK_EXECUTABLE_DIRS@") +SET(FLTK_LIBRARY_DIRS "@FLTK_LIBRARY_DIRS@") +SET(FLTK_LIBRARIES "fltk_images;fltk;fltk_gl;fltk_forms") + +# The C and C++ flags added by FLTK to the cmake-configured flags. +SET(FLTK_REQUIRED_C_FLAGS "@FLTK_REQUIRED_C_FLAGS@") +SET(FLTK_REQUIRED_CXX_FLAGS "@FLTK_REQUIRED_CXX_FLAGS@") + +# The FLTK version number +SET(FLTK_VERSION_MAJOR "@FLTK_VERSION_MAJOR@") +SET(FLTK_VERSION_MINOR "@FLTK_VERSION_MINOR@") +SET(FLTK_VERSION_PATCH "@FLTK_VERSION_PATCH@") + +# The location of the UseFLTK.cmake file. +SET(FLTK_USE_FILE "@FLTK_USE_FILE@") + +# The build settings file. +SET(FLTK_BUILD_SETTINGS_FILE "@FLTK_BUILD_SETTINGS_FILE@") + +# Whether FLTK was built with shared libraries. +SET(FLTK_BUILD_SHARED "@BUILD_SHARED_LIBS@") diff --git a/CMake/PlatformTests.cxx b/CMake/PlatformTests.cxx new file mode 100644 index 000000000..828a93eb2 --- /dev/null +++ b/CMake/PlatformTests.cxx @@ -0,0 +1,81 @@ +#ifdef HAVE_LIBZ + +#include + +int main() +{ + unsigned long compressedSize = 0; + unsigned char cd[100]; + const unsigned char ud[100] = ""; + unsigned long uncompressedSize = 0; + + // Call zlib's compress function. + if(compress(cd, &compressedSize, ud, uncompressedSize) != Z_OK) + { + return 0; + } + return 1; +} + + +#endif + +#ifdef HAVE_LIBJPEG + +#include +#include + +int main() +{ + struct jpeg_decompress_struct cinfo; + jpeg_create_decompress(&cinfo); + jpeg_read_header(&cinfo, TRUE); + return 1; +} + +#endif + +#ifdef HAVE_LIBPNG +#include +int main() +{ + png_structp png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)NULL, + NULL, NULL); + png_infop info_ptr = png_create_info_struct(png_ptr); + png_set_sig_bytes(png_ptr, 8); + png_read_info(png_ptr, info_ptr); + + return 0; +} +#endif + +#ifdef HAVE_PNG_H +#include +int main() { retunr 0;} +#endif + +#ifdef HAVE_PNG_GET_VALID +#include +int main() +{ + png_structp png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)NULL, + NULL, NULL); + png_infop info_ptr = png_create_info_struct(png_ptr); + png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS); + return 0; +} +#endif + +#ifdef HAVE_PNG_SET_TRNS_TO_ALPHA +#include +int main() +{ + png_structp png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)NULL, + NULL, NULL); + png_set_tRNS_to_alpha(png_ptr); + return 0; +} +#endif -- cgit v1.2.3