1# 2# Copyright (C) 2018 Huawei Technologies Co, Ltd. 3# 4 5cmake_minimum_required(VERSION 3.18) 6 7project(AGPEngine) 8 9if (NOT DEFINED CORE_ROOT_DIRECTORY) 10 set(CORE_ROOT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "Path engine sdk root dir") 11endif() 12include(${CORE_ROOT_DIRECTORY}/cmake/cmake_tools.cmake) 13force_static_link() 14 15if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 16 set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/sdk" CACHE PATH "<comment>" FORCE) 17endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 18 19list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") 20 21option(CORE_BUILD_BASE "Build AGPBase from BASE_ROOT_DIRECTORY. " ON) 22set(BASE_ROOT_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/LumeBase" CACHE PATH "Base root dir") 23if (EXISTS "${BASE_ROOT_DIRECTORY}/CMakeLists.txt") 24 message("Found base source in ${BASE_ROOT_DIRECTORY}") 25 if (NOT TARGET AGPBase::AGPBaseAPI) 26 if (CORE_BUILD_BASE) 27 message("AGPBase::AGPBaseAPI target does not exist yet, so add base from the submodule") 28# add_subdirectory("${BASE_ROOT_DIRECTORY}/" LumeBase) 29 endif() 30 endif() 31endif() 32 33if (NOT TARGET AGPBase::AGPBaseAPI) 34 find_package(AGPBaseAPI REQUIRED) 35endif() 36option(CORE_HIDE_SYMBOLS "Hide non CORE_PUBLIC symbols" ON) 37#set(CORE_HIDE_SYMBOLS FALSE CACHE BOOL "" FORCE) 38option(CORE_PERF_ENABLED "Build AGPEngine with performance timers" OFF) 39#set(CORE_PERF_ENABLED TRUE CACHE BOOL "" FORCE) 40 41# 42# Pure interface api targets. (includes, shared sources only) 43# todo: check install, create cmake modules.. etc 44# 45# Pure interface target for AGPEngine. exposes only the api folder! 46add_library(AGPEngineAPI INTERFACE) 47add_library(AGPEngine::AGPEngineAPI ALIAS AGPEngineAPI) 48 49set (AGPEngineAPI_HeaderPath 50 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/api> 51) 52 53if(ANDROID) 54 set (AGPEngineOSAPI_HeaderPath 55 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/platform/android>$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/api/platform/android> 56 ) 57elseif(OHOS) 58 set (AGPEngineOSAPI_HeaderPath 59 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/platform/ohos_ndk>$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/api/platform/ohos_ndk> 60 ) 61else() 62 set (AGPEngineOSAPI_HeaderPath 63 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/platform/common>$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/api/platform/common> 64 ) 65endif() 66 67set(Api_OSSources 68 core/os/intf_platform.h 69 core/os/platform_create_info.h 70) 71 72set(Api_Sources 73 core/ecs/entity.h 74 core/ecs/entity_reference.h 75 core/ecs/component_struct_macros.h 76 core/ecs/intf_component_manager.h 77 core/ecs/intf_ecs.h 78 core/ecs/intf_entity_manager.h 79 core/ecs/intf_system.h 80 core/ecs/intf_system_graph_loader.h 81 82 core/image/intf_image_container.h 83 core/image/intf_image_loader_manager.h 84 core/image/intf_animated_image.h 85 86 core/io/intf_filesystem_api.h 87 core/io/intf_directory.h 88 core/io/intf_file.h 89 core/io/intf_file_manager.h 90 core/io/intf_file_system.h 91 core/io/intf_file_monitor.h 92 93 core/json/json.h 94 95 core/perf/cpu_perf_scope.h 96 core/perf/intf_performance_data_manager.h 97 core/perf/intf_performance_trace.h 98 99 core/plugin/intf_class_factory.h 100 core/plugin/intf_class_info.h 101 core/plugin/intf_class_register.h 102 core/plugin/intf_plugin.h 103 core/plugin/intf_plugin_decl.h 104 core/plugin/intf_plugin_register.h 105 core/plugin/intf_interface.h 106 core/plugin/intf_interface_helper.h 107 108 core/property/intf_property_api.h 109 core/property/intf_property_handle.h 110 core/property/property_handle_util.h 111 core/property/property_types.h 112 core/property/property.h 113 core/property/scoped_handle.h 114 115 core/property_tools/property_api_impl.inl 116 core/property_tools/property_api_impl.h 117 core/property_tools/property_data.cpp 118 core/property_tools/property_data.h 119 core/property_tools/property_macros.h 120 core/property_tools/core_metadata.inl 121 122 core/resources/intf_resource.h 123 core/resources/intf_resource_manager.h 124 125 core/threading/intf_thread_pool.h 126 127 core/util/intf_frustum_util.h 128 core/util/parallel_sort.h 129 130 core/engine_info.h 131 core/implementation_uids.h 132 core/intf_engine.h 133 core/intf_logger.h 134 core/log.h 135 core/namespace.h 136) 137 138# Prefixing the filenames here with either the generator expression or the relative path for source_group. 139# (because source_group does not understand generator expressions). 140 141set_list_prefix(Api_Sources_Generator Api_Sources "${AGPEngineAPI_HeaderPath}/") 142set_list_prefix(Api_OSSources_Generator Api_OSSources "${AGPEngineOSAPI_HeaderPath}/") 143target_sources(AGPEngineAPI INTERFACE ${Api_Sources_Generator} 144 INTERFACE ${Api_OSSources_Generator}) 145 146set_list_prefix(Api_Sources_Build Api_Sources "${CMAKE_CURRENT_SOURCE_DIR}/") 147set_list_prefix(Api_OSSources_Build Api_OSSources "${CMAKE_CURRENT_SOURCE_DIR}/") 148source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} 149 FILES ${Api_Sources_Build} 150 FILES ${Api_OSSources_Build} 151) 152 153target_include_directories(AGPEngineAPI SYSTEM INTERFACE 154 ${AGPEngineAPI_HeaderPath} 155) 156target_include_directories(AGPEngineAPI SYSTEM INTERFACE 157 ${AGPEngineOSAPI_HeaderPath} 158) 159target_link_libraries(AGPEngineAPI INTERFACE AGPBase::AGPBaseAPI) 160 161# Temporarily set this always. Should vary depending on static/ shared. 162if(APPLE) 163 target_compile_definitions(AGPEngineAPI INTERFACE CORE_USE_COMPILER_GENERATED_STATIC_LIST=0) 164else() 165 target_compile_definitions(AGPEngineAPI INTERFACE CORE_USE_COMPILER_GENERATED_STATIC_LIST=1) 166endif() 167 168# 169# Performance timers 170# 171if(CORE_PERF_ENABLED) 172 target_compile_definitions(AGPEngineAPI INTERFACE CORE_PERF_ENABLED=1) 173else() 174 target_compile_definitions(AGPEngineAPI INTERFACE CORE_PERF_ENABLED=0) 175endif() 176 177# Make it possible to import from a build tree. 178#export(TARGETS AGPEngineAPI NAMESPACE AGPEngine:: FILE AGPEngineAPIConfig.cmake) 179include(CMakePackageConfigHelpers) 180 181configure_package_config_file( 182 "${PROJECT_SOURCE_DIR}/../cmake/AGPEngineAPIConfig.cmake.in" 183 "${PROJECT_BINARY_DIR}/cmake/AGPEngineAPIConfig.cmake" 184 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AGPEngineAPI 185) 186 187install(TARGETS AGPEngineAPI 188 EXPORT AGPEngineAPITargets 189 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/$<CONFIG> 190 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/$<CONFIG> 191 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/$<CONFIG> 192 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 193) 194 195install(EXPORT AGPEngineAPITargets 196 FILE AGPEngineAPITargets.cmake 197 NAMESPACE AGPEngine:: 198 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AGPEngineAPI 199) 200 201install(FILES "${PROJECT_BINARY_DIR}/cmake/AGPEngineAPIConfig.cmake" 202 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AGPEngineAPI 203) 204 205install(DIRECTORY ./ 206 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/api 207) 208 209export(EXPORT AGPEngineAPITargets 210 FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/AGPEngineAPITargets.cmake" 211 NAMESPACE AGPEngine:: 212) 213 214# 215# Clang format target. 216# 217add_custom_target(FormatEngineApi 218 COMMAND clang-format -verbose -i ${Api_Sources_Build} 219 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 220) 221set_target_properties(FormatEngineApi PROPERTIES FOLDER Formatting) 222