From 6390a0e09e0a394c2323a65a823886eb91281ba1 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 16 Feb 2015 14:30:27 +0000 Subject: [PATCH] [CMake] Improve installation, support DESTDIR, and more (STR #3149). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10580 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CMake/export.cmake | 28 +++++++++++++++++++++- CMake/install-symlinks.cmake.in | 14 +++++------ CMake/install.cmake | 10 ++++---- CMake/macros.cmake | 8 +++---- CMake/setup.cmake | 31 ++++++++++++++++++++++--- CMakeLists.txt | 2 +- fltk-config.cmake.in | 4 ++-- fluid/CMakeLists.txt | 41 ++++++++++++++++++++++++++++++--- fluid/fluid.desktop | 2 +- fluid/fluid.xml | 7 ++++++ fluid/x-fluid.desktop | 8 ------- 11 files changed, 120 insertions(+), 35 deletions(-) create mode 100644 fluid/fluid.xml delete mode 100644 fluid/x-fluid.desktop diff --git a/CMake/export.cmake b/CMake/export.cmake index 2e1d2640e..bc19a1d89 100644 --- a/CMake/export.cmake +++ b/CMake/export.cmake @@ -4,7 +4,7 @@ # Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org) # Written by Michael Surette # -# Copyright 1998-2010 by Bill Spitzak and others. +# Copyright 1998-2015 by Bill Spitzak and others. # # This library is free software. Distribution and use rights are outlined in # the file "COPYING" which should have been included with this file. If this @@ -69,6 +69,26 @@ configure_file( ) # generate fltk-config +# Set install locations; this could be shortened with a foreach loop... +if(IS_ABSOLUTE ${FLTK_INSTALL_BINDIR}) + set(FLTK_FULL_BINDIR ${FLTK_BINDIR}) +else() + set(FLTK_FULL_BINDIR ${CMAKE_INSTALL_PREFIX}/${FLTK_BINDIR}) +endif(IS_ABSOLUTE ${FLTK_INSTALL_BINDIR}) + +if(IS_ABSOLUTE ${FLTK_INCLUDEDIR}) + set(FLTK_FULL_INCLUDEDIR ${FLTK_INCLUDEDIR}) +else() + set(FLTK_FULL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX}/${FLTK_INCLUDEDIR}) +endif(IS_ABSOLUTE ${FLTK_INCLUDEDIR}) + +if(IS_ABSOLUTE ${FLTK_LIBDIR}) + set(FLTK_FULL_LIBDIR ${FLTK_LIBDIR}) +else() + set(FLTK_FULL_LIBDIR ${CMAKE_INSTALL_PREFIX}/${FLTK_LIBDIR}) +endif(IS_ABSOLUTE ${FLTK_LIBDIR}) + +# set compiler get_filename_component(CC ${CMAKE_C_COMPILER} NAME) get_filename_component(CXX ${CMAKE_CXX_COMPILER} NAME) @@ -91,6 +111,12 @@ if(UNIX) endif(UNIX) if(OPTION_CREATE_LINKS) + # Set PREFIX_INCLUDE to the proper value. + if(IS_ABSOLUTE ${FLTK_INCLUDEDIR}) + set(PREFIX_INCLUDE ${FLTK_INCLUDEDIR}) + else() + set(PREFIX_INCLUDE "${CMAKE_INSTALL_PREFIX}/${FLTK_INCLUDEDIR}") + endif(IS_ABSOLUTE ${FLTK_INCLUDEDIR}) configure_file( "${FLTK_SOURCE_DIR}/CMake/install-symlinks.cmake.in" "${FLTK_BINARY_DIR}/install-symlinks.cmake" diff --git a/CMake/install-symlinks.cmake.in b/CMake/install-symlinks.cmake.in index 2febc1a53..fe33bc271 100644 --- a/CMake/install-symlinks.cmake.in +++ b/CMake/install-symlinks.cmake.in @@ -1,17 +1,17 @@ # On unix create backward compatibility symlinks -if(NOT EXISTS @PREFIX_INCLUDE@/Fl) +if(NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/Fl) EXECUTE_PROCESS(COMMAND ln -s FL Fl - WORKING_DIRECTORY @PREFIX_INCLUDE@ + WORKING_DIRECTORY $ENV{DESTDIR}@PREFIX_INCLUDE@ ) -endif(NOT EXISTS @PREFIX_INCLUDE@/Fl) +endif(NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/Fl) -file(GLOB FLTK_HEADER_FILES @PREFIX_INCLUDE@/FL/*.H) +file(GLOB FLTK_HEADER_FILES $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/*.H) foreach(file ${FLTK_HEADER_FILES}) GET_FILENAME_COMPONENT(nameWE ${file} NAME_WE) - if(NOT EXISTS @PREFIX_INCLUDE@/FL/${nameWE}.h) + if(NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/${nameWE}.h) EXECUTE_PROCESS(COMMAND ln -s ${nameWE}.H ${nameWE}.h - WORKING_DIRECTORY @PREFIX_INCLUDE@/FL + WORKING_DIRECTORY $ENV{DESTDIR}@PREFIX_INCLUDE@/FL ) - endif() + endif(NOT EXISTS $ENV{DESTDIR}@PREFIX_INCLUDE@/FL/${nameWE}.h) endforeach(file) diff --git a/CMake/install.cmake b/CMake/install.cmake index 2e8f76c96..3d3df3e7a 100644 --- a/CMake/install.cmake +++ b/CMake/install.cmake @@ -4,7 +4,7 @@ # Main CMakeLists.txt to build the FLTK project using CMake (www.cmake.org) # Written by Michael Surette # -# Copyright 1998-2010 by Bill Spitzak and others. +# Copyright 1998-2015 by Bill Spitzak and others. # # This library is free software. Distribution and use rights are outlined in # the file "COPYING" which should have been included with this file. If this @@ -32,7 +32,7 @@ add_custom_target(uninstall ) install(DIRECTORY ${FLTK_SOURCE_DIR}/FL - DESTINATION include USE_SOURCE_PERMISSIONS + DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS PATTERN ".svn" EXCLUDE ) @@ -70,11 +70,11 @@ install(FILES ${FLTK_BINARY_DIR}/etc/UseFLTK.cmake DESTINATION ${FLTK_CONFIG_PATH} ) -if(UNIX) +if(UNIX OR MSYS OR (MINGW AND CMAKE_CROSSCOMPILING)) macro(INSTALL_MAN FILE LEVEL) install(FILES ${FLTK_SOURCE_DIR}/documentation/src/${FILE}.man - DESTINATION share/man/man${LEVEL} + DESTINATION ${FLTK_MANDIR}/man${LEVEL} RENAME ${FILE}.${LEVEL} ) endmacro(INSTALL_MAN FILE LEVEL) @@ -86,4 +86,4 @@ if(UNIX) INSTALL_MAN(checkers 6) INSTALL_MAN(sudoku 6) -endif(UNIX) +endif(UNIX OR MSYS OR (MINGW AND CMAKE_CROSSCOMPILING)) diff --git a/CMake/macros.cmake b/CMake/macros.cmake index 545e88ffe..e4c5db807 100644 --- a/CMake/macros.cmake +++ b/CMake/macros.cmake @@ -4,7 +4,7 @@ # macros.cmake defines macros used by the build system # Written by Michael Surette # -# Copyright 1998-2014 by Bill Spitzak and others. +# Copyright 1998-2015 by Bill Spitzak and others. # # This library is free software. Distribution and use rights are outlined in # the file "COPYING" which should have been included with this file. If this @@ -65,9 +65,9 @@ macro(FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES) install(TARGETS ${LIBRARY_NAME} EXPORT FLTK-Targets - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + RUNTIME DESTINATION ${FLTK_BINDIR} + LIBRARY DESTINATION ${FLTK_LIBDIR} + ARCHIVE DESTINATION ${FLTK_LIBDIR} ) list(APPEND FLTK_LIBRARIES "${LIBRARY_NAME}") diff --git a/CMake/setup.cmake b/CMake/setup.cmake index b720f48fa..d5ec27d68 100644 --- a/CMake/setup.cmake +++ b/CMake/setup.cmake @@ -4,7 +4,7 @@ # CMakeLists.txt to build the FLTK project using CMake (www.cmake.org) # Written by Michael Surette # -# Copyright 1998-2014 by Bill Spitzak and others. +# Copyright 1998-2015 by Bill Spitzak and others. # # This library is free software. Distribution and use rights are outlined in # the file "COPYING" which should have been included with this file. If this @@ -37,6 +37,31 @@ set(CMAKE_MODULE_PATH "${FLTK_SOURCE_DIR}/CMake") set(FLTK_INCLUDE_DIRS ${FLTK_BINARY_DIR} ${FLTK_SOURCE_DIR}) include_directories(${FLTK_INCLUDE_DIRS}) +# Setup install locations +if(CMAKE_VERSION VERSION_GREATER 2.8.4) + # Use GNUInstallDirs if available. + include(GNUInstallDirs) +else() + # Else set reasonable defaults. + set(CMAKE_INSTALL_BINDIR bin) + set(CMAKE_INSTALL_LIBDIR lib) + set(CMAKE_INSTALL_INCLUDEDIR include) + set(CMAKE_INSTALL_DATADIR share) + set(CMAKE_INSTALL_MANDIR share/man) +endif(CMAKE_VERSION VERSION_GREATER 2.8.4) + +set(FLTK_BINDIR ${CMAKE_INSTALL_BINDIR} CACHE PATH + "Binary install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.") +set(FLTK_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH + "Library install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.") +set(FLTK_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH + "Public header install path relative to CMAKE_INSTALL_PREFIX unless set to an absolute path.") +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.") + + ####################################################################### # platform dependent information ####################################################################### @@ -58,8 +83,8 @@ elseif(APPLE) set(FLTK_CONFIG_PATH FLTK/.framework/Resources/CMake) set(FLTK_EXAMPLES_PATH share/fltk-examples) else() - set(FLTK_CONFIG_PATH lib/fltk) - set(FLTK_EXAMPLES_PATH share/fltk-examples) + set(FLTK_CONFIG_PATH ${FLTK_LIBDIR}/fltk) + set(FLTK_EXAMPLES_PATH ${FLTK_DATADIR}/fltk-examples) endif(WIN32 AND NOT CYGWIN) include(TestBigEndian) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71bd61a0c..bb05e339e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ include(CMake/options.cmake) include(CMake/export.cmake) ####################################################################### -# build examples - these have to be after fluid is built/imported +# build examples - these have to be built after fluid is built/imported ####################################################################### if(OPTION_BUILD_EXAMPLES) add_subdirectory(test) diff --git a/fltk-config.cmake.in b/fltk-config.cmake.in index 93e666ab4..5743c3b46 100644 --- a/fltk-config.cmake.in +++ b/fltk-config.cmake.in @@ -31,8 +31,8 @@ selfdir=`dirname "$0"` prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} exec_prefix_set=no -includedir=@PREFIX_INCLUDE@ -libdir=@PREFIX_LIB@ +includedir=@FLTK_FULL_INCLUDEDIR@ +libdir=@FLTK_FULL_LIBDIR@ srcdir=. # compiler names diff --git a/fluid/CMakeLists.txt b/fluid/CMakeLists.txt index 25424a8bf..f2b2aa82e 100644 --- a/fluid/CMakeLists.txt +++ b/fluid/CMakeLists.txt @@ -1,3 +1,20 @@ +# +# "$Id$" +# +# CMakeLists.txt to build fluid for the FLTK project using CMake (www.cmake.org) +# +# Copyright 1998-2015 by Bill Spitzak and others. +# +# This library is free software. Distribution and use rights are outlined in +# the file "COPYING" which should have been included with this file. If this +# file is missing or damaged, see the license at: +# +# http://www.fltk.org/COPYING.php +# +# Please report all bugs and problems on the following page: +# +# http://www.fltk.org/str.php +# set(CPPFILES CodeEditor.cxx @@ -35,7 +52,25 @@ endif(HAVE_XINERAMA) install(TARGETS fluid EXPORT FLTK-Targets - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib + RUNTIME DESTINATION ${FLTK_BINDIR} + LIBRARY DESTINATION ${FLTK_LIBDIR} + ARCHIVE DESTINATION ${FLTK_LIBDIR} ) + +if(UNIX) + install(FILES fluid.desktop + DESTINATION ${FLTK_DATADIR}/applications + ) + # Install mime-type file. x-fluid.desktop method is deprecated. + install(FILES fluid.xml + DESTINATION ${FLTK_DATADIR}/mime/packages + ) + + # Install desktop icons. + foreach(icon 32 48 64 128) + install(FILES icons/fluid-${icon}.png + DESTINATION ${FLTK_DATADIR}/icons/hicolor/${icon}x${icon}/apps + RENAME fluid.png + ) + endforeach() +endif(UNIX) diff --git a/fluid/fluid.desktop b/fluid/fluid.desktop index 4f807d826..eb930bc30 100644 --- a/fluid/fluid.desktop +++ b/fluid/fluid.desktop @@ -6,5 +6,5 @@ Exec=fluid %F Icon=fluid Terminal=false Type=Application -MimeType=application/x-fluid +MimeType=application/x-fluid; Categories=Development;GUIDesigner; diff --git a/fluid/fluid.xml b/fluid/fluid.xml new file mode 100644 index 000000000..b4581f23e --- /dev/null +++ b/fluid/fluid.xml @@ -0,0 +1,7 @@ + + + + FLUID GUI Design + + + diff --git a/fluid/x-fluid.desktop b/fluid/x-fluid.desktop deleted file mode 100644 index 994e6443c..000000000 --- a/fluid/x-fluid.desktop +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Type=MimeType -MimeType=application/x-fluid -Icon=fluid.png -Patterns=*.fl -Name=FLUID -Comment=FLUID GUI Design -Encoding=UTF-8