18bf80f4bSopenharmony_ci#
28bf80f4bSopenharmony_ci# Copyright (C) 2020 Huawei Technologies Co, Ltd.
38bf80f4bSopenharmony_ci#
48bf80f4bSopenharmony_ci
58bf80f4bSopenharmony_cicmake_minimum_required(VERSION 3.18)
68bf80f4bSopenharmony_ci
78bf80f4bSopenharmony_ciproject(PluginDotfield)
88bf80f4bSopenharmony_ci
98bf80f4bSopenharmony_ci# Setup c++17 standard and no extensions.
108bf80f4bSopenharmony_ciset(CMAKE_CXX_STANDARD 17)
118bf80f4bSopenharmony_ciset(CMAKE_CXX_STANDARD_REQUIRED ON)
128bf80f4bSopenharmony_ciset(CMAKE_CXX_EXTENSIONS OFF)
138bf80f4bSopenharmony_ci
148bf80f4bSopenharmony_ciif (NOT DEFINED RENDER_ROOT_DIRECTORY)
158bf80f4bSopenharmony_ci    set(RENDER_ROOT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/LumeRender" CACHE PATH "Path render sdk root dir")
168bf80f4bSopenharmony_ciendif()
178bf80f4bSopenharmony_ciinclude(${RENDER_ROOT_DIRECTORY}/cmake/cmake_tools.cmake)
188bf80f4bSopenharmony_ci
198bf80f4bSopenharmony_cilist(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
208bf80f4bSopenharmony_ci
218bf80f4bSopenharmony_ciif (NOT TARGET AGPEngine::AGPEngineAPI)
228bf80f4bSopenharmony_ci    find_package(AGPEngineAPI REQUIRED)
238bf80f4bSopenharmony_ciendif()
248bf80f4bSopenharmony_ciif (NOT TARGET AGPEngine::ComponentHelperSDK)
258bf80f4bSopenharmony_ci    find_package(ComponentHelperSDK REQUIRED)
268bf80f4bSopenharmony_ciendif()
278bf80f4bSopenharmony_ciif (NOT TARGET AGPRender::AGPRenderAPI)
288bf80f4bSopenharmony_ci    find_package(AGPRenderAPI REQUIRED)
298bf80f4bSopenharmony_ciendif()
308bf80f4bSopenharmony_ciif (NOT TARGET AGP3D::AGP3DAPI)
318bf80f4bSopenharmony_ci    find_package(AGP3DAPI REQUIRED)
328bf80f4bSopenharmony_ciendif()
338bf80f4bSopenharmony_ci
348bf80f4bSopenharmony_ciset(lib_dest "lib/$<CONFIG>")
358bf80f4bSopenharmony_ciset(inc_dest "include")
368bf80f4bSopenharmony_ci
378bf80f4bSopenharmony_ci#
388bf80f4bSopenharmony_ci# Plugin API.
398bf80f4bSopenharmony_ci#
408bf80f4bSopenharmony_ciadd_library(PluginDotfieldAPI INTERFACE)
418bf80f4bSopenharmony_ciadd_library(PluginDotfield::PluginDotfieldAPI ALIAS PluginDotfieldAPI)
428bf80f4bSopenharmony_ci
438bf80f4bSopenharmony_ciset (PluginDotfieldAPI_HeaderPath
448bf80f4bSopenharmony_ci    $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/api>$<INSTALL_INTERFACE:${inc_dest}/api>
458bf80f4bSopenharmony_ci)
468bf80f4bSopenharmony_ci
478bf80f4bSopenharmony_ciset(dotfield_api
488bf80f4bSopenharmony_ci    dotfield/implementation_uids.h
498bf80f4bSopenharmony_ci    dotfield/ecs/systems/dotfield_system.h
508bf80f4bSopenharmony_ci    dotfield/ecs/components/dotfield_component.h
518bf80f4bSopenharmony_ci    dotfield/render/intf_render_data_store_default_dotfield.h
528bf80f4bSopenharmony_ci)
538bf80f4bSopenharmony_ci
548bf80f4bSopenharmony_ciset_list_prefix(Api_Sources_Generator dotfield_api "${PluginDotfieldAPI_HeaderPath}/")
558bf80f4bSopenharmony_citarget_sources(PluginDotfieldAPI INTERFACE ${Api_Sources_Generator})
568bf80f4bSopenharmony_ci
578bf80f4bSopenharmony_ciset_list_prefix(Api_Sources_Build dotfield_api "${CMAKE_CURRENT_LIST_DIR}/api/")
588bf80f4bSopenharmony_cisource_group(TREE ${CMAKE_CURRENT_LIST_DIR}/api
598bf80f4bSopenharmony_ci    PREFIX api
608bf80f4bSopenharmony_ci    FILES ${Api_Sources_Build}
618bf80f4bSopenharmony_ci)
628bf80f4bSopenharmony_ci
638bf80f4bSopenharmony_citarget_include_directories(PluginDotfieldAPI SYSTEM INTERFACE ${PluginDotfieldAPI_HeaderPath})
648bf80f4bSopenharmony_ci
658bf80f4bSopenharmony_ciinstall(DIRECTORY api/ DESTINATION ${inc_dest}/api)
668bf80f4bSopenharmony_ci
678bf80f4bSopenharmony_ciinstall(TARGETS PluginDotfieldAPI EXPORT PluginDotfieldAPIConfig
688bf80f4bSopenharmony_ci    DESTINATION ${lib_dest}
698bf80f4bSopenharmony_ci)
708bf80f4bSopenharmony_ciinstall(EXPORT PluginDotfieldAPIConfig
718bf80f4bSopenharmony_ci    FILE PluginDotfieldAPIConfig.cmake
728bf80f4bSopenharmony_ci    NAMESPACE PluginDotfield::
738bf80f4bSopenharmony_ci    DESTINATION "share/cmake"
748bf80f4bSopenharmony_ci)
758bf80f4bSopenharmony_ci
768bf80f4bSopenharmony_ci# Make it possible to import from a build tree.
778bf80f4bSopenharmony_ciexport(TARGETS PluginDotfieldAPI NAMESPACE PluginDotfield:: FILE PluginDotfieldAPIConfig.cmake)
788bf80f4bSopenharmony_ci
798bf80f4bSopenharmony_ci
808bf80f4bSopenharmony_ciset(managers
818bf80f4bSopenharmony_ci    src/components/dotfield_component.cpp
828bf80f4bSopenharmony_ci)
838bf80f4bSopenharmony_ci
848bf80f4bSopenharmony_ciset(systems
858bf80f4bSopenharmony_ci    src/systems/dotfield_system.cpp
868bf80f4bSopenharmony_ci)
878bf80f4bSopenharmony_ci
888bf80f4bSopenharmony_ciset(nodes
898bf80f4bSopenharmony_ci    src/render/render_data_store_default_dotfield.h
908bf80f4bSopenharmony_ci    src/render/render_data_store_default_dotfield.cpp
918bf80f4bSopenharmony_ci    src/render/render_node_dotfield_render.h
928bf80f4bSopenharmony_ci    src/render/render_node_dotfield_render.cpp
938bf80f4bSopenharmony_ci    src/render/render_node_dotfield_simulation.h
948bf80f4bSopenharmony_ci    src/render/render_node_dotfield_simulation.cpp
958bf80f4bSopenharmony_ci)
968bf80f4bSopenharmony_ci
978bf80f4bSopenharmony_ciset(data
988bf80f4bSopenharmony_ci    assets/app/shaders/common/dotfield_common.h
998bf80f4bSopenharmony_ci    assets/app/shaders/common/dotfield_struct_common.h
1008bf80f4bSopenharmony_ci
1018bf80f4bSopenharmony_ci    assets/app/shaders/computeshader/dotfield_simulation.comp
1028bf80f4bSopenharmony_ci    assets/app/shaders/computeshader/dotfield_simulation.shader
1038bf80f4bSopenharmony_ci
1048bf80f4bSopenharmony_ci    assets/app/shaders/shader/default_material_dotfield.vert
1058bf80f4bSopenharmony_ci    assets/app/shaders/shader/default_material_dotfield.frag
1068bf80f4bSopenharmony_ci    assets/app/shaders/shader/default_material_dotfield.shader
1078bf80f4bSopenharmony_ci
1088bf80f4bSopenharmony_ci    assets/app/pipelinelayouts/default_material_dotfield.shaderpl
1098bf80f4bSopenharmony_ci    assets/app/pipelinelayouts/dotfield_simulation.shaderpl
1108bf80f4bSopenharmony_ci
1118bf80f4bSopenharmony_ci    assets/app/vertexinputdeclarations/default_material_dotfield.shadervid
1128bf80f4bSopenharmony_ci)
1138bf80f4bSopenharmony_ci
1148bf80f4bSopenharmony_cisource_group(TREE ${CMAKE_CURRENT_LIST_DIR} FILES ${systems} ${managers} ${nodes} src/component_dll.cpp)
1158bf80f4bSopenharmony_cisource_group(TREE ${CMAKE_CURRENT_LIST_DIR} PREFIX assets FILES ${data})
1168bf80f4bSopenharmony_ci
1178bf80f4bSopenharmony_ci#
1188bf80f4bSopenharmony_ci# Collect version information from git.
1198bf80f4bSopenharmony_ci#
1208bf80f4bSopenharmony_ciadd_custom_command(
1218bf80f4bSopenharmony_ci    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_version.cpp
1228bf80f4bSopenharmony_ci           ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
1238bf80f4bSopenharmony_ci    COMMAND ${CMAKE_COMMAND} -P
1248bf80f4bSopenharmony_ci            ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
1258bf80f4bSopenharmony_ci)
1268bf80f4bSopenharmony_ci
1278bf80f4bSopenharmony_ci#
1288bf80f4bSopenharmony_ci# Plugin library.
1298bf80f4bSopenharmony_ci#
1308bf80f4bSopenharmony_ciadd_library(PluginDotfield SHARED
1318bf80f4bSopenharmony_ci    src/component_dll.cpp
1328bf80f4bSopenharmony_ci    ${managers}
1338bf80f4bSopenharmony_ci    ${systems}
1348bf80f4bSopenharmony_ci    ${nodes}
1358bf80f4bSopenharmony_ci    ${data}
1368bf80f4bSopenharmony_ci	${CMAKE_CURRENT_BINARY_DIR}/version.cpp
1378bf80f4bSopenharmony_ci)
1388bf80f4bSopenharmony_ci
1398bf80f4bSopenharmony_citarget_include_directories(PluginDotfield PRIVATE api src assets)
1408bf80f4bSopenharmony_citarget_compile_definitions(PluginDotfield PRIVATE CORE_PLUGIN=1)
1418bf80f4bSopenharmony_citarget_link_libraries(PluginDotfield PRIVATE
1428bf80f4bSopenharmony_ci    AGPBase::AGPBaseAPI
1438bf80f4bSopenharmony_ci    AGPEngine::AGPEngineAPI
1448bf80f4bSopenharmony_ci    AGPEngine::ComponentHelperSDK
1458bf80f4bSopenharmony_ci    AGPRender::AGPRenderAPI
1468bf80f4bSopenharmony_ci    AGP3D::AGP3DAPI
1478bf80f4bSopenharmony_ci    PluginDotfield::PluginDotfieldAPI
1488bf80f4bSopenharmony_ci)
1498bf80f4bSopenharmony_ci
1508bf80f4bSopenharmony_cisetup_warnings(PluginDotfield)
1518bf80f4bSopenharmony_ci
1528bf80f4bSopenharmony_ciappend_link_flags(PluginDotfield "${BASE_SO_LINK_FLAGS}")
1538bf80f4bSopenharmony_ci
1548bf80f4bSopenharmony_ciif (ANDROID)
1558bf80f4bSopenharmony_ci    append_link_flags(PluginDotfield "-Wl,--exclude-libs,ALL")
1568bf80f4bSopenharmony_ciendif()
1578bf80f4bSopenharmony_ci
1588bf80f4bSopenharmony_ciset_target_properties(PluginDotfield PROPERTIES
1598bf80f4bSopenharmony_ci    CXX_VISIBILITY_PRESET hidden
1608bf80f4bSopenharmony_ci    VISIBILITY_INLINES_HIDDEN 1)
1618bf80f4bSopenharmony_ci
1628bf80f4bSopenharmony_ciset_target_properties(PluginDotfield PROPERTIES FOLDER SamplePlugins)
1638bf80f4bSopenharmony_ci
1648bf80f4bSopenharmony_ci# Build shaders and assets
1658bf80f4bSopenharmony_cicompile_shaders(TARGET CompileDotfieldShaders SOURCE "${CMAKE_CURRENT_LIST_DIR}/assets/app/shaders" INCLUDE AGPRender::AGPRenderAPI AGP3D::AGP3DAPI)
1668bf80f4bSopenharmony_ci
1678bf80f4bSopenharmony_cibuild_rofs(CompileDotfieldAssets PluginDotfield "${CMAKE_CURRENT_LIST_DIR}/assets/app" "/" "DOTFIELD_BIN" "DOTFIELD_BIN_SIZE" "dotfieldrofs")
1688bf80f4bSopenharmony_ciset_target_properties(CompileDotfieldAssets PROPERTIES FOLDER Tools)
1698bf80f4bSopenharmony_ci
1708bf80f4bSopenharmony_ciadd_dependencies(CompileDotfieldAssets CompileDotfieldShaders)
1718bf80f4bSopenharmony_ciadd_dependencies(PluginDotfield CompileDotfieldAssets)
1728bf80f4bSopenharmony_ci
1738bf80f4bSopenharmony_ci
1748bf80f4bSopenharmony_ci#
1758bf80f4bSopenharmony_ci# Export cmake "config" module.
1768bf80f4bSopenharmony_ci#
1778bf80f4bSopenharmony_ciinstall(TARGETS PluginDotfield EXPORT PluginDotfieldConfig
1788bf80f4bSopenharmony_ci    DESTINATION ${lib_dest}
1798bf80f4bSopenharmony_ci)
1808bf80f4bSopenharmony_ciinstall(EXPORT PluginDotfieldConfig
1818bf80f4bSopenharmony_ci    FILE PluginDotfieldConfig.cmake
1828bf80f4bSopenharmony_ci    NAMESPACE PluginDotfield::
1838bf80f4bSopenharmony_ci    DESTINATION "share/cmake"
1848bf80f4bSopenharmony_ci)
1858bf80f4bSopenharmony_ci
1868bf80f4bSopenharmony_ci# Make it possible to import from a build tree.
1878bf80f4bSopenharmony_ciexport(TARGETS PluginDotfield NAMESPACE PluginDotfield:: FILE PluginDotfieldTargets.cmake)
1888bf80f4bSopenharmony_ci
1898bf80f4bSopenharmony_ciconfigure_file(cmake/PluginDotfieldConfig.cmake.in PluginDotfieldConfig.cmake @ONLY)
1908bf80f4bSopenharmony_ciinstall(FILES
1918bf80f4bSopenharmony_ci    "${CMAKE_CURRENT_BINARY_DIR}/PluginDotfieldConfig.cmake"
1928bf80f4bSopenharmony_ci    DESTINATION "share/cmake"
1938bf80f4bSopenharmony_ci)
194