加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CMakeLists.txt 10.06 KB
一键复制 编辑 原始数据 按行查看 历史
knight 提交于 2019-04-16 15:35 . sync code
#Top Dir
cmake_minimum_required(VERSION 3.1)
#cmake linux 3.5 nonrecognition
#cmake_policy(SET CMP0071 NEW)
#set (_AV_WARE_VERSION_MAJOR 1)
#set (_AV_WARE_VERSION_MINOR 1)
#set (_AV_WARE_VERSION_PATCH 3)
#set (_AV_WARE_VERSION_OEM Gp)
#set (_AV_WARE_VERSION_RUNTIME RC) #base、alpha、beta 、RC release(R)
include("CMakeConfig.cmake")
############################################
#option (_AV_WARE_CODE_OPENSOURCE "Open Source" OFF)
option (_AV_WARE_CODE_OPENSOURCE "Open Source" ON)
option (_AV_WARE_CODE_LITE "Lite Version" OFF)
############################################
if (WIN32)
set(UI_CLOSE_CAPUTRE ON)
set(SYS_CHN_NUM "64")
##当使用VS编码嵌入式的时候,则不能去找UI--
if (COMPILER MATCHES "PC_WIN32")
set(_AV_WARE_CODE_GUI uiDisplay)
set (CMAKE_QT_PATH ${QT_WIN32_PATH})
elseif (COMPILER MATCHES "PC_WIN64")
set(_AV_WARE_CODE_GUI uiDisplay)
set (CMAKE_QT_PATH ${QT_WIN64_PATH})
endif()
elseif (UNIX)
set(CMAKE_SYSTEM_NAME Linux)
if (COMPILER MATCHES "HISI_16C_18ACE_V100")
set(UI_CLOSE_CAPUTRE OFF)
set(SYS_CHN_NUM "1")
set (CMAKE_C_COMPILER "arm-hisiv300-linux-gcc")
set (CMAKE_CXX_COMPILER "arm-hisiv300-linux-g++")
elseif (COMPILER MATCHES "HISI_16AD")
set(UI_CLOSE_CAPUTRE OFF)
set(SYS_CHN_NUM "1")
set (CMAKE_C_COMPILER "arm-hisiv300-linux-gcc")
set (CMAKE_CXX_COMPILER "arm-hisiv300-linux-g++")
#set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4")
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=cortex-a7 -mfloat-abi=softfp -mfpu=neon-vfpv4")
elseif (COMPILER MATCHES "HISI_16C_18E_V200")
set(UI_CLOSE_CAPUTRE OFF)
set(SYS_CHN_NUM "1")
set (CMAKE_C_COMPILER "arm-hisiv300-linux-gcc")
set (CMAKE_CXX_COMPILER "arm-hisiv300-linux-g++")
add_definitions("-DCHIP_ID=0x3518E200")
elseif (COMPILER MATCHES "HISI_3535")
option (_AV_WARE_RENDER_BY_RECT "Render Windows By Rect" ON)
set(UI_CLOSE_CAPUTRE ON)
set(SYS_CHN_NUM "16")
set(_AV_WARE_CODE_GUI uiDisplay)
set (CMAKE_QT_PATH ${QT_NVR35_PATH})
set (CMAKE_C_COMPILER "arm-hisiv300-linux-gcc")
set (CMAKE_CXX_COMPILER "arm-hisiv300-linux-g++")
elseif (COMPILER MATCHES "HISI_3536")
option (_AV_WARE_RENDER_BY_RECT "Render Windows By Rect" ON)
set(UI_CLOSE_CAPUTRE ON)
set(SYS_CHN_NUM "32")
set(_AV_WARE_CODE_GUI uiDisplay)
set (CMAKE_QT_PATH ${QT_NVR36_PATH})
set (CMAKE_C_COMPILER "arm-hisiv400-linux-gcc")
set (CMAKE_CXX_COMPILER "arm-hisiv400-linux-g++")
elseif (COMPILER MATCHES "HISI_3798M")
option (_AV_WARE_RENDER_BY_RECT "Render Windows By Rect" ON)
set(UI_CLOSE_CAPUTRE ON)
set(SYS_CHN_NUM "9")
set(_AV_WARE_CODE_GUI uiDisplay)
set (CMAKE_QT_PATH ${QT_NVR3798M_PATH})
set (CMAKE_C_COMPILER "arm-hisiv400-linux-gcc")
set (CMAKE_CXX_COMPILER "arm-hisiv400-linux-g++")
elseif (COMPILER MATCHES "AMBA")
set(UI_CLOSE_CAPUTRE OFF)
set(SYS_CHN_NUM "1")
set (CMAKE_C_COMPILER "arm-linux-gnueabihf-gcc")
set (CMAKE_CXX_COMPILER "arm-linux-gnueabihf-g++")
elseif (COMPILER MATCHES "PC_LIN32")
set(UI_CLOSE_CAPUTRE ON)
set(SYS_CHN_NUM "64")
set(_AV_WARE_CODE_GUI uiDisplay)
elseif (COMPILER MATCHES "PC_LIN64")
set(UI_CLOSE_CAPUTRE ON)
set(SYS_CHN_NUM "64")
set(_AV_WARE_CODE_GUI uiDisplay)
elseif (COMPILER MATCHES "ANDROID")
set(UI_CLOSE_CAPUTRE ON)
set(SYS_CHN_NUM "9")
set(_AV_WARE_CODE_GUI uiPhone)
set(CMAKE_SYSTEM_NAME ANDROID)
set(CMAKE_QT_PATH "$ENV{Qt5_android}/lib/cmake/Qt5")
elseif (COMPILER MATCHES "IOS")
set(UI_CLOSE_CAPUTRE ON)
elseif (COMPILER MATCHES "Ingenic")
set(UI_CLOSE_CAPUTRE OFF)
set(SYS_CHN_NUM "1")
set (CMAKE_C_COMPILER "mips-linux-uclibc-gnu-gcc")
set (CMAKE_CXX_COMPILER "mips-linux-uclibc-gnu-g++")
endif()
endif()
###############################################################################
set(CMAKE_SUPPRESS_REGENERATION 1)
set(CMAKE_USE_RELATIVE_PATHS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
set(PROJDIR ${CMAKE_CURRENT_SOURCE_DIR})
set (AVWARE_HOME_DIR ${PROJDIR})
set (CMAKE_CONFIGURATION_TYPES Debug Release)
set (ProjectName avWare)
Project (${ProjectName}_${COMPILER})
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set (CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR})
###############################################################################
set (CMAKE_BUILD_TYPE ${_CMAKE_CONF_BUILD_TYPE})
set (CMAKE_VERBOSE_MAKEFILE ${_CMAKE_CONF_VERBOSE_MAKEFILE})
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_RELEASE_POSTFIX "")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_definitions("-D_AV_WARE_")
include_directories(${PROJECT_BINARY_DIR})
if (WIN32)
add_definitions("-D_CRT_SECURE_NO_WARNINGS")
add_definitions("-D_WINSOCK_DEPRECATED_NO_WARNINGS")
if (COMPILER MATCHES "PC_WIN32")
add_definitions("-D_WIN32")
elseif (COMPILER MATCHES "PC_WIN64")
add_definitions("-D_WIN64")
else()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /openmp")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /openmp")
set(CMAKE_EXE_LINKER_FLAGS "/SAFESEH:NO /MANIFEST:NO")
elseif (UNIX)
#不启作用 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -ffunction-sections -fdata-sections")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -gc-sections")
#堆栈保护--
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all")
#GCC 64位偏移地址形式操作文件,用于格式化文件系统
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s -O2 -pipe -fPIC -Wall -MMD -fno-strict-aliasing -fmessage-length=0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s -O2 -pipe -fPIC -Wall -MMD -fno-strict-aliasing -fmessage-length=0")
elseif (${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -ggdb -pipe -fPIC -Wall -MMD -fno-strict-aliasing")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -ggdb -pipe -fPIC -Wall -MMD -fno-strict-aliasing")
if (COMPILER MATCHES "PC_LIN32" OR COMPILER MATCHES "PC_LIN64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
endif()
else()
message(FATAL_ERROR "Please use cmake -DCMAKE_BUILD_TYPE=Debug(Release) dir current Type[${_CMAKE_CONF_BUILD_TYPE}]")
endif()
if (COMPILER MATCHES "PC_LIN32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
elseif (COMPILER MATCHES "PC_LIN64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
elseif (COMPILER MATCHES "ANDROID")
include_directories(App/Includes/Platform/${COMPILER})
endif()
if (CMAKE_C_COMPILER MATCHES "arm-linux-gnueabihf-gcc")
#for lib muduo_base TODO: to check hisiv400�?----
add_definitions("-DHisiGccV300")
endif()
endif()
##----------------------------------------------------------------------------------
if (DEFINED _AV_WARE_CODE_GUI)
set(_AV_WARE_M_HAVE_UI "ON")
endif()
if (UI_CLOSE_CAPUTRE STREQUAL "ON")
set (_AV_WARE_M_HAVE_UI_CLOSE_CAPUTRE "ON")
endif()
if(_CMAKE_CONFIG_M_HAVE_EXT_NETMANAGE STREQUAL "ON")
set(_AV_WARE_M_HAVE_EXT_NETMANAGE "ON")
endif()
if(_CMAKE_CONFIG_M_HAVE_WIFI STREQUAL "ON")
set(_AV_WARE_M_HAVE_WIFI "ON")
endif()
if(_CMAKE_CONFIG_M_HAVE_SIM STREQUAL "ON")
set(_AV_WARE_M_HAVE_SIM "ON")
endif()
if (_CMAKE_CONFIG_DEBUG STREQUAL "ON")
set(_AV_WARE_DEBUG "ON")
#add_definitions("-DMEMWATCH -DMW_STDIO")
endif()
if (_CMAKE_CONFIG_CONSOLE STREQUAL "ON")
set(_AV_WARE_CONSOLE "ON")
endif()
##----------------------------------------------------------------------------------
configure_file (
"${PROJECT_SOURCE_DIR}/config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__AV_WARE_FILE__='\"$(subst ${CMAKE_CURRENT_SOURCE_DIR}/,,$(abspath $<))\"'")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__AV_WARE_FILE__='\"$(subst ${CMAKE_CURRENT_SOURCE_DIR}/,,$(abspath $<))\"'")
message("")
message("")
message("##[Top CMakeLists] COMPILER [${COMPILER}]")
message("##[Top CMakeLists] BUILD_TYPE [${CMAKE_BUILD_TYPE}]")
message("##[Top CMakeLists] Build Msg [${CMAKE_VERBOSE_MAKEFILE}]")
message("##[Top CMakeLists] QtHomePath [${CMAKE_QT_PATH}]")
message("##[Top CMakeLists] GUI [${_AV_WARE_CODE_GUI}]")
message("##[Top CMakeLists] SYS_CHN_NUM [${SYS_CHN_NUM}]")
message("##[Top CMakeLists] UI_C_CAPUTRE [${UI_CLOSE_CAPUTRE}]")
message("##[Top CmakeLists] CC [${CMAKE_C_COMPILER}] ")
message("##[Top CmakeLists] CX [${CMAKE_CXX_COMPILER}] ")
#if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Platform/${COMPILER}")
# add_subdirectory(Platform/${COMPILER})
# message("##[Top CMakeLists] Platform Dir [Platform/${COMPILER}]")
#else()
# add_subdirectory(Platform/X86Architecture)
# message("##[Top CMakeLists] Platform Dir [Platform/X86Architecture]")
#endif()
#message("")
#add_subdirectory(Platform/PlatformTools)
add_subdirectory(App)
if (ANDROID)
set(CMAKE_PREFIX_PATH "$ENV{Qt5_android}/lib/cmake/Qt5")
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Qml Quick Gui)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/App/CMake/${COMPILER}/libs/${ARM_TARGET}/)
add_subdirectory(App/CMake/${COMPILER})
endif()
###record for knight
#set(TOOLCHAIN_DIR "/home/ProgamApp/ToolChain/hisi-linux-nptl/arm-hisiv300-linux/target")
#set(CMAKE_FIND_ROOT_PATH ${TOOLCHAIN_DIR})
#set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
#set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
#set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
#set(CMAKE_C_COMPILER ${TOOLCHAIN_DIR}/bin/arm-hisiv300-linux-gcc)
#set(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/bin/arm-hisiv300-linux-g++)
#file(DOWNLOAD "http://graceport.tpddns.cn:880/bg.jpg" "${PROJECT_BINARY_DIR}/bg.jpg" TIMEOUT 600 STATUS __status)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化