File: CMakeLists.txt

package info (click to toggle)
solvespace 3.0.rc2%2Brepack1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,136 kB
  • sloc: cpp: 121,426; ansic: 8,912; javascript: 1,919; sh: 113; xml: 44; makefile: 25
file content (294 lines) | stat: -rw-r--r-- 11,617 bytes parent folder | download
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# First, set up registration functions for the kinds of resources we handle.
set(resource_root ${CMAKE_CURRENT_SOURCE_DIR}/)
set(resource_list)
if(WIN32)
    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win32/versioninfo.rc.in
                   ${CMAKE_CURRENT_BINARY_DIR}/win32/versioninfo.rc)

    set(rc_file ${CMAKE_CURRENT_BINARY_DIR}/resources.rc)
    file(WRITE  ${rc_file} "// Autogenerated; do not edit\n")
    file(APPEND ${rc_file} "#include <windows.h>\n")
    file(APPEND ${rc_file} "#include \"${CMAKE_CURRENT_BINARY_DIR}/win32/versioninfo.rc\"\n")

    function(add_resource name)
        set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})

        if(${ARGC} GREATER 1)
            set(id ${ARGV1})
        else()
            string(REPLACE ${resource_root} "" id ${source})
        endif()
        if(${ARGC} GREATER 2)
            set(type ${ARGV2})
        else()
            set(type RCDATA)
        endif()
        file(SHA512 "${source}" hash)
        file(APPEND ${rc_file} "${id} ${type} \"${source}\" // ${hash}\n")
        # CMake doesn't track file dependencies across directories, so we force
        # a reconfigure (which changes the RC file because of the hash above)
        # every time a resource is changed.
        set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${source}")
    endfunction()
elseif(APPLE)
    set(app_resource_dir ${CMAKE_BINARY_DIR}/bin/SolveSpace.app/Contents/Resources)
    set(cli_resource_dir ${CMAKE_BINARY_DIR}/res)

    function(add_resource name)
        set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
        set(target_app ${app_resource_dir}/${name})
        set(target_cli ${cli_resource_dir}/${name})
        set(resource_list "${resource_list};${target_app};${target_cli}" PARENT_SCOPE)

        get_filename_component(target_app_dir ${target_app} DIRECTORY)
        get_filename_component(target_cli_dir ${target_cli} DIRECTORY)
        add_custom_command(
            OUTPUT ${target_app} ${target_cli}
            COMMAND ${CMAKE_COMMAND} -E make_directory ${target_app_dir}
            COMMAND ${CMAKE_COMMAND} -E copy ${source} ${target_app}
            COMMAND ${CMAKE_COMMAND} -E make_directory ${target_cli_dir}
            COMMAND ${CMAKE_COMMAND} -E copy ${source} ${target_cli}
            COMMENT "Copying resource ${name}"
            DEPENDS ${source}
            VERBATIM)
    endfunction()

    function(add_xib name)
        set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
        get_filename_component(basename ${name} NAME_WE)
        set(target ${app_resource_dir}/${basename}.nib)
        set(resource_list "${resource_list};${target}" PARENT_SCOPE)

        add_custom_command(
            OUTPUT ${target}
            COMMAND ${CMAKE_COMMAND} -E make_directory ${app_resource_dir}
            COMMAND ibtool --errors --warnings --notices --output-format human-readable-text
                --compile ${target} ${source}
            COMMENT "Building Interface Builder file ${name}"
            DEPENDS ${source}
            VERBATIM)
    endfunction()

    function(add_iconset name)
        set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
        get_filename_component(basename ${name} NAME_WE)
        set(target ${app_resource_dir}/${basename}.icns)
        set(resource_list "${resource_list};${target}" PARENT_SCOPE)

        add_custom_command(
            OUTPUT ${target}
            COMMAND ${CMAKE_COMMAND} -E make_directory ${app_resource_dir}
            COMMAND iconutil -c icns -o ${target} ${source}
            COMMENT "Building icon set ${name}"
            DEPENDS ${source}
            VERBATIM)
    endfunction()
