Skip to content

Commit 8716787

Browse files
Merge pull request #82 from QCDLab/gui
Add NeoPDF GUI Plotter
2 parents d84ea5d + debbeb1 commit 8716787

File tree

8 files changed

+685
-1
lines changed

8 files changed

+685
-1
lines changed

.github/workflows/release.yml

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
path: neopdf_capi-${{ matrix.target }}.tar.gz
152152

153153
publish-release:
154-
needs: [capi-macos, cli-macos, capi-linux, cli-linux]
154+
needs: [capi-macos, cli-macos, capi-linux, cli-linux, gui-macos, gui-linux]
155155
runs-on: ubuntu-latest
156156
if: "startsWith(github.ref, 'refs/tags/')"
157157
steps:
@@ -166,6 +166,77 @@ jobs:
166166
find artifacts -name 'neopdf_*' ! -name '*.whl' -type f -exec gh release upload v${version} {} +
167167
gh release edit v${version} --draft=false
168168
169+
gui-macos:
170+
needs: capi-macos
171+
strategy:
172+
matrix:
173+
include:
174+
- os: macos-13
175+
target: x86_64-apple-darwin
176+
- os: macos-14
177+
target: aarch64-apple-darwin
178+
runs-on: ${{ matrix.os }}
179+
steps:
180+
- uses: actions/checkout@v4
181+
- name: Install Qt
182+
run: brew install qt6
183+
- name: Set Qt path
184+
run: echo "CMAKE_PREFIX_PATH=$(brew --prefix qt6)" >> $GITHUB_ENV
185+
- name: Download capi artifact
186+
uses: actions/download-artifact@v4
187+
with:
188+
name: neopdf_capi-${{ matrix.target }}
189+
path: neopdf_capi_artifact
190+
- name: Build and package
191+
run: |
192+
mkdir capi_install
193+
tar -xzf neopdf_capi_artifact/neopdf_capi-${{ matrix.target }}.tar.gz -C capi_install
194+
export CARGO_C_INSTALL_PREFIX=$(pwd)/capi_install
195+
cmake -S neopdf_gui -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/install -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH
196+
cmake --build build --config Release
197+
cmake --install build
198+
cd install
199+
cpack
200+
- name: Upload artifact
201+
uses: actions/upload-artifact@v4
202+
with:
203+
name: neopdf_gui-${{ matrix.target }}
204+
path: install/*.dmg
205+
206+
gui-linux:
207+
needs: capi-linux
208+
runs-on: ubuntu-latest
209+
strategy:
210+
matrix:
211+
target: [x86_64-unknown-linux-gnu]
212+
steps:
213+
- uses: actions/checkout@v4
214+
- name: Install Qt and build essentials
215+
run: |
216+
sudo apt-get update
217+
sudo apt-get install -y build-essential qt6-base-dev qt6-charts-dev
218+
- name: Download capi artifact
219+
uses: actions/download-artifact@v4
220+
with:
221+
name: neopdf_capi-${{ matrix.target }}
222+
path: neopdf_capi_artifact
223+
- name: Build and package
224+
run: |
225+
mkdir capi_install
226+
tar -xzf neopdf_capi_artifact/neopdf_capi-${{ matrix.target }}.tar.gz -C capi_install
227+
export CARGO_C_INSTALL_PREFIX=$(pwd)/capi_install
228+
cmake -S neopdf_gui -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$(pwd)/install
229+
cmake --build build --config Release
230+
cmake --install build
231+
cd install
232+
cpack
233+
- name: Upload artifact
234+
uses: actions/upload-artifact@v4
235+
with:
236+
name: neopdf_gui-${{ matrix.target }}
237+
path: install/*.tar.gz
238+
239+
169240
publish-crates:
170241
runs-on: ubuntu-latest
171242
container: ghcr.io/qcdlab/neopdf-container:latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/target
2+
/neopdf_gui/build/
23
/neopdf_capi/docs/build/
34
/neopdf_capi/docs/xml/
45
/neopdf_capi/docs/html/

maintainer/make-release.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ sed -i \
6161
Cargo.toml
6262
git add Cargo.toml
6363

64+
# update GUI version
65+
sed -i "s/^project(neopdf_gui VERSION .*)/project(neopdf_gui VERSION ${version})/" neopdf_gui/CMakeLists.txt
66+
git add neopdf_gui/CMakeLists.txt
67+
6468
echo ">>> Updating Cargo.lock ..."
6569

6670
# update explicit version for `neopdf_tmdlib` in `neopdf_cli`

neopdf_gui/CMakeLists.txt

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(neopdf_gui VERSION 0.1.0)
3+
4+
set(CMAKE_CXX_STANDARD 17)
5+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
6+
7+
set(CMAKE_AUTOMOC ON)
8+
set(CMAKE_AUTOUIC ON)
9+
set(CMAKE_AUTORCC ON)
10+
11+
find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets Charts)
12+
13+
set(CARGO_C_INSTALL_PREFIX "$ENV{CARGO_C_INSTALL_PREFIX}")
14+
if(DEFINED CARGO_C_INSTALL_PREFIX AND NOT CARGO_C_INSTALL_PREFIX STREQUAL "")
15+
list(APPEND NEOPDF_CAPI_INCLUDE_SEARCH_PATHS "${CARGO_C_INSTALL_PREFIX}/include/neopdf_capi")
16+
list(APPEND NEOPDF_CAPI_LIBRARY_SEARCH_PATHS "${CARGO_C_INSTALL_PREFIX}/lib")
17+
else()
18+
message(FATAL_ERROR "CARGO_C_INSTALL_PREFIX must be specified.")
19+
endif()
20+
21+
find_path(
22+
NEOPDF_CAPI_INCLUDE_DIR
23+
NAMES NeoPDF.hpp neopdf_capi.h
24+
PATHS ${NEOPDF_CAPI_INCLUDE_SEARCH_PATHS}
25+
NO_DEFAULT_PATH
26+
)
27+
if(NOT NEOPDF_CAPI_INCLUDE_DIR)
28+
message(FATAL_ERROR "Could not find NeoPDF.hpp/neopdf_capi.h.")
29+
endif()
30+
31+
find_library(
32+
NEOPDF_CAPI_LIBRARY
33+
NAMES neopdf_capi
34+
PATHS ${NEOPDF_CAPI_LIBRARY_SEARCH_PATHS}
35+
NO_DEFAULT_PATH
36+
)
37+
if(NOT NEOPDF_CAPI_LIBRARY)
38+
message(FATAL_ERROR "Could not find libneopdf_capi.")
39+
endif()
40+
41+
message(STATUS "Found neopdf_capi library: ${NEOPDF_CAPI_LIBRARY}")
42+
message(STATUS "Found neopdf_capi include dir: ${NEOPDF_CAPI_INCLUDE_DIR}")
43+
44+
add_executable(neopdf_gui
45+
main.cpp
46+
MainWindow.cpp
47+
MainWindow.hpp
48+
)
49+
50+
if(APPLE)
51+
set_target_properties(neopdf_gui PROPERTIES
52+
MACOSX_BUNDLE TRUE
53+
)
54+
endif()
55+
56+
target_link_libraries(neopdf_gui
57+
PRIVATE
58+
Qt6::Core
59+
Qt6::Gui
60+
Qt6::Widgets
61+
Qt6::Charts
62+
)
63+
64+
target_include_directories(neopdf_gui
65+
PRIVATE
66+
${CMAKE_CURRENT_SOURCE_DIR}
67+
${NEOPDF_CAPI_INCLUDE_DIR}
68+
)
69+
70+
target_link_libraries(neopdf_gui
71+
PRIVATE
72+
${NEOPDF_CAPI_LIBRARY}
73+
)
74+
75+
target_compile_definitions(neopdf_gui PRIVATE QT_NO_FILESYSTEM)
76+
77+
install(TARGETS neopdf_gui
78+
BUNDLE DESTINATION .
79+
RUNTIME DESTINATION bin
80+
)
81+
82+
if(WIN32)
83+
set(QT_DEPLOY_TOOL windeployqt)
84+
elseif(APPLE)
85+
set(QT_DEPLOY_TOOL macdeployqt)
86+
endif()
87+
88+
if(QT_DEPLOY_TOOL)
89+
find_program(QT_DEPLOY_TOOL_PATH ${QT_DEPLOY_TOOL} HINTS ${Qt6_BIN_DIR})
90+
if(QT_DEPLOY_TOOL_PATH)
91+
if(WIN32)
92+
set(APP_PATH "\"${CMAKE_INSTALL_PREFIX}/bin/neopdf_gui.exe\"")
93+
elseif(APPLE)
94+
set(APP_PATH "\"${CMAKE_INSTALL_PREFIX}/neopdf_gui.app\"")
95+
endif()
96+
install(CODE "execute_process(COMMAND ${QT_DEPLOY_TOOL_PATH} ${APP_PATH})")
97+
endif()
98+
endif()
99+
100+
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
101+
set(CPACK_GENERATOR "TGZ")
102+
if(APPLE)
103+
set(CPACK_GENERATOR "DragNDrop")
104+
endif()
105+
106+
include(CPack)

0 commit comments

Comments
 (0)