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 core/resources/intf_serializable.h 125 126 core/threading/intf_thread_pool.h 127 128 core/util/intf_frustum_util.h 129 core/util/parallel_sort.h 130 131 core/engine_info.h 132 core/implementation_uids.h 133 core/intf_engine.h 134 core/intf_logger.h 135 core/log.h 136 core/namespace.h 137) 138 139# Prefixing the filenames here with either the generator expression or the relative path for source_group. 140# (because source_group does not understand generator expressions). 141 142set_list_prefix(Api_Sources_Generator Api_Sources "${AGPEngineAPI_HeaderPath}/") 143set_list_prefix(Api_OSSources_Generator Api_OSSources "${AGPEngineOSAPI_HeaderPath}/") 144target_sources(AGPEngineAPI INTERFACE ${Api_Sources_Generator} 145 INTERFACE ${Api_OSSources_Generator}) 146 147set_list_prefix(Api_Sources_Build Api_Sources "${CMAKE_CURRENT_SOURCE_DIR}/") 148set_list_prefix(Api_OSSources_Build Api_OSSources "${CMAKE_CURRENT_SOURCE_DIR}/") 149source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} 150 FILES ${Api_Sources_Build} 151 FILES ${Api_OSSources_Build} 152) 153 154target_include_directories(AGPEngineAPI SYSTEM INTERFACE 155 ${AGPEngineAPI_HeaderPath} 156) 157target_include_directories(AGPEngineAPI SYSTEM INTERFACE 158 ${AGPEngineOSAPI_HeaderPath} 159) 160target_link_libraries(AGPEngineAPI INTERFACE AGPBase::AGPBaseAPI) 161 162# Temporarily set this always. Should vary depending on static/ shared. 163if(APPLE) 164 target_compile_definitions(AGPEngineAPI INTERFACE CORE_USE_COMPILER_GENERATED_STATIC_LIST=0) 165else() 166 target_compile_definitions(AGPEngineAPI INTERFACE CORE_USE_COMPILER_GENERATED_STATIC_LIST=1) 167endif() 168 169# 170# Performance timers 171# 172if(CORE_PERF_ENABLED) 173 target_compile_definitions(AGPEngineAPI INTERFACE CORE_PERF_ENABLED=1) 174else() 175 target_compile_definitions(AGPEngineAPI INTERFACE CORE_PERF_ENABLED=0) 176endif() 177 178# Make it possible to import from a build tree. 179#export(TARGETS AGPEngineAPI NAMESPACE AGPEngine:: FILE AGPEngineAPIConfig.cmake) 180include(CMakePackageConfigHelpers) 181 182configure_package_config_file( 183 "${PROJECT_SOURCE_DIR}/../cmake/AGPEngineAPIConfig.cmake.in" 184 "${PROJECT_BINARY_DIR}/cmake/AGPEngineAPIConfig.cmake" 185 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AGPEngineAPI 186) 187 188install(TARGETS AGPEngineAPI 189 EXPORT AGPEngineAPITargets 190 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/$<CONFIG> 191 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/$<CONFIG> 192 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/$<CONFIG> 193 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 194) 195 196install(EXPORT AGPEngineAPITargets 197 FILE AGPEngineAPITargets.cmake 198 NAMESPACE AGPEngine:: 199 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AGPEngineAPI 200) 201 202install(FILES "${PROJECT_BINARY_DIR}/cmake/AGPEngineAPIConfig.cmake" 203 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/AGPEngineAPI 204) 205 206install(DIRECTORY ./ 207 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/api 208) 209 210export(EXPORT AGPEngineAPITargets 211 FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/AGPEngineAPITargets.cmake" 212 NAMESPACE AGPEngine:: 213) 214 215# 216# Clang format target. 217# 218add_custom_target(FormatEngineApi 219 COMMAND clang-format -verbose -i ${Api_Sources_Build} 220 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 221) 222set_target_properties(FormatEngineApi PROPERTIES FOLDER Formatting) 223