else() # Unix
    include(GNUInstallDirs)

    set(app_resource_dir ${CMAKE_BINARY_DIR}/res)

    function(add_resource name)
        set(source ${CMAKE_CURRENT_SOURCE_DIR}/${name})
        set(target ${app_resource_dir}/${name})
        set(resource_list "${resource_list};${target}" PARENT_SCOPE)

        get_filename_component(target_dir ${target} DIRECTORY)
        add_custom_command(
            OUTPUT ${target}
            COMMAND ${CMAKE_COMMAND} -E make_directory ${target_dir}
            COMMAND ${CMAKE_COMMAND} -E copy ${source} ${target}
            COMMENT "Copying resource ${name}"
            DEPENDS ${source}
            VERBATIM)

        get_filename_component(name_dir ${name} DIRECTORY)
        install(FILES ${source}
            DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/solvespace/${name_dir})
    endfunction()
endif()

function(add_resources)
    foreach(name ${ARGN})
        add_resource(${name})
        set(resource_list "${resource_list}" PARENT_SCOPE)
    endforeach()
endfunction()

# Second, register all resources.
if(WIN32)
    add_resource(win32/icon.ico     4000 ICON)
    add_resource(win32/manifest.xml 1    RT_MANIFEST)
elseif(APPLE)
    add_iconset (cocoa/AppIcon.iconset)
    add_xib     (cocoa/MainMenu.xib)
    add_xib     (cocoa/SaveFormatAccessory.xib)
else()
    add_resource(freedesktop/solvespace-48x48.png)

    if(FLATPAK)
        configure_file(
            ${CMAKE_CURRENT_SOURCE_DIR}/freedesktop/solvespace-flatpak.desktop.in
            ${CMAKE_CURRENT_BINARY_DIR}/freedesktop/solvespace-flatpak.desktop)
        install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freedesktop/solvespace-flatpak.desktop
            DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications
            RENAME      com.solvespace.SolveSpace.desktop)

        install(FILES freedesktop/solvespace-flatpak-mime.xml
            DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/mime/packages
            RENAME      com.solvespace.SolveSpace-slvs.xml)

        install(FILES freedesktop/solvespace-scalable.svg
            DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps
            RENAME      com.solvespace.SolveSpace.svg)
        install(FILES freedesktop/solvespace-scalable.svg
            DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/mimetypes
            RENAME      com.solvespace.SolveSpace.svg)

        foreach(SIZE 16x16 24x24 32x32 48x48)
            install(FILES freedesktop/solvespace-${SIZE}.png
                DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}/apps
                RENAME      com.solvespace.SolveSpace.png)
            install(FILES freedesktop/solvespace-${SIZE}.png
                DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}/mimetypes
                RENAME      com.solvespace.SolveSpace.png)
        endforeach()
    elseif(SNAP)
        install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/freedesktop/solvespace-snap.desktop
            DESTINATION /
            RENAME      solvespace.desktop)
        
        # snapd does not support registering new mime types

        install(FILES freedesktop/solvespace-scalable.svg
            DESTINATION /meta/icons/hicolor/scalable/apps
            RENAME      snap.solvespace.svg)

        foreach(SIZE 16x16 24x24 32x32 48x48)
            install(FILES freedesktop/solvespace-${SIZE}.png
                DESTINATION /meta/icons/hicolor/${SIZE}/apps
                RENAME      snap.solvespace.png)
        endforeach()
    else()
        configure_file(
            ${CMAKE_CURRENT_SOURCE_DIR}/freedesktop/solvespace.desktop.in
            ${CMAKE_CURRENT_BINARY_DIR}/freedesktop/solvespace.desktop)
        install(FILES ${CMAKE_CURRENT_BINARY_DIR}/freedesktop/solvespace.desktop
            DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)

        install(FILES freedesktop/solvespace-mime.xml
            DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/mime/packages
            RENAME      solvespace-slvs.xml)
        
        install(FILES freedesktop/solvespace-scalable.svg
            DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/apps
            RENAME      solvespace.svg)
        install(FILES freedesktop/solvespace-scalable.svg
            DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/scalable/mimetypes
            RENAME      application.x-solvespace.svg)

        foreach(SIZE 16x16 24x24 32x32 48x48)
            install(FILES freedesktop/solvespace-${SIZE}.png
                DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}/apps
                RENAME      solvespace.png)
            install(FILES freedesktop/solvespace-${SIZE}.png
                DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/${SIZE}/mimetypes
                RENAME      application.x-solvespace.png)
        endforeach()

        foreach(SIZE 16x16 24x24 32x32 48x48)
            install(FILES freedesktop/solvespace-${SIZE}.xpm
                DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pixmaps)
        endforeach()
    endif()
