Skip to content

Commit 782cba9

Browse files
committed
Add support for building targets with examples (LUE_WITH_EXAMPLES)
1 parent 776b2fc commit 782cba9

File tree

5 files changed

+63
-0
lines changed

5 files changed

+63
-0
lines changed

environment/cmake/Lue.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ message(STATUS "Build documentation : ${LUE_BUILD_DOCUMENTATION}")
106106
message(STATUS "Build quality assurance : ${LUE_BUILD_QUALITY_ASSURANCE}")
107107
message(STATUS "+ python api : ${LUE_QUALITY_ASSURANCE_WITH_PYTHON_API}")
108108
message(STATUS "+ tests : ${LUE_QUALITY_ASSURANCE_WITH_TESTS}")
109+
message(STATUS "With examples : ${LUE_WITH_EXAMPLES}")
109110
message(STATUS "")
110111
message(STATUS "CMAKE_GENERATOR : ${CMAKE_GENERATOR}")
111112
message(STATUS "GENERATOR_IS_MULTI_CONFIG : ${GENERATOR_IS_MULTI_CONFIG}")

environment/cmake/LueConfiguration.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ option(LUE_BUILD_DOCUMENTATION
3838
"Build documentation"
3939
FALSE)
4040

41+
option(LUE_WITH_EXAMPLES
42+
"Include examples"
43+
FALSE)
44+
4145
option(LUE_BUILD_QUALITY_ASSURANCE
4246
"Include support for quality assurance"
4347
FALSE)

source/framework/algorithm/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,10 @@ lue_install_development_libraries(
19721972

19731973
# ------------------------------------------------------------------------------
19741974

1975+
if(LUE_WITH_EXAMPLES)
1976+
add_subdirectory(example)
1977+
endif()
1978+
19751979
if(LUE_BUILD_TESTS)
19761980
add_subdirectory(test)
19771981
endif()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
add_executable(lue.framework.algorithm.example.ndvi ndvi.cpp)
2+
3+
target_link_libraries(lue.framework.algorithm.example.ndvi
4+
PRIVATE
5+
lue::framework_local_operation
6+
lue::framework_miscellaneous_operation
7+
)
8+
9+
lue_install_executables(
10+
TARGETS
11+
lue.framework.algorithm.example.ndvi
12+
)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include "lue/framework/algorithm/operator.hpp"
2+
#include "lue/framework/algorithm/value_policies/add.hpp"
3+
#include "lue/framework/algorithm/value_policies/divide.hpp"
4+
#include "lue/framework/algorithm/value_policies/subtract.hpp"
5+
#include "lue/framework/algorithm/value_policies/uniform.hpp"
6+
#include "lue/framework/core/component.hpp"
7+
#include <hpx/hpx_init.hpp>
8+
9+
10+
auto hpx_main([[maybe_unused]] int argc, [[maybe_unused]] char* argv[]) -> int
11+
{
12+
using namespace lue::value_policies;
13+
14+
using Element = float;
15+
lue::Rank const rank{2};
16+
using Array = lue::PartitionedArray<Element, rank>;
17+
using Shape = lue::ShapeT<Array>;
18+
19+
Shape const array_shape{40000, 40000};
20+
Shape const partition_shape{2000, 2000};
21+
Element const min{0};
22+
Element const max{1};
23+
24+
auto const near_infrared = uniform(array_shape, partition_shape, min, max);
25+
auto const red = uniform(array_shape, partition_shape, min, max);
26+
auto const ndvi = (near_infrared - red) / (near_infrared + red);
27+
28+
int hpx_status = hpx::finalize();
29+
30+
return hpx_status;
31+
}
32+
33+
34+
auto main(int argc, char* argv[]) -> int
35+
{
36+
std::vector<std::string> const cfg{};
37+
38+
hpx::init_params params{};
39+
params.cfg = {cfg};
40+
41+
return hpx::init(argc, argv, params);
42+
}

0 commit comments

Comments
 (0)