-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
143 lines (127 loc) · 4.01 KB
/
CMakeLists.txt
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
cmake_minimum_required(
VERSION 3.26)
project(AdaptationPathways
LANGUAGES NONE
VERSION 0.0.10
DESCRIPTION "Adaptation Pathways TODO"
HOMEPAGE_URL "https://publicwiki.deltares.nl/display/AP/Adaptation+Pathways"
)
enable_testing()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/environment/cmake)
find_package(CairoSVG REQUIRED)
find_package(PyInstaller REQUIRED)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
find_package(QtTools)
find_package(Quarto)
find_package(Sphinx REQUIRED)
set(AP_PLOT_GRAPHS
"${CMAKE_CURRENT_SOURCE_DIR}/source/script/ap_plot_graphs.py"
)
set(AP_PYTHONPATH
"${PROJECT_SOURCE_DIR}/source/package"
"$ENV{PYTHONPATH}"
)
cmake_path(CONVERT "${AP_PYTHONPATH}" TO_NATIVE_PATH_LIST AP_PYTHONPATH)
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} AP_HOST_SYSTEM_NAME_LOWER_CASE)
add_subdirectory(documentation)
if(Quarto_FOUND)
add_subdirectory(presentation)
endif()
add_subdirectory(source)
add_custom_target(logo
VERBATIM
COMMAND
${CMAKE_COMMAND} -E env "PYTHONPATH=${AP_PYTHONPATH}"
# Creates logo.{pdf,svg}
${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/environment/create_logo.py logo
)
add_custom_target(icon
VERBATIM
COMMAND
# cairosvg logo.svg -o icon.png
${CMAKE_COMMAND} -E env "PYTHONPATH=${AP_PYTHONPATH}"
${Python3_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/environment/script/ap_svg_to_png.py logo.svg icon.png
COMMAND
${Python3_EXECUTABLE} -c "from PIL import Image; img = Image.open('icon.png'); img.save('icon.ico'); img.save('icon.icns')"
DEPENDS
logo
)
if(WIN32)
set(AP_ICON icon.ico)
elseif(APPLE)
set(AP_ICON icon.icns)
else()
set(AP_ICON icon.png)
endif()
set(AP_ICON ${CMAKE_CURRENT_SOURCE_DIR}/source/package/adaptation_pathways/desktop/icon/${AP_ICON})
configure_file(
adaptation_pathways.spec.in
adaptation_pathways.spec
@ONLY
)
add_custom_target(package
VERBATIM
COMMAND
${CMAKE_COMMAND} -E env "PYTHONPATH=${AP_PYTHONPATH}"
${Python3_EXECUTABLE}
-m build
--wheel
--outdir ${CMAKE_CURRENT_BINARY_DIR}/dist
${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(release
# VERBATIM
COMMAND
${CMAKE_COMMAND} -E rm -rf adaptation_pathways-${CMAKE_PROJECT_VERSION}
COMMAND
${CMAKE_COMMAND} -E make_directory
adaptation_pathways-${CMAKE_PROJECT_VERSION}/dist
adaptation_pathways-${CMAKE_PROJECT_VERSION}/documentation/html
COMMAND
${CMAKE_COMMAND} -E copy
"dist/*-${CMAKE_PROJECT_VERSION}-*.whl"
adaptation_pathways-${CMAKE_PROJECT_VERSION}/dist
COMMAND
${CMAKE_COMMAND} -E copy_directory
documentation/html
adaptation_pathways-${CMAKE_PROJECT_VERSION}/documentation/html
COMMAND
${CMAKE_COMMAND} -E tar "cf"
"adaptation_pathways-${CMAKE_PROJECT_VERSION}.zip" --format=zip --
adaptation_pathways-${CMAKE_PROJECT_VERSION}
COMMAND
${CMAKE_COMMAND} -E rm -rf adaptation_pathways-${CMAKE_PROJECT_VERSION}
)
add_dependencies(release
test
documentation
package
)
add_custom_target(installer
VERBATIM
COMMAND
${CMAKE_COMMAND} -E env "PYTHONPATH=${AP_PYTHONPATH}"
${PyInstaller_EXECUTABLE}
--noconfirm
adaptation_pathways.spec
DEPENDS
adaptation_pathways.spec
# icon
)
add_custom_target(installer_release
VERBATIM
COMMAND
${CMAKE_COMMAND} -E rm -rf pathway_generator-${CMAKE_PROJECT_VERSION}
COMMAND
${CMAKE_COMMAND} -E copy_directory
"dist/pathway_generator"
pathway_generator-${CMAKE_PROJECT_VERSION}
COMMAND
${CMAKE_COMMAND} -E tar "cf"
"pathway_generator-${AP_HOST_SYSTEM_NAME_LOWER_CASE}-${CMAKE_PROJECT_VERSION}.zip" --format=zip --
pathway_generator-${CMAKE_PROJECT_VERSION}
)
add_dependencies(installer_release
installer
)