endif()

add_resources(
    banner.txt
    icons/graphics-window/angle.png
    icons/graphics-window/arc.png
    icons/graphics-window/assemble.png
    icons/graphics-window/bezier.png
    icons/graphics-window/circle.png
    icons/graphics-window/construction.png
    icons/graphics-window/equal.png
    icons/graphics-window/extrude.png
    icons/graphics-window/helix.png
    icons/graphics-window/horiz.png
    icons/graphics-window/image.png
    icons/graphics-window/in3d.png
    icons/graphics-window/lathe.png
    icons/graphics-window/length.png
    icons/graphics-window/line.png
    icons/graphics-window/ontoworkplane.png
    icons/graphics-window/other-supp.png
    icons/graphics-window/parallel.png
    icons/graphics-window/perpendicular.png
    icons/graphics-window/pointonx.png
    icons/graphics-window/point.png
    icons/graphics-window/rectangle.png
    icons/graphics-window/ref.png
    icons/graphics-window/revolve.png
    icons/graphics-window/same-orientation.png
    icons/graphics-window/sketch-in-3d.png
    icons/graphics-window/sketch-in-plane.png
    icons/graphics-window/step-rotate.png
    icons/graphics-window/step-translate.png
    icons/graphics-window/symmetric.png
    icons/graphics-window/tangent-arc.png
    icons/graphics-window/text.png
    icons/graphics-window/trim.png
    icons/graphics-window/vert.png
    icons/text-window/constraint.png
    icons/text-window/construction.png
    icons/text-window/edges.png
    icons/text-window/faces.png
    icons/text-window/occluded-visible.png
    icons/text-window/occluded-stippled.png
    icons/text-window/occluded-invisible.png
    icons/text-window/mesh.png
    icons/text-window/normal.png
    icons/text-window/outlines.png
    icons/text-window/point.png
    icons/text-window/shaded.png
    icons/text-window/workplane.png
    locales.txt
    locales/de_DE.po
    locales/en_US.po
    locales/fr_FR.po
    locales/uk_UA.po
    locales/ru_RU.po
    locales/zh_CN.po
    fonts/private/0-check-false.png
    fonts/private/1-check-true.png
    fonts/private/2-radio-false.png
    fonts/private/3-radio-true.png
    fonts/private/4-stipple-dot.png
    fonts/private/5-stipple-dash-long.png
    fonts/private/6-stipple-dash.png
    fonts/private/7-stipple-zigzag.png
    fonts/unicode.lff.gz
    fonts/BitstreamVeraSans-Roman-builtin.ttf
    shaders/imesh.frag
    shaders/imesh.vert
    shaders/imesh_point.frag
    shaders/imesh_point.vert
    shaders/imesh_tex.frag
    shaders/imesh_texa.frag
    shaders/imesh_tex.vert
    shaders/mesh.frag
    shaders/mesh.vert
    shaders/mesh_fill.frag
    shaders/mesh_fill.vert
    shaders/edge.frag
    shaders/edge.vert
    shaders/outline.vert
    threejs/hammer-2.0.8.js.gz
    threejs/SolveSpaceControls.js)

# Third, distribute the resources.
add_custom_target(resources
    DEPENDS ${resource_list})
if(WIN32)
    set_property(TARGET resources PROPERTY EXTRA_SOURCES ${rc_file})
endif()