From 8c56fc7e225b0d8d6ab9b3f9e4bce6758151ec62 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Tue, 30 Nov 2010 10:34:43 +0000 Subject: [PATCH] Updated CMake files with patches from Michael Surette (STR #2317). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7919 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CMake/FLTKConfig.cmake.in | 13 +++- CMake/install-symlinks.cmake.in | 17 ++++++ CMakeLists.txt | 105 ++++++++++++++------------------ configh.cmake.in | 2 +- fltk-config.cmake.in | 6 +- src/Fl_Printer.cxx | 6 +- test/CMakeLists.txt | 2 +- test/device.cxx | 2 +- 8 files changed, 83 insertions(+), 70 deletions(-) create mode 100644 CMake/install-symlinks.cmake.in diff --git a/CMake/FLTKConfig.cmake.in b/CMake/FLTKConfig.cmake.in index 0501c6674..fb4f425ce 100644 --- a/CMake/FLTKConfig.cmake.in +++ b/CMake/FLTKConfig.cmake.in @@ -7,7 +7,7 @@ set(FLTK_FOUND TRUE) set(FLTK_VERSION @FLTK_VERSION_FULL@) -set(FLTK_FLUID_EXECUTABLE "@PREFIX_BIN@/fluid") +set(FLTK_FLUID_EXECUTABLE "@FLTK_FLUID_PATH@") if(NOT "@EXE_LINKER_FLAGS@" STREQUAL "") set(FLTK_EXE_LINKER_FLAGS "@EXE_LINKER_FLAGS@") @@ -35,4 +35,15 @@ set(FLTK_XINERAMA_FOUND @FLTK_XINERAMA_FOUND@) set(FLTK_XFT_FOUND @FLTK_XFT_FOUND@) set(FLTK_XDBE_FOUND @FLTK_XDBE_FOUND@) +set(FLTK_CAIRO_FOUND @FLTK_CAIRO_FOUND@) +set(FLTK_GL_FOUND @FLTK_GL_FOUND@) +set(FLTK_THREADS_FOUND @FLTK_THREADS_FOUND@) +set(FLTK_PTHREADS_FOUND @FLTK_PTHREADS_FOUND@) +set(FLTK_BUILTIN_JPEG_FOUND @FLTK_BUILTIN_JPEG_FOUND@) +set(FLTK_BUILTIN_ZLIB_FOUND @FLTK_BUILTIN_ZLIB_FOUND@) +set(FLTK_BUILTIN_PNG_FOUND @FLTK_BUILTIN_PNG_FOUND@) +set(FLTK_XINERAMA_FOUND @FLTK_XINERAMA_FOUND@) +set(FLTK_XFT_FOUND @FLTK_XFT_FOUND@) +set(FLTK_XDBE_FOUND @FLTK_XDBE_FOUND@) + include("@PREFIX_CONFIG@/FLTKLibraries.cmake") diff --git a/CMake/install-symlinks.cmake.in b/CMake/install-symlinks.cmake.in new file mode 100644 index 000000000..2febc1a53 --- /dev/null +++ b/CMake/install-symlinks.cmake.in @@ -0,0 +1,17 @@ + +# On unix create backward compatibility symlinks +if(NOT EXISTS @PREFIX_INCLUDE@/Fl) + EXECUTE_PROCESS(COMMAND ln -s FL Fl + WORKING_DIRECTORY @PREFIX_INCLUDE@ + ) +endif(NOT EXISTS @PREFIX_INCLUDE@/Fl) + +file(GLOB FLTK_HEADER_FILES @PREFIX_INCLUDE@/FL/*.H) +foreach(file ${FLTK_HEADER_FILES}) + GET_FILENAME_COMPONENT(nameWE ${file} NAME_WE) + if(NOT EXISTS @PREFIX_INCLUDE@/FL/${nameWE}.h) + EXECUTE_PROCESS(COMMAND ln -s ${nameWE}.H ${nameWE}.h + WORKING_DIRECTORY @PREFIX_INCLUDE@/FL + ) + endif() +endforeach(file) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5a14fe1c..bbbccf4c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,38 +46,11 @@ set(ARCHIVE_OUTPUT_PATH ${FLTK_BINARY_DIR}/lib) # Search for modules in the FLTK source dir first set(CMAKE_MODULE_PATH "${FLTK_SOURCE_DIR}/CMake") -include_directories(${FLTK_SOURCE_DIR} ${FLTK_BINARY_DIR}) - -# If this is out-of-source build, then copy FL directory -if(NOT ${FLTK_SOURCE_DIR} STREQUAL ${FLTK_BINARY_DIR}) - file(GLOB FLTK_HEADER_FILES ${FLTK_SOURCE_DIR}/FL/*.[hHr]) - foreach(file ${FLTK_HEADER_FILES}) - GET_FILENAME_COMPONENT(name ${file} NAME) - CONFIGURE_file(${file} ${FLTK_BINARY_DIR}/FL/${name} COPYONLY) - endforeach(file) -endif(NOT ${FLTK_SOURCE_DIR} STREQUAL ${FLTK_BINARY_DIR}) +include_directories(${FLTK_BINARY_DIR} ${FLTK_SOURCE_DIR}) ####################################################################### # platform dependent information ####################################################################### -# On unix create backward compatibility symlinks -if(CMAKE_HOST_UNIX) - if(NOT EXISTS ${FLTK_BINARY_DIR}/Fl) - EXECUTE_PROCESS(COMMAND ln -s FL Fl - WORKING_DIRECTORY ${FLTK_BINARY_DIR} - ) - endif(NOT EXISTS ${FLTK_BINARY_DIR}/Fl) - - file(GLOB FLTK_HEADER_FILES ${FLTK_BINARY_DIR}/FL/*.H) - foreach(file ${FLTK_HEADER_FILES}) - GET_FILENAME_COMPONENT(nameWE ${file} NAME_WE) - if(NOT EXISTS ${FLTK_BINARY_DIR}/FL/${nameWE}.h) - EXECUTE_PROCESS(COMMAND ln -s ${nameWE}.H ${nameWE}.h - WORKING_DIRECTORY ${FLTK_BINARY_DIR}/FL - ) - endif() - endforeach(file) -endif(CMAKE_HOST_UNIX) include(TestBigEndian) TEST_BIG_ENDIAN(WORDS_BIGENDIAN) @@ -135,10 +108,6 @@ endif(${SIZEOF_INT} MATCHES "^8$") ####################################################################### # check for headers, libraries and functions ####################################################################### -# set default search paths -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # headers find_file(HAVE_ALSA_ASOUNDLIB_H alsa/asoundlib.h) find_file(HAVE_DIRENT_H dirent.h) @@ -349,6 +318,7 @@ if(CMAKE_HOST_UNIX) set(PREFIX_MAN ${CMAKE_INSTALL_PREFIX}/man CACHE INTERNAL "" FORCE) endif(OPTION_PREFIX_MAN) + option(OPTION_CREATE_LINKS "create backwards compatibility links" OFF) endif(CMAKE_HOST_UNIX) ####################################################################### @@ -544,7 +514,7 @@ if(X11_Xinerama_FOUND) endif(X11_Xinerama_FOUND) if(OPTION_USE_XINERAMA) - set(HAVE_XINERAMA X11_Xinerama_FOUND) + set(HAVE_XINERAMA ${X11_Xinerama_FOUND}) include_directories(${X11_Xinerama_INCLUDE_PATH}) list(APPEND FLTK_LDLIBS -lXinerama) set(FLTK_XINERAMA_FOUND TRUE) @@ -561,7 +531,7 @@ if(OPTION_USE_XFT) set(USE_XFT X11_Xft_FOUND) list(APPEND FLTK_LDLIBS -lXft) set(FLTK_XFT_FOUND TRUE) -else() +else() set(FLTK_XFT_FOUND FALSE) endif(OPTION_USE_XFT) @@ -588,36 +558,40 @@ if(CMAKE_CROSSCOMPILING) NO_CMAKE_FIND_ROOT_PATH ) add_executable(fluid IMPORTED) - set(FLTK_FLUID_EXECUTABLE fluid) + set(FLTK_FLUID_EXECUTABLE ${FLUID_PATH}) set(FLTK_FLUID_PATH ${FLUID_PATH}) set_target_properties(fluid PROPERTIES IMPORTED_LOCATION ${FLUID_PATH} - ) + ) else() add_subdirectory(fluid) set(FLTK_FLUID_EXECUTABLE fluid) - set(FLTK_FLUID_PATH ${EXECUTABLE_OUTPUT_PATH}/${FLTK_FLUID_EXECUTABLE}) + set(FLTK_FLUID_PATH ${PREFIX_BIN}/fluid) endif(CMAKE_CROSSCOMPILING) add_subdirectory(src) # generate FLTKConfig.cmake string(REPLACE ";" " " EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") -configure_file(${FLTK_SOURCE_DIR}/CMake/FLTKConfig.cmake.in +configure_file( + ${FLTK_SOURCE_DIR}/CMake/FLTKConfig.cmake.in ${EXECUTABLE_OUTPUT_PATH}/FLTKConfig.cmake @ONLY - ) +) # generate UseFLTK.cmake -configure_file(${FLTK_SOURCE_DIR}/CMake/UseFLTK.cmake.in +configure_file( + ${FLTK_SOURCE_DIR}/CMake/UseFLTK.cmake.in ${EXECUTABLE_OUTPUT_PATH}/UseFLTK.cmake @ONLY - ) +) # generate config.h -configure_file("${FLTK_SOURCE_DIR}/configh.cmake.in" - "${FLTK_BINARY_DIR}/config.h" @ONLY - ) +configure_file( + "${FLTK_SOURCE_DIR}/configh.cmake.in" + "${FLTK_BINARY_DIR}/config.h" + @ONLY +) # generate fltk-config get_filename_component(CC ${CMAKE_C_COMPILER} NAME) @@ -630,24 +604,34 @@ if(X11_Xext_FOUND) endif(X11_Xext_FOUND) string(REPLACE ";" " " LD_LIBS "${FLTK_LDLIBS}") -configure_file(${FLTK_SOURCE_DIR}/fltk-config.cmake.in - ${FLTK_BINARY_DIR}/fltk-config - ) +configure_file( + "${FLTK_SOURCE_DIR}/fltk-config.cmake.in" + "${FLTK_BINARY_DIR}/fltk-config" + @ONLY +) if(UNIX) execute_process(COMMAND chmod 755 fltk-config - WORKING_DIRECTORY ${FLTK_BINARY_DIR} + WORKING_DIRECTORY "${FLTK_BINARY_DIR}" ) endif(UNIX) +if(OPTION_CREATE_LINKS) + configure_file( + "${FLTK_SOURCE_DIR}/CMake/install-symlinks.cmake.in" + "${FLTK_BINARY_DIR}/install-symlinks.cmake" + @ONLY + ) +endif(OPTION_CREATE_LINKS) + # generate uninstall target configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" @ONLY - ) +) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" - ) +) ####################################################################### # build examples - these have to be after fluid is built/imported @@ -660,31 +644,32 @@ endif(OPTION_BUILD_EXAMPLES) # installation ####################################################################### -install(DIRECTORY ${FLTK_BINARY_DIR}/FL +install(DIRECTORY ${FLTK_SOURCE_DIR}/FL DESTINATION ${PREFIX_INCLUDE} USE_SOURCE_PERMISSIONS - ) + PATTERN ".svn" EXCLUDE +) -install(DIRECTORY ${FLTK_BINARY_DIR}/Fl - DESTINATION ${PREFIX_INCLUDE} USE_SOURCE_PERMISSIONS - ) +if(OPTION_CREATE_LINKS) + install(SCRIPT ${FLTK_BINARY_DIR}/install-symlinks.cmake) +endif(OPTION_CREATE_LINKS) install(PROGRAMS ${FLTK_BINARY_DIR}/fltk-config DESTINATION ${PREFIX_BIN} OPTIONAL - ) +) install(EXPORT fltk-install DESTINATION ${PREFIX_CONFIG} FILE FLTKLibraries.cmake - ) +) install(FILES ${EXECUTABLE_OUTPUT_PATH}/FLTKConfig.cmake DESTINATION ${PREFIX_CONFIG} - ) +) install(FILES ${EXECUTABLE_OUTPUT_PATH}/UseFLTK.cmake DESTINATION ${PREFIX_CONFIG} - ) +) if(CMAKE_HOST_UNIX) macro(INSTALL_MAN FILE LEVEL) @@ -692,7 +677,7 @@ if(CMAKE_HOST_UNIX) ${FLTK_SOURCE_DIR}/documentation/src/${FILE}.man DESTINATION ${PREFIX_MAN}/man${LEVEL} RENAME ${FILE}.${LEVEL} - ) + ) endmacro(INSTALL_MAN FILE LEVEL) INSTALL_MAN(fluid 1) diff --git a/configh.cmake.in b/configh.cmake.in index 3c36761d1..9d45f5ae4 100644 --- a/configh.cmake.in +++ b/configh.cmake.in @@ -73,7 +73,7 @@ * Do you have the OpenGL glXGetProcAddressARB() function? */ -#cmakedefine HAVE_GLXGETPROCADDRESSARB +#cmakedefine HAVE_GLXGETPROCADDRESSARB %HAVE_GLXGETPROCADDRESSARB% /* * USE_COLORMAP: diff --git a/fltk-config.cmake.in b/fltk-config.cmake.in index a0b1dac41..4159a65da 100644 --- a/fltk-config.cmake.in +++ b/fltk-config.cmake.in @@ -59,9 +59,9 @@ OPTIM="@OPTION_OPTIM@" CAIROFLAGS="@CAIROFLAGS@" # Check for local invocation, and update paths accordingly... -if test -f "$selfdir/FL/Fl_Window.H"; then - bindir="$selfdir/fluid" - includedir="$selfdir" +if test -f "$selfdir/bin/UseFLTK.cmake"; then + bindir="$selfdir/bin/fluid" + includedir="@FLTK_SOURCE_DIR@" libdir="$selfdir/lib" if test -f "$libdir/libfltk_jpeg.a"; then diff --git a/src/Fl_Printer.cxx b/src/Fl_Printer.cxx index bef1c25a3..7ac7bf203 100644 --- a/src/Fl_Printer.cxx +++ b/src/Fl_Printer.cxx @@ -29,12 +29,12 @@ #include #ifdef __APPLE__ -#include +#include "Fl_Quartz_Printer.mm" #elif defined(WIN32) -#include +#include "Fl_GDI_Printer.cxx" #endif -#include +#include "Fl_PostScript.cxx" // print dialog customization strings /** [this text may be customized at run-time] */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6cdf0b67b..969b3d642 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,7 +3,7 @@ set(EXECUTABLE_OUTPUT_PATH ${FLTK_BINARY_DIR}/bin/examples) ####################################################################### # audio libs for test apps if(WIN32) - set(AUDIOLIBS -lwinmm) + set(AUDIOLIBS winmm) elseif(APPLE) set(AUDIOLIBS "-framework CoreAudio") elseif(HAVE_ALSA_ASOUNDLIB_H) diff --git a/test/device.cxx b/test/device.cxx index 4a6cf7171..bd613a238 100644 --- a/test/device.cxx +++ b/test/device.cxx @@ -23,7 +23,7 @@ #include #include #include -#include +#include "pixmaps/porsche.xpm" #include #include #include