[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
This commit is contained in:
Albrecht Schlosser 2015-02-16 14:30:27 +00:00
parent a5fcc0a91f
commit 6390a0e09e
11 changed files with 120 additions and 35 deletions

View File

@ -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"

View File

@ -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)

View File

@ -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))

View File

@ -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}")

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -6,5 +6,5 @@ Exec=fluid %F
Icon=fluid
Terminal=false
Type=Application
MimeType=application/x-fluid
MimeType=application/x-fluid;
Categories=Development;GUIDesigner;

7
fluid/fluid.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-fluid">
<comment>FLUID GUI Design</comment>
<glob pattern="*.fl"/>
</mime-type>
</mime-info>

View File

@ -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