summaryrefslogtreecommitdiff
path: root/CMake/install.cmake
blob: 9dfe6566fb58c54490fd0ef2156fdfce02a4376e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#
# Installation support for building the FLTK project using CMake (www.cmake.org)
# Originally written by Michael Surette
#
# Copyright 1998-2025 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:
#
#     https://www.fltk.org/COPYING.php
#
# Please see the following page on how to report bugs and issues:
#
#     https://www.fltk.org/bugs.php
#

#######################################################################
# installation
#######################################################################

# 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"
)

install(DIRECTORY
  ${CMAKE_CURRENT_SOURCE_DIR}/FL
  DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS
  FILES_MATCHING
    PATTERN "*.[hH]"
    PATTERN "fl_config.h" EXCLUDE
)

install(DIRECTORY
  ${CMAKE_CURRENT_BINARY_DIR}/FL
  DESTINATION ${FLTK_INCLUDEDIR} USE_SOURCE_PERMISSIONS
  FILES_MATCHING
    PATTERN "*.[hH]"
)

if(FLTK_INSTALL_LINKS)
  install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/install-symlinks.cmake)
endif(FLTK_INSTALL_LINKS)

# generate FLTKConfig.cmake for installed directory use
set(INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
if(FLTK_HAVE_CAIRO)
  list(APPEND INCLUDE_DIRS ${PKG_CAIRO_INCLUDE_DIRS})
endif()

set(CONFIG_PATH ${CMAKE_INSTALL_PREFIX}/${FLTK_CONFIG_PATH})

install(EXPORT FLTK-Targets
  DESTINATION ${FLTK_CONFIG_PATH}
  FILE FLTK-Targets.cmake
  NAMESPACE fltk::
)

configure_file(
  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTKConfig.cmake.in
  ${CMAKE_CURRENT_BINARY_DIR}/etc/FLTKConfig.cmake
  @ONLY
)

install(FILES
  ${CMAKE_CURRENT_BINARY_DIR}/etc/FLTKConfig.cmake
  DESTINATION ${FLTK_CONFIG_PATH}
)

install(FILES
  ${CMAKE_CURRENT_SOURCE_DIR}/CMake/FLTK-Functions.cmake
  DESTINATION ${FLTK_CONFIG_PATH}
)

# Generate fltk-config

set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set(BINARY_DIR)
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
set(srcdir ".")

set(LIBNAME "${libdir}/libfltk.a")

configure_file(
  "${CMAKE_CURRENT_SOURCE_DIR}/fltk-config.in"
  "${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-config"
  @ONLY
)

# Install fltk-config
# Note: no need to set execute perms, install(PROGRAMS) does this

install(PROGRAMS
  ${CMAKE_CURRENT_BINARY_DIR}/bin/fltk-config
  DESTINATION ${FLTK_BINDIR}
)

# Install man pages of fluid and fltk-options

macro(INSTALL_MAN FILE LEVEL)
  install(FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/documentation/src/${FILE}.man
    DESTINATION ${FLTK_MANDIR}/man${LEVEL}
    RENAME ${FILE}.${LEVEL}
  )
endmacro(INSTALL_MAN FILE LEVEL)

if(FLTK_BUILD_FLUID)
  INSTALL_MAN (fluid 1)
endif(FLTK_BUILD_FLUID)
if(FLTK_BUILD_FLTK_OPTIONS)
  INSTALL_MAN (fltk-options 1)
endif(FLTK_BUILD_FLTK_OPTIONS)
INSTALL_MAN (fltk-config 1)
INSTALL_MAN (fltk 3)

# Install the games

if(FLTK_BUILD_TEST) # "OR FLTK_BUILD_GAMES" (not yet implemented)

  set(games_ blocks checkers sudoku)
  if(FLTK_USE_GL)
    list(APPEND games_ glpuzzle)
  endif()

  foreach(game_ ${games_})
    if(FLTK_BUILD_SHARED_LIBS)
      set(tgt_ "${game_}-shared")
      set_target_properties(${tgt_} PROPERTIES RUNTIME_OUTPUT_NAME ${game_})
    else()
      set(tgt_ ${game_})
    endif()
    install(TARGETS ${tgt_}
            EXPORT  FLTK-Targets
            RUNTIME DESTINATION ${FLTK_BINDIR}
            LIBRARY DESTINATION ${FLTK_LIBDIR}
            ARCHIVE DESTINATION ${FLTK_LIBDIR}
            BUNDLE  DESTINATION ${FLTK_BINDIR} # macOS: bundles
    )
    # install man page
    INSTALL_MAN (${game_} 6)
  endforeach()
  unset(game_)
  unset(games_)
endif()