Skip to content

Commit 2281f5c

Browse files
authored
Merge pull request #56 from JanCaha/development
Development
2 parents 9cd66d1 + 94e1525 commit 2281f5c

File tree

8 files changed

+97
-126
lines changed

8 files changed

+97
-126
lines changed

.github/workflows/conda_build.yaml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -92,55 +92,3 @@ jobs:
9292
with:
9393
path: conda_package/linux-64/*.conda
9494
name: conda_package_linux
95-
96-
# Build-on-Windows:
97-
98-
# name: Build on Windows
99-
100-
# runs-on: windows-latest
101-
102-
# needs: Update-conda-package-version
103-
104-
# env:
105-
# GH_TOKEN: ${{ github.token }}
106-
# LIBARCHIVE: C:\Miniconda\Library\bin\archive.dll
107-
108-
# steps:
109-
110-
# - name: Setup MSVC
111-
# uses: ilammy/msvc-dev-cmd@v1
112-
113-
# - name: Checkout
114-
# uses: actions/checkout@v4
115-
# with:
116-
# submodules: true
117-
118-
# - uses: conda-incubator/setup-miniconda@v3
119-
# with:
120-
# auto-update-conda: true
121-
# use-mamba: true
122-
# channels: conda-forge,defaults
123-
# auto-activate-base: true
124-
# activate-environment: ""
125-
126-
# - name: Add Custom Conda Channel
127-
# run: |
128-
# conda config --add channels https://jancaha.github.io/conda-channel
129-
130-
# - name: Install conda-build
131-
# run: |
132-
# conda install -n base conda-build conda-verify
133-
134-
# - name: Install libsimplerasters
135-
# run: |
136-
# conda install -n base libsimplerasters
137-
138-
# - name: Build library
139-
# run: |
140-
# conda build conda --output-folder conda_package
141-
142-
# - name: Upload artifact
143-
# uses: actions/upload-artifact@v4
144-
# with:
145-
# path: conda_package/win-64/*.conda
146-
# name: conda_package_windows

.github/workflows/create_releases.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ jobs:
9191
-DBUILD_TESTS:bool=on \
9292
-DCELL_EVENT_DATA_FLOAT:bool=on \
9393
-DOUTPUT_RASTER_DATA_FLOAT:bool=on \
94-
-D CMAKE_INSTALL_PREFIX=/usr
94+
-DBUILD_GUI_APP:bool=on \
95+
-DNEEDS_QT:bool=on \
96+
-DCMAKE_INSTALL_PREFIX=/usr
9597
9698
- name: Build DEB
9799
run: |

.github/workflows/test_library.yaml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757
run: |
5858
mkdir build
5959
cmake \
60-
-S. \
61-
-Bbuild \
60+
-S . \
61+
-B build \
6262
-G Ninja \
6363
-DCMAKE_CXX_COMPILER=${COMPILER} \
6464
-DCMAKE_BUILD_TYPE=Release \
@@ -67,7 +67,8 @@ jobs:
6767
-DBUILD_TESTS:bool=on \
6868
-DCELL_EVENT_DATA_FLOAT:bool=on \
6969
-DOUTPUT_RASTER_DATA_FLOAT:bool=on \
70-
-DNEEDS_QT:bool=off
70+
-DNEEDS_QT:bool=off \
71+
-DBUILD_GUI_APP:bool=off
7172
7273
- name: Build
7374
run: |
@@ -88,8 +89,8 @@ jobs:
8889
id: unittestsdouble
8990
run: |
9091
cmake \
91-
-S. \
92-
-Bbuild \
92+
-S . \
93+
-B build \
9394
-G Ninja \
9495
-DCMAKE_CXX_COMPILER=${COMPILER} \
9596
-DCMAKE_BUILD_TYPE=Release \
@@ -98,7 +99,8 @@ jobs:
9899
-DBUILD_TESTS:bool=on \
99100
-DCELL_EVENT_DATA_FLOAT:bool=off \
100101
-DOUTPUT_RASTER_DATA_FLOAT:bool=off \
101-
-DNEEDS_QT:bool=off
102+
-DNEEDS_QT:bool=off \
103+
-DBUILD_GUI_APP:bool=off
102104
cmake --build build --config Release --target build_tests
103105
cmake --build build --config Release --target run_tests
104106
@@ -150,7 +152,7 @@ jobs:
150152
- name: Configure
151153
run: |
152154
cmake \
153-
-S. \
155+
-S . \
154156
-Bbuild \
155157
-G Ninja \
156158
-DCMAKE_CXX_COMPILER=${COMPILER} \
@@ -161,7 +163,8 @@ jobs:
161163
-DCELL_EVENT_DATA_FLOAT:bool=on \
162164
-DOUTPUT_RASTER_DATA_FLOAT:bool=on \
163165
-DNEEDS_QT:bool=on \
164-
-D CMAKE_INSTALL_PREFIX=/usr
166+
-DBUILD_GUI_APP:bool=on \
167+
-DCMAKE_INSTALL_PREFIX=/usr \
165168
166169
- name: Run Tests even with Qt
167170
id: unittestsqt

CMakeLists.txt

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ option(BUILD_TESTS "Build tests." ON)
1111
option(BUILD_DOCUMENTATION "Build documentation." OFF)
1212
option(PACK_DEB "Pack DEB file for installation in Debian/Ubuntu/Mint and derivatives." ON)
1313
option(NEEDS_QT "Allows optionally building library without searching for Qt. Cannot build binaries with this set to OFF. For running test mainly." ON)
14+
option(BUILD_GUI_APP "Allows building of executable program with GUI" ON)
1415
option(CELL_EVENT_DATA_FLOAT "Create CellEvents with data stored `float` instead of `double`. Lowers significantly RAM memory usage." ON)
1516
option(OUTPUT_RASTER_DATA_FLOAT "Create output rasters with data stored `Float32` instead of `Float64`. Lowers RAM memory usage." ON)
1617

18+
if(BUILD_GUI_APP)
19+
set(NEEDS_QT ON)
20+
endif()
21+
1722
# C++ Standard
1823
set(CMAKE_CXX_STANDARD 20)
1924
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -29,20 +34,30 @@ find_package(SimpleRasters REQUIRED)
2934
if(NEEDS_QT)
3035
set(CMAKE_AUTOMOC TRUE)
3136

32-
find_package(Qt5 COMPONENTS Core Widgets Xml Gui Test REQUIRED)
37+
find_package(Qt5 COMPONENTS Core Xml Test REQUIRED)
3338

3439
set(QT_INCLUDES
3540
${Qt5Core_INCLUDE_DIRS}
36-
${Qt5Widgets_INCLUDE_DIRS}
37-
${Qt5Gui_INCLUDE_DIRS}
3841
)
3942

4043
set(QT_LIBS
4144
Qt5::Core
42-
Qt5::Gui
43-
Qt5::Widgets
4445
)
4546

47+
if(BUILD_GUI_APP)
48+
find_package(Qt5 COMPONENTS Core Widgets Xml Gui Test REQUIRED)
49+
50+
set(QT_INCLUDES
51+
${Qt5Core_INCLUDE_DIRS}
52+
)
53+
54+
set(QT_LIBS
55+
${QT_LIBS}
56+
Qt5::Gui
57+
Qt5::Widgets
58+
)
59+
endif()
60+
4661
set(HAS_QT TRUE)
4762
else()
4863
message(STATUS "Not using Qt")
@@ -128,11 +143,20 @@ install(TARGETS library_viewshed
128143

129144
if(HAS_QT)
130145
install(TARGETS
131-
viewshed inverseviewshed viewshedcalculator losextractor viewshed_widgets
146+
viewshed inverseviewshed
132147
COMPONENT bin
133148
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
134149
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
135150
)
151+
152+
if(BUILD_GUI_APP)
153+
install(TARGETS
154+
viewshedcalculator losextractor viewshed_widgets
155+
COMPONENT bin
156+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
157+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
158+
)
159+
endif()
136160
endif()
137161

138162
# endif()

cmake/CondaInstall.cmake

Lines changed: 0 additions & 24 deletions
This file was deleted.

conda/meta.yaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,38 @@ source:
77

88
build:
99
number: 0
10+
skip: true # [win]
1011
script:
11-
- cmake ${CMAKE_ARGS} -B build -S {{SRC_DIR}} -G Ninja -DCMAKE_BUILD_TYPE=Release -DPACK_DEB:bool=off -DBUILD_DOCUMENTATION:bool=off -DBUILD_TESTS:bool=off -DCELL_EVENT_DATA_FLOAT:bool=on -DOUTPUT_RASTER_DATA_FLOAT:bool=on -DNEEDS_QT:bool=off
12+
- cmake ${CMAKE_ARGS} -B build -S {{SRC_DIR}} -G Ninja -DCMAKE_BUILD_TYPE=Release -DPACK_DEB:bool=off -DBUILD_DOCUMENTATION:bool=off -DBUILD_TESTS:bool=off -DCELL_EVENT_DATA_FLOAT:bool=on -DOUTPUT_RASTER_DATA_FLOAT:bool=on -DNEEDS_QT:bool=on -DBUILD_GUI_APP:bool=off
1213
- cmake --build build --config Release
1314
- cmake --install build --prefix {{PREFIX}}
1415

16+
test:
17+
requires:
18+
- bash
19+
commands:
20+
- test -f "${PREFIX}/lib/libviewshed.so"
21+
- test -f "${PREFIX}/include/viewshed/viewshed.h"
22+
- test -x "${PREFIX}/bin/viewshed"
23+
- test -x "${PREFIX}/bin/inverseviewshed"
24+
1525
requirements:
1626
build:
1727
- {{ compiler('c') }}
1828
- {{ compiler('cxx') }}
1929
- pthread-stubs
2030
- libgdal
2131
- libsimplerasters
32+
- qt-main 5.*
2233
host:
2334
- pthread-stubs
2435
- libgdal
2536
- libsimplerasters
37+
- qt-main 5.*
2638
run:
2739
- libgdal
2840
- libsimplerasters
41+
- qt-main 5.*
2942

3043
about:
3144
home: https://github.com/JanCaha/cpp-viewshed-library

scripts/install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ cmake \
1212
-D CELL_EVENT_DATA_FLOAT:bool=on \
1313
-D OUTPUT_RASTER_DATA_FLOAT:bool=on \
1414
-D CMAKE_INSTALL_PREFIX=/usr \
15-
-D NEEDS_QT:bool=on
15+
-D NEEDS_QT:bool=on \
16+
-D BUILD_GUI_APP:bool=on
1617

1718
cmake --build build --config Release --target library_viewshed
1819
cmake --build build --config Release --target create_binaries

src/bin/CMakeLists.txt

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Binaries :
2-
macro(create_binary bin_name filename add_widgets)
2+
add_custom_target(create_binaries)
3+
4+
macro(create_binary bin_name filename)
35
add_executable(${bin_name} ${filename} commandlinehelper.h)
46

57
set_target_properties(${bin_name} PROPERTIES AUTOMOC TRUE)
@@ -9,58 +11,60 @@ macro(create_binary bin_name filename add_widgets)
911
target_include_directories(${bin_name} PRIVATE ${QT_INCLUDES})
1012
target_include_directories(${bin_name} PRIVATE ${GDAL_INCLUDE_DIR})
1113
target_include_directories(${bin_name} PRIVATE SimpleRasters::SimpleRasters)
12-
target_include_directories(${bin_name} PRIVATE viewshed_widgets)
1314

1415
target_link_libraries(${bin_name}
1516
${QT_LIBS}
1617
bs_thread_pool
1718
library_viewshed
1819
${GDAL_LIBRARY}
1920
SimpleRasters::SimpleRasters
20-
viewshed_widgets
2121
)
22+
23+
add_dependencies(create_binaries ${bin_name})
2224
endmacro(create_binary)
2325

24-
if(HAS_QT)
25-
message(STATUS "Has Qt so binaries can be build.")
26+
macro(create_gui_binary bin_name filename)
27+
create_binary(${bin_name} ${filename})
2628

27-
add_library(viewshed_widgets SHARED
28-
pointwidget.h pointwidget.cpp
29-
doublevalidator.h doublevalidator.cpp
30-
fileselectorwidget.h fileselectorwidget.cpp
31-
viewshedcalculatorwindow.h viewshedcalculatorwindow.cpp)
29+
target_include_directories(${bin_name} PRIVATE viewshed_widgets)
30+
target_link_libraries(${bin_name} viewshed_widgets)
31+
endmacro(create_gui_binary)
3232

33-
set_target_properties(viewshed_widgets PROPERTIES OUTPUT_NAME "viewshedwidgets")
33+
if(HAS_QT)
34+
message(STATUS "Has Qt so binaries can be build.")
3435

35-
set_target_properties(viewshed_widgets PROPERTIES VERSION ${PROJECT_VERSION})
36+
create_binary(viewshed viewshed.cpp)
3637

37-
target_include_directories(viewshed_widgets PUBLIC ${QT_INCLUDES})
38-
target_include_directories(viewshed_widgets PUBLIC SimpleRasters::SimpleRasters)
39-
target_include_directories(viewshed_widgets PRIVATE ${GDAL_INCLUDE_DIR})
38+
create_binary(inverseviewshed inverseviewshed.cpp)
4039

41-
target_link_libraries(viewshed_widgets
42-
${QT_LIBS}
43-
library_viewshed
44-
${GDAL_LIBRARY}
45-
SimpleRasters::SimpleRasters
40+
add_dependencies(create_binaries
41+
viewshed
42+
inverseviewshed
4643
)
4744

48-
create_binary(viewshed viewshed.cpp OFF)
45+
if(BUILD_GUI_APP)
46+
add_library(viewshed_widgets SHARED
47+
pointwidget.h pointwidget.cpp
48+
doublevalidator.h doublevalidator.cpp
49+
fileselectorwidget.h fileselectorwidget.cpp
50+
viewshedcalculatorwindow.h viewshedcalculatorwindow.cpp)
4951

50-
create_binary(inverseviewshed inverseviewshed.cpp OFF)
52+
set_target_properties(viewshed_widgets PROPERTIES OUTPUT_NAME "viewshedwidgets")
5153

52-
create_binary(viewshedcalculator viewshedcalculator.cpp ON)
54+
set_target_properties(viewshed_widgets PROPERTIES VERSION ${PROJECT_VERSION})
5355

54-
create_binary(losextractor losextractor.cpp ON)
56+
target_include_directories(viewshed_widgets PUBLIC ${QT_INCLUDES})
57+
target_include_directories(viewshed_widgets PUBLIC SimpleRasters::SimpleRasters)
58+
target_include_directories(viewshed_widgets PRIVATE ${GDAL_INCLUDE_DIR})
5559

56-
add_custom_target(create_binaries)
60+
target_link_libraries(viewshed_widgets
61+
${QT_LIBS}
62+
library_viewshed
63+
${GDAL_LIBRARY}
64+
SimpleRasters::SimpleRasters
65+
)
5766

58-
add_dependencies(create_binaries viewshed)
59-
60-
add_dependencies(create_binaries
61-
viewshed
62-
inverseviewshed
63-
viewshedcalculator
64-
losextractor
65-
)
67+
create_gui_binary(viewshedcalculator viewshedcalculator.cpp)
68+
create_gui_binary(losextractor losextractor.cpp)
69+
endif()
6670
endif()

0 commit comments

Comments
 (0)