Commit 247f6c56 authored by zhengxuexing's avatar zhengxuexing

init commit

parent 54bab429
Pipeline #36 canceled with stages
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Global Config
cmake_minimum_required(VERSION 3.12.0)
# Global Setting
set(PROJ_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(CMAKE_TOOLCHAIN_ROOT ${PROJ_ROOT}/scripts/cmake)
include(${CMAKE_TOOLCHAIN_ROOT}/cmake-core/global.cmake)
message("PROJECT_ROOT = ${PROJ_ROOT} ")
message("CMAKE_TOOLCHAIN_ROOT = ${CMAKE_TOOLCHAIN_ROOT} ")
message("include(${CMAKE_TOOLCHAIN_ROOT}/cmake-core/global.cmake) ")
project(${PROJECT_NAME} VERSION 1.0.0.0)
set(LIB_BUILD_TYPE_EXT )
set(LIB_TYPE SHARED) # SHARED STATIC
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
message("PROJECT_NAME = ${PROJECT_NAME} ")
message("LIB_TYPE = ${LIB_TYPE} ")
# platform options
option(WIN "Build for Windows" OFF)
option(LINUX "Build for Linux" OFF)
option(OSX "Build for MacOSX" OFF)
option(IOS "Build for IOS" OFF)
option(ANDROID "Build for Android" OFF)
set(META_FILES )
if(WIN)
set(LIB_TYPE STATIC) # SHARED STATIC
set(WIN32 ON)
set(OS_TYPE "win")
set(OS_BUNDLE WIN32)
add_definitions(-DWIN)
include(${CMAKE_TOOLCHAIN_ROOT}/cmake-win/win_func.cmake)
WIN_ADD_META(META_FILES) # Add Resource To Project - eg. AppIcon.ico
APP_ADD_RES("${CMAKE_TOOLCHAIN_ROOT}/cmake-win/res/*.*" "Resources/")
elseif(LINUX)
set(OS_TYPE "linux")
add_definitions(-DLINUX)
elseif(OSX)
set(APPLE ON)
set(OS_TYPE "osx")
set(OS_BUNDLE MACOSX_BUNDLE)
set(OS_MIN_VERSION 10.13)
add_definitions(-DOSX )
# set OSX Libs
set(LIB_FMWKs)
include(${CMAKE_TOOLCHAIN_ROOT}/cmake-apple/apple_libs.cmake)
include(${CMAKE_TOOLCHAIN_ROOT}/cmake-apple/apple_func.cmake)
XCODE_ADD_META(META_FILES) # Add Resource To Project - eg. Info.plist, AppIcon.icns
APP_ADD_RES("${CMAKE_TOOLCHAIN_ROOT}/cmake-apple/res/AppIcon.icns" "Resources/")
elseif(IOS)
set(APPLE ON)
set(OS_TYPE "iOS")
set(OS_MIN_VERSION 10.0)
add_definitions(-DIOS )
elseif(ANDROID)
set(OS_TYPE "linux")
add_definitions(-DANDROID )
endif()
# project resources
# set(CONF_FILES ${PROJ_ROOT}/conf/project.json)
# set(CONF_FILES ${PROJ_ROOT}/conf/AirportList.json)
set(CONF_DIR ${PROJ_ROOT}/conf)
File(GLOB_RECURSE CONF_FILES ${CONF_DIR}/*.*)
if(NOT ANDROID)
source_group(
TREE ${CONF_DIR}
PREFIX "conf"
FILES ${CONF_FILES}
)
endif(NOT ANDROID)
set(TOOLS_DIR ${PROJ_ROOT}/tools)
File(GLOB_RECURSE TOOLS_FILEs ${TOOLS_DIR}/*.*)
if(NOT ANDROID)
source_group(
TREE ${TOOLS_DIR}
PREFIX "plugins"
FILES ${TOOLS_FILEs}
)
endif(NOT ANDROID)
# MODULE options
option(WITH_PY "Build with PY " OFF)
option(WITH_QT "Build with QT " ON)
option(ViConfigTool "Build with ViConfigTool " ON)
option(QLandscapeDB "Build with QLandscapeDB " ON)
option(QtCoreKit "Build with QtCoreKit " ON)
option(CCoreKit "Build with CCoreKit " ON)
# option(MODULE_OPTION "Build with MODULE_OPTION" ON)
if(WITH_QT)
include(${CMAKE_TOOLCHAIN_ROOT}/cmake-qt/qt_func.cmake)
QT_INIT(${QT_INSTALL_DIR})
# set Qt include and libs
set(INC_QT)
set(LIB_QT)
include(${CMAKE_TOOLCHAIN_ROOT}/cmake-qt/qt_libs.cmake)
message("INC_QT=${INC_QT}")
message("LIB_QT=${LIB_QT}")
endif(WITH_QT)
if(WITH_PY)
# set Qt include and libs
set(INC_PY)
set(LIB_PY)
include(${CMAKE_TOOLCHAIN_ROOT}/cmake-py/py_libs.cmake)
message("INC_PY=${INC_PY}")
message("LIB_PY=${LIB_PY}")
endif(WITH_PY)
# subdirectory
set(INC_FILES)
set(SRC_FILES)
set(INC_GROUP ${PROJ_ROOT}/src/app ${PROJ_ROOT}/src/modules)
include(${PROJ_ROOT}/src/app/app.cmake)
include(${PROJ_ROOT}/src/modules/modules.cmake)
# include(Module-Group.cmake)
# add_subdirectory(Module-Group-Dir)
message("INC_FILES=${INC_FILES}")
message("SRC_FILES=${SRC_FILES}")
{
"scenes" : [
{
"id" : 0,
"name" : "全局",
"persit" : true,
"preload" : true
},
{
"id" : 1,
"name" : "shengyang机场",
"persit" : true,
"preload" : true
},
{
"id" : 2,
"name" : "首都国际机场",
"persit" : true,
"preload" : true
},
{
"id" : 3,
"name" : "北京大兴机场",
"persit" : true,
"preload" : true
},
{
"id" : 4,
"name" : "上海虹桥机场",
"persit" : true,
"preload" : true
},
{
"id" : 5,
"name" : "上海浦东机场",
"persit" : true,
"preload" : true
},
{
"id" : 6,
"name" : "葫芦岛机场",
"persit" : true,
"preload" : true
},
{
"id" : 7,
"name" : "青岛流亭机场",
"persit" : true,
"preload" : true
},
{
"id" : 8,
"name" : "珠海机场",
"persit" : true,
"preload" : true
},
{
"id" : 9,
"name" : "胶东国际机场",
"persit" : true,
"preload" : true
},
{
"id" : 10,
"name" : "成都双流机场",
"persit" : true,
"preload" : true
},
{
"id" : 11,
"name" : "白云机场",
"persit" : true,
"preload" : true
}
]
}
\ No newline at end of file
{
"airport_max_num":5
}
\ No newline at end of file
{
"dir_codes": [
{
"group": "QtAPP",
"group_dir": "/src/app",
"modules": [
{
"deps": [
"QLandscapeDB",
"QtCoreKit",
"CCoreKit"
],
"gen_lib": "NO",
"module": "ViConfigTool",
"option": "ON"
}
]
},
{
"group": "QtKit",
"group_dir": "/src/modules",
"modules": [
{
"deps": [
"QtCoreKit",
"CCoreKit"
],
"gen_lib": "YES",
"module": "QLandscapeDB",
"option": "ON"
},
{
"deps": [
"CCoreKit"
],
"gen_lib": "YES",
"module": "QtCoreKit",
"option": "ON"
},
{
"deps": [
],
"gen_lib": "YES",
"module": "CCoreKit",
"option": "ON"
}
]
}
],
"dir_help": {
"conf": "conf",
"doc": "doc",
"scripts": "scripts",
"tools": "tools"
},
"dir_proj": "C:/Users/coder/Desktop/ViConfigTool",
"options": {
"WITH_PY": "OFF",
"WITH_QT": "ON"
},
"proj_name": "ViConfigTool"
}
#!/bin/bash
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ${script_dir}
# set var
APP_NAME=ViConfigTool
QT_DIR="$HOME/Qt5.14.2/"
QT_INSTALL_DIR="$QT_DIR/5.14.2/clang_64/"
PY_INSTALL_DIR="/Applications/Xcode.app/Contents/Developer/Library"
ROOT_DIR=${script_dir}/../..
BUILD_DIR=${ROOT_DIR}/build_unix
BIN_DIR=${ROOT_DIR}/bin
function do_mkdir() {
if [[ -d ${BUILD_DIR} ]]; then
rm -rf ${BUILD_DIR}
fi
mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
if [[ -d ${BIN_DIR} ]]; then
rm -rf ${BIN_DIR}
fi
}
function do_gen {
# Unix Makefiles, Xcode
generator=-G"Unix Makefiles"
platform=LINUX
if [[ `uname` == "Darwin" ]]; then
generator="-GXcode"
platform="OSX"
fi
cmake -Wno-dev ${ROOT_DIR} ${generator} -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$BUILD_DIR \
-DEXECUTABLE_OUTPUT_PATH=$BIN_DIR \
-DQT_INSTALL_DIR=${QT_INSTALL_DIR} \
-DPY_INSTALL_DIR=${PY_INSTALL_DIR} \
-DPROJECT_NAME=${APP_NAME} -D${platform}=ON -H$ROOT_DIR -B$BUILD_DIR
}
function walk_dir() {
rm -rf $1/.DS_Store
rm -rf $1/__pycache__
for child in `ls $1`
do
if [ -d $1"/"$child ]; then
walk_dir $1"/"$child
fi
done
}
function clean_plugins() {
PLIGUN_DIR=${ROOT_DIR}/../plugins
if [[ -d $PLIGUN_DIR ]]; then
walk_dir $PLIGUN_DIR
fi
}
function do_open() {
if [[ `uname` == "Darwin" ]]; then
# xcodebuild -project ${BUILD_DIR}/${APP_NAME}.xcodeproj -scheme install -configuration Release build
open ${BUILD_DIR}/${APP_NAME}.xcodeproj
else
make
make install
fi
}
do_mkdir
clean_plugins
do_gen
do_open
\ No newline at end of file
@REM MIT License
@REM
@REM Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
@REM
@REM Permission is hereby granted, free of charge, to any person obtaining a copy
@REM of this software and associated documentation files (the "Software"), to deal
@REM in the Software without restriction, including without limitation the rights
@REM to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@REM copies of the Software, and to permit persons to whom the Software is
@REM furnished to do so, subject to the following conditions:
@REM
@REM The above copyright notice and this permission notice shall be included in all
@REM copies or substantial portions of the Software.
@REM
@REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
@REM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
@REM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@REM AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
@REM LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
@REM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
@REM SOFTWARE.
@REM
@echo off
::set var
SET APP_NAME=ViConfigTool
SET ROOT_DIR=%~dp0\..\..
SET BUILD_DIR=%ROOT_DIR%\build_win
SET BIN_DIR=%ROOT_DIR%\bin64
:: https://www.cnblogs.com/doudougou/archive/2011/08/22/2148851.html
@REM REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\devenv.exe"
SET VS_EXE="C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe"
SET QT_INSTALL_DIR="D:/ProgramFiles/Qt5.14.2/5.14.2/msvc2017_64/"
SET PY_INSTALL_DIR=%LOCALAPPDATA%/"Programs/Python/Python311-32"
SET VS_PROJ="%BUILD_DIR%\%APP_NAME%.sln"
::echo var
echo APP_NAME = %APP_NAME%
echo ROOT_DIR = %ROOT_DIR%
echo BUILD_DIR = %BUILD_DIR%
echo VS_EXE = %VS_EXE%
echo VS_PROJ = %VS_PROJ%
echo QT_INSTALL_DIR = %QT_INSTALL_DIR%
echo PY_INSTALL_DIR = %PY_INSTALL_DIR%
:: make %BUILD_DIR% and cd %BUILD_DIR%
:: cd %ROOT_DIR%
if exist %BUILD_DIR% rd /s /q %BUILD_DIR%
md %BUILD_DIR%
if exist %BIN_DIR% rd /s /q %BIN_DIR%
:: clean py cache
SET PLUGIN_DIR=%ROOT_DIR%\..\plugins
echo PLUGIN_DIR = %PLUGIN_DIR%
for /f "delims=" %%i in ('dir /ad/b/s "%PLUGIN_DIR%"') do (
if exist %%i\.DS_Store rd /s /q %%i\.DS_Store
if exist %%i\__pycache__ rd /s /q %%i\__pycache__
)
:: run cmake: gen vs-project
:: -G"Visual Studio 15 2017"
:: -G"Visual Studio 16 2019"
:: -G"Visual Studio 17 2022"
cmake -Wno-dev %ROOT_DIR% -G"Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release -DPROJECT_NAME=%APP_NAME% -DCMAKE_INSTALL_PREFIX=%BUILD_DIR% -DCMAKE_PREFIX_PATH=%QT_INSTALL_DIR% -DEXECUTABLE_OUTPUT_PATH=%BIN_DIR% -DQT_INSTALL_DIR=%QT_INSTALL_DIR% -DPY_INSTALL_DIR=%PY_INSTALL_DIR% -DWIN=ON -H%ROOT_DIR% -B%BUILD_DIR%
if exist %VS_PROJ% start %VS_EXE% %VS_PROJ%
echo. & pause
\ No newline at end of file
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set(CURRENT_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
# eg. XCODE_SETTING(<SDK> 9.0/10.13)
function(XCODE_SETTING target_name min_version)
if(IOS OR OSX)
# Deployment Postprocess
XCODE_DEPLOYMENT_POSTPROCESSING(${target_name})
# Generate Debug Symbols
XCODE_DEBUG_SYMBOLS(${target_name})
# XCode Debug Information Format
XCODE_DEBUG_INFO_FMT(${target_name})
# XCode Strip Linked Product
XCODE_STRIP_INSTALLED_PRODUCT(${target_name})
set_target_properties( ${target_name} PROPERTIES
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17"
XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL[variant=Release] s
XCODE_ATTRIBUTE_LLVM_LTO[variant=Release] YES
XCODE_ATTRIBUTE_GCC_INPUT_FILETYPE sourcecode.cpp.objcpp # objc++
XCODE_ATTRIBUTE_OTHER_CFLAGS[variant=Release] "-fembed-bitcode"
XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode"
)
endif()
if(IOS)
set_target_properties( ${target_name} PROPERTIES
XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${min_version}
XCODE_ATTRIBUTE_ARCHS "arm64"
XCODE_ATTRIBUTE_SDKROOT iphoneos
)
# append flags for XCODE_ATTRIBUTE_GCC_PREPROCESSOR_DEFINITIONS
# https://blog.csdn.net/whatday/article/details/104376582/
# https://www.cnblogs.com/Need4Speak/p/5397949.html
# add_definitions(-D __IOS__=1)
target_compile_definitions(${target_name} PUBLIC __IOS__ )
elseif(OSX)
set_target_properties( ${target_name} PROPERTIES
XCODE_ATTRIBUTE_MACOSX_DEPLOYMENT_TARGET ${min_version}
XCODE_ATTRIBUTE_ARCHS "x86_64"
XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "--deep" # for Error "codesign": code object is not signed at all
XCODE_ATTRIBUTE_SDKROOT macosx
)
# append flags for XCODE_ATTRIBUTE_GCC_PREPROCESSOR_DEFINITIONS
# add_definitions(-D __OSX__=1)
target_compile_definitions(${target_name} PUBLIC __OSX__ )
endif()
endfunction(XCODE_SETTING)
######################################## IOS && OSX universal ########################################
# XCode Deployment Postprocessing : Default value is YES after XCode 9.1, always used for app slim down.
# NO : keep non-essential compile symbol. e.g. debug symbol.
# YES : delete non-essential compile symbol and protect app. e.g. debug symbol.
function(XCODE_DEPLOYMENT_POSTPROCESSING target_name)
if(IOS OR OSX)
set_target_properties( ${target_name} PROPERTIES
XCODE_ATTRIBUTE_DEPLOYMENT_POSTPROCESSING[variant=Debug] "NO"
XCODE_ATTRIBUTE_DEPLOYMENT_POSTPROCESSING[variant=MinSizeRel] "YES"
XCODE_ATTRIBUTE_DEPLOYMENT_POSTPROCESSING[variant=RelWithDebInfo] "NO"
XCODE_ATTRIBUTE_DEPLOYMENT_POSTPROCESSING[variant=Release] "YES"
)
endif()
endfunction(XCODE_DEPLOYMENT_POSTPROCESSING)
# XCode Generate Debug Symbols : always used for app slim down.
function(XCODE_DEBUG_SYMBOLS target_name)
if(IOS OR OSX)
set_target_properties( ${target_name} PROPERTIES
XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Debug] "YES"
XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=MinSizeRel] "NO"
XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=RelWithDebInfo] "YES"
XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Release] "NO"
)
endif()
endfunction(XCODE_DEBUG_SYMBOLS)
# XCode Debug Information Format
function(XCODE_DEBUG_INFO_FMT target_name)
if(IOS OR OSX)
set_target_properties( ${target_name} PROPERTIES
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Debug] "dwarf-with-dsym"
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=MinSizeRel] "dwarf"
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=RelWithDebInfo] "dwarf-with-dsym"
XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Release] "dwarf"
)
endif()
endfunction(XCODE_DEBUG_INFO_FMT)
# XCode Strip Linked Product
function(XCODE_STRIP_INSTALLED_PRODUCT target_name)
if(IOS OR OSX)
set_target_properties( ${target_name} PROPERTIES
XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT[variant=Debug] "NO"
XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT[variant=MinSizeRel] "YES"
XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT[variant=RelWithDebInfo] "NO"
XCODE_ATTRIBUTE_STRIP_INSTALLED_PRODUCT[variant=Release] "YES"
)
endif()
endfunction(XCODE_STRIP_INSTALLED_PRODUCT)
# Strip Debug Symbols During Copy
# function(XCODE_DEBUG_SYMBOLS_DURING_COPY target_name)
# if(IOS OR OSX)
# set_target_properties( ${target_name} PROPERTIES
# XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Debug] "NO"
# XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=MinSizeRel] "YES"
# XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=RelWithDebInfo] "NO"
# XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT[variant=Release] "YES"
# )
# endif()
# endfunction(XCODE_DEBUG_SYMBOLS_DURING_COPY)
######################################## XCode Add Files ########################################
# [CMake中的function和macro](https://blog.csdn.net/fb_941219/article/details/89358576)
# [CMake(Normal Variable And Function)](https://www.cnblogs.com/Braveliu/p/15600782.html)
# var META_FILES required
function(XCODE_ADD_META)
if (APPLE)
set(ICON_NAME AppIcon)
set(ICON_FILE ${CURRENT_CMAKE_DIR}/res/${ICON_NAME}.icns)
set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
# Identify MacOS bundle
set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
set(MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION})
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
set(MACOSX_BUNDLE_COPYRIGHT ${COPYRIGHT})
set(MACOSX_BUNDLE_GUI_IDENTIFIER ${IDENTIFIER})
set(MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
set(META_FILES ${ICON_FILE} PARENT_SCOPE) # PARENT_SCOPE make change avaliable outside fucntion
endif()
endfunction(XCODE_ADD_META)
function(XCODE_ADD_INFO_PLIST bin_name)
if (IOS)
configure_file(${CURRENT_CMAKE_DIR}/res/IOSBundleInfo.plist.in ${PROJECT_BINARY_DIR}/Info.plist)
set_target_properties(${bin_name} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/Info.plist)
elseif(OSX)
configure_file(${CURRENT_CMAKE_DIR}/res/MacOSXBundleInfo.plist.in ${PROJECT_BINARY_DIR}/Info.plist)
set_target_properties(${bin_name} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/Info.plist)
endif()
endfunction(XCODE_ADD_INFO_PLIST)
\ No newline at end of file
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
if(OSX)
## OpenGL && Foundation && Metal && QuartzCore
find_package(OpenGL REQUIRED)
find_library(LIB_FOUNDATION Foundation)
find_library(LIB_QC QuartzCore)
find_library(LIB_METAL Metal)
SET(LIB_FMWKs ${LIB_FMWKs} ${OpenGL} ${LIB_FOUNDATION} ${LIB_QC} ${LIB_METAL})
endif(OSX)
\ No newline at end of file
# This file is based off of the Platform/Darwin.cmake and Platform/UnixPaths.cmake
# files which are included with CMake 2.8.4
# It has been altered for iOS development
# Options:
#
# IOS_PLATFORM = OS (default) or SIMULATOR or SIMULATOR64
# This decides if SDKS will be selected from the iPhoneOS.platform or iPhoneSimulator.platform folders
# OS - the default, used to build for iPhone and iPad physical devices, which have an arm arch.
# SIMULATOR - used to build for the Simulator platforms, which have an x86 arch.
#
# CMAKE_IOS_DEVELOPER_ROOT = automatic(default) or /path/to/platform/Developer folder
# By default this location is automatcially chosen based on the IOS_PLATFORM value above.
# If set manually, it will override the default location and force the user of a particular Developer Platform
#
# CMAKE_IOS_SDK_ROOT = automatic(default) or /path/to/platform/Developer/SDKs/SDK folder
# By default this location is automatcially chosen based on the CMAKE_IOS_DEVELOPER_ROOT value.
# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
# If set manually, this will force the use of a specific SDK version
# Macros:
#
# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE)
# A convenience macro for setting xcode specific properties on targets
# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1")
#
# find_host_package (PROGRAM ARGS)
# A macro used to find executable programs on the host system, not within the iOS environment.
# Thanks to the android-cmake project for providing the command
# Standard settings
set (CMAKE_SYSTEM_NAME Darwin)
set (CMAKE_SYSTEM_VERSION 1)
set (UNIX True)
set (APPLE True)
set (IOS True)
# Required as of cmake 2.8.10
set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
# Determine the cmake host system version so we know where to find the iOS SDKs
find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
if (CMAKE_UNAME)
exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
endif (CMAKE_UNAME)
# Force the compilers to gcc for iOS
include (CMakeForceCompiler)
#CMAKE_FORCE_C_COMPILER (/usr/bin/gcc Apple)
set(CMAKE_C_COMPILER /usr/bin/gcc)
set(CMAKE_C_COMPILER_ID Apple)
#CMAKE_FORCE_CXX_COMPILER (/usr/bin/g++ Apple)
set(CMAKE_CXX_COMPILER /usr/bin/g++)
set(CMAKE_CXX_COMPILER_ID Apple)
set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
# Skip the platform compiler checks for cross compiling
set (CMAKE_CXX_COMPILER_WORKS TRUE)
set (CMAKE_C_COMPILER_WORKS TRUE)
# All iOS/Darwin specific settings - some may be redundant
set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
set (CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
set (CMAKE_SHARED_MODULE_PREFIX "lib")
set (CMAKE_SHARED_MODULE_SUFFIX ".so")
set (CMAKE_MODULE_EXISTS 1)
set (CMAKE_DL_LIBS "")
set (CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
# Hidden visibilty is required for cxx on iOS
set (CMAKE_C_FLAGS_INIT "")
set (CMAKE_CXX_FLAGS_INIT "-fvisibility=hidden -fvisibility-inlines-hidden")
set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
set (CMAKE_PLATFORM_HAS_INSTALLNAME 1)
set (CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -headerpad_max_install_names")
set (CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -headerpad_max_install_names")
set (CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
set (CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
# hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree
# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
# Setup iOS platform unless specified manually with IOS_PLATFORM
if (NOT DEFINED IOS_PLATFORM)
set (IOS_PLATFORM "OS")
endif (NOT DEFINED IOS_PLATFORM)
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
# Setup building for arm64 or not
if (NOT DEFINED BUILD_ARM64)
set (BUILD_ARM64 true)
endif (NOT DEFINED BUILD_ARM64)
set (BUILD_ARM64 ${BUILD_ARM64} CACHE STRING "Build arm64 arch or not")
# Check the platform selection and setup for developer root
if (${IOS_PLATFORM} STREQUAL "OS")
set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
# This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
set (SIMULATOR true)
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
# This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR64")
set (SIMULATOR true)
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
# This causes the installers to properly locate the output libraries
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
else (${IOS_PLATFORM} STREQUAL "OS")
message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR")
endif (${IOS_PLATFORM} STREQUAL "OS")
# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT
# Note Xcode 4.3 changed the installation location, choose the most recent one available
exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR)
set (XCODE_POST_43_ROOT "${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
if (EXISTS ${XCODE_POST_43_ROOT})
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
elseif(EXISTS ${XCODE_PRE_43_ROOT})
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
endif (EXISTS ${XCODE_POST_43_ROOT})
endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT
if (NOT DEFINED CMAKE_IOS_SDK_ROOT)
file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
if (_CMAKE_IOS_SDKS)
list (SORT _CMAKE_IOS_SDKS)
list (REVERSE _CMAKE_IOS_SDKS)
list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
else (_CMAKE_IOS_SDKS)
message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
endif (_CMAKE_IOS_SDKS)
message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
endif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
# Set the sysroot default to the most recent SDK
set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
# set the architecture for iOS
if (${IOS_PLATFORM} STREQUAL "OS")
set (IOS_ARCH armv7 armv7s arm64)
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
set (IOS_ARCH i386)
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR64")
set (IOS_ARCH x86_64)
endif (${IOS_PLATFORM} STREQUAL "OS")
set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS")
# Set the find root to the iOS developer roots and to user defined paths
set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root")
# default to searching for frameworks first
set (CMAKE_FIND_FRAMEWORK FIRST)
# set up the default search directories for frameworks
set (CMAKE_SYSTEM_FRAMEWORK_PATH
${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks
${CMAKE_IOS_SDK_ROOT}/System/Library/PrivateFrameworks
${CMAKE_IOS_SDK_ROOT}/Developer/Library/Frameworks
)
# only search the iOS sdks, not the remainder of the host filesystem
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# This little macro lets you set any XCode specific property
macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
endmacro (set_xcode_property)
# This macro lets you find executable programs on the host system
macro (find_host_package)
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
set (IOS FALSE)
find_package(${ARGN})
set (IOS TRUE)
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endmacro (find_host_package)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2021年 coder4869. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
<key>BuildMachineOSBuild</key>
<string>20D91</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string></string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string></string>
<key>CSResourcesFileMapped</key>
<true/>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>12E5220o</string>
<key>DTPlatformName</key>
<string>macosx</string>
<key>DTPlatformVersion</key>
<string>11.3</string>
<key>DTSDKBuild</key>
<string>20E5172i</string>
<key>DTSDKName</key>
<string>macosx11.3</string>
<key>DTXcode</key>
<string>1250</string>
<key>DTXcodeBuild</key>
<string>12E5220o</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>LSRequiresCarbon</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>使用相机</string>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>添加图片/视频到相册</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>使用相册</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2021年 coder4869. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#### Build Optimization
# https://blog.csdn.net/weixin_33724570/article/details/89731190
# https://blog.csdn.net/weixin_39716160/article/details/116607853
message("Build Options Setting !!!")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--fix-cortex-a8" CACHE INTERNAL "" FORCE)
endif()
# --fatal-warnings will take all warnings as error, same to -Werror. Here cancel the limit!
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-fatal-warnings" CACHE INTERNAL "" FORCE)
# [clang LTO is broken with __thread variables #498](https://github.com/android-ndk/ndk/issues/498)
# Workaround is -Wl,-plugin-opt=-emulated-tls
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-plugin-opt=-emulated-tls" CACHE INTERNAL "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fPIC " CACHE INTERNAL "" FORCE)
if(NOT APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--as-needed" CACHE INTERNAL "" FORCE)
endif(APPLE)
if(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CMAKE_BUILD_TYPE Debug)
set(LIB_BUILD_TYPE_EXT d)
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
set(CMAKE_BUILD_TYPE Release)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# For Debug and RelWithDebInfo
add_definitions(-D DEBUG)
set(CMAKE_CONFIGURATION_TYPES "Debug" CACHE STRING "" FORCE)
set(LIB_BUILD_TYPE_EXT d)
add_compile_options(
"-Wall" "-fexceptions"
"$<$<CONFIG:Debug>:-O0;-g3;-ggdb>"
)
elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
# For Release and MinSizeRel
add_definitions(-D NDDEBUG)
set(CMAKE_CONFIGURATION_TYPES "Release" CACHE STRING "" FORCE)
add_compile_options(
"-Wall" "-fexceptions"
"$<$<CONFIG:Release>:-flto;-O3>"
)
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto -O3 " CACHE INTERNAL "" FORCE)
if(NOT APPLE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,ALL " CACHE INTERNAL "" FORCE)
endif(APPLE)
# gold linker has error for Cortex-A53 on aarch64, Remove icf(reduce lib size) for it.
if((CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7-a") OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86") OR (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"))
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--icf=safe" CACHE INTERNAL "" FORCE)
endif()
else()
message("Unknown CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} !")
endif(CMAKE_BUILD_TYPE)
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF(NOT "${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF(NOT "${rm_retval}" STREQUAL 0)
ENDFOREACH(file)
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# e.g. SET_POLICY()
function(SET_POLICY)
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()
endfunction(SET_POLICY)
# e.g. SET_CXX_VERSION("c++17")
# [C++ Standard](https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD.html)
# [add_compile_options() and CMAKE_CXX_FLAGS](http://t.zoukankan.com/Irvingcode-p-12952543.html)
function(SET_CXX_VERSION version)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:${version}")
else()
# set(CMAKE_CXX_STANDARD 17)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=${version}")
endif()
endfunction(SET_CXX_VERSION)
# e.g.
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# set(CONF_FILES ${PROJ_ROOT}/conf/project.json)
# add_executable(${PROJECT_NAME} ${OS_BUNDLE} ${SRC_FILES} ${CONF_FILES})
# APP_ADD_RES("${PROJ_ROOT}/conf/project.json" "Resources/")
function(APP_ADD_RES src_files dst_dir)
File(GLOB TARGET_FILEs ${src_files})
# message("APP_ADD_RES() TARGET_FILEs = ${TARGET_FILEs} ; src_files = ${src_files} ; dst_dir = ${dst_dir} ")
if(APPLE)
set_source_files_properties(${TARGET_FILEs} PROPERTIES MACOSX_PACKAGE_LOCATION ${dst_dir})
elseif(WIN32)
file(COPY ${TARGET_FILEs} DESTINATION ${EXECUTABLE_OUTPUT_PATH}/${dst_dir})
endif(WIN32)
endfunction(APP_ADD_RES)
# e.g.
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
# set(PLUGIN_DIR ${PROJ_ROOT}/../plugins)
# File(GLOB_RECURSE PLUGIN_FILEs ${PLUGIN_DIR}/*.*)
# if(NOT ANDROID)
# source_group(
# TREE ${PLUGIN_DIR}
# PREFIX "plugins"
# FILES ${PLUGIN_FILEs}
# )
# endif(NOT ANDROID)
# add_executable(${PROJECT_NAME} ${OS_BUNDLE} ${SRC_FILES} ${PLUGIN_FILEs})
# APP_ADD_RES_RECURSE("${PLUGIN_DIR}/" "Resources/plugins/" "${PLUGIN_DIR}/*.*")
function(APP_ADD_RES_RECURSE src_dir dst_dir src_files)
get_filename_component(src_dir ${src_dir} ABSOLUTE)
message("APP_ADD_RES_RECURSE() src_dir = ${src_dir} ; dst_dir = ${dst_dir} ; src_files = ${src_files} ")
File(GLOB_RECURSE TARGET_FILEs ${src_files})
if(APPLE)
foreach(file_path ${TARGET_FILEs})
get_filename_component(file_abs_path ${file_path} ABSOLUTE)
# get_filename_component(file_abs_path ${file_path} REALPATH)
get_filename_component(file_dir_path ${file_abs_path} PATH)
set(dst_path)
# string(REPLACE <match-string> <replace-string> <out-var> <input>...)
string(REPLACE ${src_dir} "${dst_dir}/" dst_path ${file_dir_path})
message("APP_ADD_RES_RECURSE() file_path=${file_path} ; dst_path=${dst_path}")
set_source_files_properties(${file_path} PROPERTIES MACOSX_PACKAGE_LOCATION ${dst_path})
endforeach(file_path)
elseif(WIN32)
foreach(file_path ${TARGET_FILEs})
get_filename_component(file_abs_path ${file_path} ABSOLUTE)
# get_filename_component(file_abs_path ${file_path} REALPATH)
get_filename_component(file_dir_path ${file_abs_path} PATH)
set(dst_path)
# string(REPLACE <match-string> <replace-string> <out-var> <input>...)
string(REPLACE ${src_dir} "${dst_dir}/" dst_path ${file_dir_path})
message("APP_ADD_RES_RECURSE() file_path=${file_path}; dst_path=${dst_path}")
file(COPY ${file_path} DESTINATION ${EXECUTABLE_OUTPUT_PATH}/${dst_path})
endforeach(file_path)
endif(WIN32)
endfunction(APP_ADD_RES_RECURSE)
# e.g. cmake .. -DCMAKE_INSTALL_PREFIX=$BUILD_DIR
# based on CMAKE_INSTALL_PREFIX
function(INSTALL_INC from_dir to_dir)
INSTALL(DIRECTORY ${from_dir} DESTINATION ${to_dir}
FILES_MATCHING
PATTERN "Forms" EXCLUDE # For Qt
PATTERN "pimp" EXCLUDE # For Private Implement
PATTERN "*.h" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
PATTERN "*.hpp" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
PATTERN "*.inc" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ
)
endfunction(INSTALL_INC)
# lib bin exe
function(INSTALL_TARGET sdk_name)
# include(GNUInstallDirs)
INSTALL(TARGETS ${sdk_name}
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin # exe & dynamic lib
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endfunction(INSTALL_TARGET)
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
include(${CMAKE_CURRENT_LIST_DIR}/core_func.cmake)
message("include(${CMAKE_CURRENT_LIST_DIR}/core_func.cmake) ")
SET_POLICY()
SET_CXX_VERSION("c++17")
# Compiler
# set(CMAKE_C_COMPILER "/usr/local/gcc/bin/gcc")
# set(CMAKE_CXX_COMPILER "/usr/local/gcc/bin/g++")
include(${CMAKE_CURRENT_LIST_DIR}/build_options.cmake)
message("include(${CMAKE_CURRENT_LIST_DIR}/build_options.cmake) ")
\ No newline at end of file
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
if(NOT COMMAND find_host_program)
macro(find_host_program)
find_program(${ARGN})
endmacro()
endif()
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# e.g.
# set(PY_INSTALL_DIR "/usr/local/Cellar/python@3.10/3.10.8/")
# PY_INIT(${PY_INSTALL_DIR})
macro(PY_INIT install_dir)
endmacro()
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
if(WITH_PY)
if(WIN) # for windows
SET(INC_PY ${PY_INSTALL_DIR}/include )
SET(LIB_PY ${PY_INSTALL_DIR}/libs/python3.lib )
elseif(OSX) # for MacOSX
# /Applications/Xcode.app/Contents/Developer/Library
SET(INC_PY ${PY_INSTALL_DIR}/Frameworks/Python3.framework/Headers )
# SET(LIB_PY ${PY_INSTALL_DIR}/Frameworks/Python3.framework/Python )
find_library(LIB_PY Python3)
SET(LIB_FMWKs ${LIB_FMWKs} ${LIB_PY} )
endif(OSX)
endif(WITH_PY)
\ No newline at end of file
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# e.g.
# SET(Qt5_INSTALL_DIR "$HOME/Qt/5.14.2/clang_64/")
# QT_INIT(${Qt5_INSTALL_DIR})
macro(QT_INIT install_dir)
# Let's do the CMake job for us
set(CMAKE_AUTOMOC ON) # For meta object compiler. Generate moc file when project compiling
set(CMAKE_AUTORCC ON) # For Resource files
set(CMAKE_AUTOUIC ON) # For UI files
# Find Qt5 with modules (CMAKE will take "<package_name>_DIR" as root path for find_package(), eg. Qt5_DIR )
# Needs to set CMAKE variable Qt5_DIR = path-to-your-qt-innstallation/5.14.2/clang_64/lib/cmake/Qt5
if(WIN32 OR WIN) # Windows
SET(Qt5_DIR "${install_dir}\\lib\\cmake\\Qt5" CACHE PATH "Path to Qt5 cmake stuff: ..\\5.14.2\\msvc2017\\lib\\cmake\\Qt5" )
else() # OSX
SET(Qt5_DIR "${install_dir}/lib/cmake/Qt5" CACHE PATH "Path to Qt5 cmake stuff: ../5.14.2/clang_64/lib/cmake/Qt5" )
endif()
FIND_PACKAGE(PkgConfig REQUIRED)
endmacro()
# framework for OSX, dll for Windows. Depends on QT_INIT()
# e.g. QT_DEPLOY(<target_name>)
function(QT_DEPLOY target_name)
GET_TARGET_PROPERTY(QT5_QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION) # get qmake file path
GET_FILENAME_COMPONENT(DEPLOYQT_EXEC ${QT5_QMAKE_EXECUTABLE} PATH) # get qmake dir path
if(WIN32 OR WIN) # Windows
SET(DEPLOYQT_EXEC "${DEPLOYQT_EXEC}/windeployqt.exe")
add_custom_command(TARGET ${target_name}
POST_BUILD
COMMAND ${DEPLOYQT_EXEC} "$<TARGET_FILE:${target_name}>" --$<LOWER_CASE:$<CONFIG>> --qmldir ${CMAKE_SOURCE_DIR}
)
else() # OSX
SET(DEPLOYQT_EXEC "${DEPLOYQT_EXEC}/macdeployqt")
add_custom_command(TARGET ${target_name}
POST_BUILD
COMMAND ${DEPLOYQT_EXEC} "$<TARGET_BUNDLE_DIR:${target_name}>" -qmldir=${CMAKE_SOURCE_DIR}
)
endif()
endfunction(QT_DEPLOY)
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
if(WITH_QT)
if(WIN) # for windows
SET(INC_QT
${QT_INSTALL_DIR}/include
${QT_INSTALL_DIR}/include/QtCore
${QT_INSTALL_DIR}/include/QtGui
${QT_INSTALL_DIR}/include/QtSql
${QT_INSTALL_DIR}/include/QtOpenGL
${QT_INSTALL_DIR}/include/QtWidgets
${QT_INSTALL_DIR}/include/QtCharts
${QT_INSTALL_DIR}/include/QtNetwork
# Camera
${QT_INSTALL_DIR}/include/QtMultimedia
${QT_INSTALL_DIR}/include/QtMultimediaWidgets
# qml - Quick
${QT_INSTALL_DIR}/include/QtQml
${QT_INSTALL_DIR}/include/QtQuick
${QT_INSTALL_DIR}/include/QtQuickWidgets
${QT_INSTALL_DIR}/include/QtQuickControls2
# ${QT_INSTALL_DIR}/include/QtQuick2Plugin
)
# LIB_BUILD_TYPE_EXT = d for debug, empty for release
SET(LIB_QT
${QT_INSTALL_DIR}/lib/Qt5Core${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5Gui${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5Sql${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5OpenGL${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5Widgets${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5Charts${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5Network${LIB_BUILD_TYPE_EXT}.lib
# Camera
${QT_INSTALL_DIR}/lib/Qt5Multimedia${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5MultimediaWidgets${LIB_BUILD_TYPE_EXT}.lib
# qml - Quick
${QT_INSTALL_DIR}/lib/Qt5Qml${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5Quick${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5QuickWidgets${LIB_BUILD_TYPE_EXT}.lib
${QT_INSTALL_DIR}/lib/Qt5QuickControls2${LIB_BUILD_TYPE_EXT}.lib
# ${QT_INSTALL_DIR}/lib/QtQuick2Plugin${LIB_BUILD_TYPE_EXT}.lib
)
elseif(OSX) # for MacOSX
SET(INC_QT
${QT_INSTALL_DIR}/lib/QtCore.framework/Headers
${QT_INSTALL_DIR}/lib/QtGui.framework/Headers
${QT_INSTALL_DIR}/lib/QtSql.framework/Headers/
${QT_INSTALL_DIR}/lib/QtOpenGL.framework/Headers
${QT_INSTALL_DIR}/lib/QtWidgets.framework/Headers
${QT_INSTALL_DIR}/lib/QtCharts.framework/Headers
${QT_INSTALL_DIR}/lib/QtNetwork.framework/Headers
# Camera
${QT_INSTALL_DIR}/lib/QtMultimedia.framework/Headers
${QT_INSTALL_DIR}/lib/QtMultimediaWidgets.framework/Headers
# qml - Quick
${QT_INSTALL_DIR}/lib/QtQml.framework/Headers
${QT_INSTALL_DIR}/lib/QtQuick.framework/Headers
${QT_INSTALL_DIR}/lib/QtQuickWidgets.framework/Headers
${QT_INSTALL_DIR}/lib/QtQuickControls2.framework/Headers
# ${QT_INSTALL_DIR}/lib/QtQuick2Plugin.framework/Headers
)
SET(LIB_QT
${QT_INSTALL_DIR}/lib/QtCore.framework
${QT_INSTALL_DIR}/lib/QtGui.framework
${QT_INSTALL_DIR}/lib/QtSql.framework
${QT_INSTALL_DIR}/lib/QtOpenGL.framework
${QT_INSTALL_DIR}/lib/QtWidgets.framework
${QT_INSTALL_DIR}/lib/QtCharts.framework
${QT_INSTALL_DIR}/lib/QtNetwork.framework
# Camera
${QT_INSTALL_DIR}/lib/QtMultimedia.framework
${QT_INSTALL_DIR}/lib/QtMultimediaWidgets.framework
# qml - Quick
${QT_INSTALL_DIR}/lib/QtQml.framework
${QT_INSTALL_DIR}/lib/QtQuick.framework
${QT_INSTALL_DIR}/lib/QtQuickWidgets.framework
${QT_INSTALL_DIR}/lib/QtQuickControls2.framework
# ${QT_INSTALL_DIR}/lib/QtQuick2Plugin.framework
)
endif(OSX)
# Search QT Libraries
SET(QT_MODULES Core Gui OpenGL Widgets Charts Network Sql)
SET(QT_MODULES_CAMERA Multimedia MultimediaWidgets)
SET(QT_MODULES_QUICK Qml Quick QuickWidgets QuickControls2 ) #Quick2Plugin
FIND_PACKAGE(Qt5 COMPONENTS ${QT_MODULES} ${QT_MODULES_CAMERA} ${QT_MODULES_QUICK} REQUIRED)
set(CMAKE_AUTOUIC OFF)
endif(WITH_QT)
\ No newline at end of file
#include "winver.h"
IDI_ICON1 ICON DISCARDABLE "@ICON_FILE@"
VS_VERSION_INFO VERSIONINFO
FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
FILEFLAGS 0x0L
FILEFLAGSMASK 0x3fL
FILEOS 0x00040004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004b0"
BEGIN
VALUE "CompanyName", "@COMPANY@"
VALUE "FileDescription", "@PROJECT_NAME@"
VALUE "FileVersion", "@PROJECT_VERSION@"
VALUE "LegalCopyright", "@COPYRIGHT@"
VALUE "InternalName", "@PROJECT_NAME@"
VALUE "OriginalFilename", "@PROJECT_NAME@.exe"
VALUE "ProductName", "@PROJECT_NAME@"
VALUE "ProductVersion", "@PROJECT_VERSION@"
END
END
END
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set(CURRENT_CMAKE_DIR ${CMAKE_CURRENT_LIST_DIR})
# var META_FILES required
function(WIN_ADD_META)
if (WIN32)
set(ICON_FILE ${CURRENT_CMAKE_DIR}/res/AppIcon.ico)
configure_file("${CURRENT_CMAKE_DIR}/res/windows_metafile.rc.in" "windows_metafile.rc")
set(RES_FILES "windows_metafile.rc")
set(CMAKE_RC_COMPILER_INIT windres)
ENABLE_LANGUAGE(RC)
SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
set(META_FILES ${RES_FILES} ${ICON_FILE} PARENT_SCOPE) # PARENT_SCOPE make change avaliable outside fucntion
endif()
endfunction(WIN_ADD_META)
function(WIN_FIX_COMPILER bin_name)
if (MSVC)
set_target_properties(${bin_name} PROPERTIES
WIN32_EXECUTABLE YES
LINK_FLAGS "/ENTRY:mainCRTStartup"
)
endif()
endfunction(WIN_FIX_COMPILER)
\ No newline at end of file
# - Try to find Assimp
# Once done, this will define
#
# ASSIMP_FOUND - system has Assimp
# ASSIMP_INCLUDE_DIR - the Assimp include directories
# ASSIMP_LIBRARIES - link these to use Assimp
FIND_PATH( ASSIMP_INCLUDE_DIR assimp/mesh.h
/usr/include
/usr/local/include
/opt/local/include
)
FIND_LIBRARY( ASSIMP_LIBRARY assimp
/usr/lib64
/usr/lib
/usr/local/lib
/opt/local/lib
)
IF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY)
SET( ASSIMP_FOUND TRUE )
SET( ASSIMP_LIBRARIES ${ASSIMP_LIBRARY} )
ENDIF(ASSIMP_INCLUDE_DIR AND ASSIMP_LIBRARY)
IF(ASSIMP_FOUND)
IF(NOT ASSIMP_FIND_QUIETLY)
MESSAGE(STATUS "Found ASSIMP: ${ASSIMP_LIBRARY}")
ENDIF(NOT ASSIMP_FIND_QUIETLY)
ELSE(ASSIMP_FOUND)
IF(ASSIMP_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find libASSIMP")
ENDIF(ASSIMP_FIND_REQUIRED)
ENDIF(ASSIMP_FOUND)
# FindGLM - attempts to locate the glm matrix/vector library.
#
# This module defines the following variables (on success):
# GLM_INCLUDE_DIRS - where to find glm/glm.hpp
# GLM_FOUND - if the library was successfully located
#
# It is trying a few standard installation locations, but can be customized
# with the following variables:
# GLM_ROOT_DIR - root directory of a glm installation
# Headers are expected to be found in either:
# <GLM_ROOT_DIR>/glm/glm.hpp OR
# <GLM_ROOT_DIR>/include/glm/glm.hpp
# This variable can either be a cmake or environment
# variable. Note however that changing the value
# of the environment varible will NOT result in
# re-running the header search and therefore NOT
# adjust the variables set by this module.
#=============================================================================
# Copyright 2012 Carsten Neumann
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# default search dirs
SET(_glm_HEADER_SEARCH_DIRS
"/usr/include"
"/usr/local/include")
# check environment variable
SET(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}")
IF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
SET(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}")
ENDIF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
# put user specified location at beginning of search
IF(GLM_ROOT_DIR)
SET(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}"
"${GLM_ROOT_DIR}/include"
${_glm_HEADER_SEARCH_DIRS})
ENDIF(GLM_ROOT_DIR)
# locate header
FIND_PATH(GLM_INCLUDE_DIR "glm/glm.hpp"
PATHS ${_glm_HEADER_SEARCH_DIRS})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG
GLM_INCLUDE_DIR)
IF(GLM_FOUND)
SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}")
ENDIF(GLM_FOUND)
# Locate SDL2 library
# This module defines
# SDL2_LIBRARY, the name of the library to link against
# SDL2_FOUND, if false, do not try to link to SDL2
# SDL2_INCLUDE_DIR, where to find SDL.h
#
# This module responds to the the flag:
# SDL2_BUILDING_LIBRARY
# If this is defined, then no SDL2main will be linked in because
# only applications need main().
# Otherwise, it is assumed you are building an application and this
# module will attempt to locate and set the the proper link flags
# as part of the returned SDL2_LIBRARY variable.
#
# Don't forget to include SDLmain.h and SDLmain.m your project for the
# OS X framework based version. (Other versions link to -lSDL2main which
# this module will try to find on your behalf.) Also for OS X, this
# module will automatically add the -framework Cocoa on your behalf.
#
#
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
# as appropriate. These values are used to generate the final SDL2_LIBRARY
# variable, but when these values are unset, SDL2_LIBRARY does not get created.
#
#
# $SDL2DIR is an environment variable that would
# correspond to the ./configure --prefix=$SDL2DIR
# used in building SDL2.
# l.e.galup 9-20-02
#
# Modified by Eric Wing.
# Added code to assist with automated building by using environmental variables
# and providing a more controlled/consistent search behavior.
# Added new modifications to recognize OS X frameworks and
# additional Unix paths (FreeBSD, etc).
# Also corrected the header search path to follow "proper" SDL guidelines.
# Added a search for SDL2main which is needed by some platforms.
# Added a search for threads which is needed by some platforms.
# Added needed compile switches for MinGW.
#
# On OSX, this will prefer the Framework version (if found) over others.
# People will have to manually change the cache values of
# SDL2_LIBRARY to override this selection or set the CMake environment
# CMAKE_INCLUDE_PATH to modify the search paths.
#
# Note that the header path has changed from SDL2/SDL.h to just SDL.h
# This needed to change because "proper" SDL convention
# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
# reasons because not all systems place things in SDL2/ (see FreeBSD).
#=============================================================================
# Copyright 2003-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
SET(SDL2_SEARCH_PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt
)
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
HINTS
$ENV{SDL2DIR}
PATH_SUFFIXES include/SDL2 include
PATHS ${SDL2_SEARCH_PATHS}
)
FIND_LIBRARY(SDL2_LIBRARY_TEMP
NAMES SDL2
HINTS
$ENV{SDL2DIR}
PATH_SUFFIXES lib64 lib
PATHS ${SDL2_SEARCH_PATHS}
)
IF(NOT SDL2_BUILDING_LIBRARY)
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
# Non-OS X framework versions expect you to also dynamically link to
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
# seem to provide SDL2main for compatibility even though they don't
# necessarily need it.
FIND_LIBRARY(SDL2MAIN_LIBRARY
NAMES SDL2main
HINTS
$ENV{SDL2DIR}
PATH_SUFFIXES lib64 lib
PATHS ${SDL2_SEARCH_PATHS}
)
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
ENDIF(NOT SDL2_BUILDING_LIBRARY)
# SDL2 may require threads on your system.
# The Apple build may not need an explicit flag because one of the
# frameworks may already provide it.
# But for non-OSX systems, I will use the CMake Threads package.
IF(NOT APPLE)
FIND_PACKAGE(Threads)
ENDIF(NOT APPLE)
# MinGW needs an additional library, mwindows
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
# (Actually on second look, I think it only needs one of the m* libraries.)
IF(MINGW)
SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
ENDIF(MINGW)
IF(SDL2_LIBRARY_TEMP)
# For SDL2main
IF(NOT SDL2_BUILDING_LIBRARY)
IF(SDL2MAIN_LIBRARY)
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(SDL2MAIN_LIBRARY)
ENDIF(NOT SDL2_BUILDING_LIBRARY)
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
# CMake doesn't display the -framework Cocoa string in the UI even
# though it actually is there if I modify a pre-used variable.
# I think it has something to do with the CACHE STRING.
# So I use a temporary variable until the end so I can set the
# "real" variable in one-shot.
IF(APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
ENDIF(APPLE)
# For threads, as mentioned Apple doesn't need this.
# In fact, there seems to be a problem if I used the Threads package
# and try using this line, so I'm just skipping it entirely for OS X.
IF(NOT APPLE)
SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
ENDIF(NOT APPLE)
# For MinGW library
IF(MINGW)
SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
ENDIF(MINGW)
# Set the final string here so the GUI reflects the final state.
SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
# Set the temp variable to INTERNAL so it is not seen in the CMake GUI
SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
ENDIF(SDL2_LIBRARY_TEMP)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set(ViConfigToolDir ${CMAKE_CURRENT_LIST_DIR})
set(BIN_NAME ViConfigTool)
set(INC_DEPS ${INC_FILES} ${INC_GROUP})
set(LIB_DEPS QLandscapeDB QtCoreKit CCoreKit )
FILE(GLOB_RECURSE ViConfigTool_SRC
${ViConfigToolDir}/*.h
${ViConfigToolDir}/*.hpp
${ViConfigToolDir}/*.c
${ViConfigToolDir}/*.cc
${ViConfigToolDir}/*.cpp
)
# Special For Qt
if(WITH_QT)
FILE(GLOB_RECURSE ViConfigTool_FORMs
${ViConfigToolDir}/Forms/*.ui
)
FILE(GLOB_RECURSE ViConfigTool_RES
${ViConfigToolDir}/Res/*.qrc
${ViConfigToolDir}/Res/*.qml
${ViConfigToolDir}/Res/*.js
)
# gen src by forms
# qt5_wrap_ui(ViConfigTool_RES_UIC ${ViConfigTool_FORMs})
# set(ViConfigTool_SRC ${ViConfigTool_SRC} ${ViConfigTool_FORMs} ${ViConfigTool_RES} ${ViConfigTool_RES_UIC})
set(ViConfigTool_SRC ${ViConfigTool_SRC} ${ViConfigTool_FORMs} ${ViConfigTool_RES})
set(INC_DEPS ${INC_DEPS} ${INC_QT})
set(LIB_DEPS ${LIB_DEPS} ${LIB_QT})
endif()
# Special For Python
if(WITH_PY)
set(INC_DEPS ${INC_DEPS} ${INC_PY})
set(LIB_DEPS ${LIB_DEPS} ${LIB_PY})
endif(WITH_PY)
# Gen Source Tree
if(NOT ANDROID)
source_group(
TREE ${ViConfigToolDir}
PREFIX "ViConfigTool"
FILES ${ViConfigTool_SRC}
)
endif(NOT ANDROID)
if(WITH_QT)
# gen src by forms
qt5_wrap_ui(ViConfigTool_RES_UIC ${ViConfigTool_FORMs})
set(ViConfigTool_SRC ${ViConfigTool_SRC} ${ViConfigTool_RES_UIC})
endif()
################################## build bin ##################################
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
add_executable(${BIN_NAME} ${OS_BUNDLE} ${ViConfigTool_SRC} ${META_FILES} ${CONF_FILES} ${PLUGIN_FILEs})
target_include_directories(${BIN_NAME} PUBLIC ${INC_DEPS} ${ViConfigToolDir} )
# target_link_directories(${BIN_NAME} PUBLIC ${INC_LIB})
target_link_libraries(${BIN_NAME} PUBLIC ${LIB_FMWKs} ${LIB_DEPS}
${OPENGL_gl_LIBRARY} # https://cmake.org/cmake/help/v3.0/module/FindOpenGL.html
)
# add app res
# APP_ADD_RES("${PROJ_ROOT}/conf/project.json" "Resources/")
APP_ADD_RES_RECURSE("${CONF_DIR}/" "conf/" "${CONF_DIR}/*.*")
APP_ADD_RES_RECURSE("${TOOLS_DIR}/" "tools/" "${TOOLS_DIR}/*.*")
if(WITH_QT)
QT_DEPLOY(${BIN_NAME}) # From qt_func.cmake. Deploy Qt Libs To APP
target_compile_definitions(${BIN_NAME} PRIVATE
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>
$<$<OR:$<CONFIG:Release>,$<CONFIG:MinSizeRel>>:QT_NO_DEBUG_OUTPUT>)
endif(WITH_QT)
# install libs & headers
INSTALL_INC(${CMAKE_CURRENT_LIST_DIR} include/)
# INSTALL_TARGET(${BIN_NAME}) # lib bin exe
if(WIN)
WIN_FIX_COMPILER(${BIN_NAME})
# INSTALL_TARGET(${BIN_NAME}) # lib bin exe
elseif(APPLE)
# from intern cmake module : apple_func.cmake
XCODE_SETTING(${BIN_NAME} ${OS_MIN_VERSION})
XCODE_ADD_INFO_PLIST(${BIN_NAME})
endif(APPLE)
if(QLandscapeDB)
add_dependencies(${BIN_NAME} QLandscapeDB)
else()
message(FATAL_ERROR "option ON for QLandscapeDB is required !")
endif(QLandscapeDB)
if(QtCoreKit)
add_dependencies(${BIN_NAME} QtCoreKit)
else()
message(FATAL_ERROR "option ON for QtCoreKit is required !")
endif(QtCoreKit)
if(CCoreKit)
add_dependencies(${BIN_NAME} CCoreKit)
else()
message(FATAL_ERROR "option ON for CCoreKit is required !")
endif(CCoreKit)
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include <CCoreKit/CCKDefines.h>
#include <QApplication>
#include <QCoreApplication>
#include <QMainWindow>
#include "QLandscapeDB/QLandscapeDB.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QCoreApplication::setApplicationName("ViConfigTool");
QCoreApplication::setApplicationVersion(QT_VERSION_STR);
ProjectConfig::GetInstance()->Init(std::string(argv[0]) + "/../../");
QLandscapeDBDialog dialog;
dialog.setWindowTitle(u8"地景数据库配置程序1.0");
//dialog.showMaximized();
dialog.show();
//QMainWindow window;
//window.setWindowTitle("ViDistribute");
//window.showMaximized();
//window.show();
return app.exec();
}
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set(SRC_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(INC_FILES ${INC_FILES} ${SRC_ROOT})
message("SRC_ROOT = ${SRC_ROOT}")
# ViConfigTool
if(WITH_QT AND ViConfigTool)
include(${SRC_ROOT}/ViConfigTool/ViConfigTool.cmake)
endif(WITH_QT AND ViConfigTool)
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifdef WIN
// 无警告编号
#pragma warning(disable: 4619)
// xxx隐式定义为“已删除”
#pragma warning(disable: 4625)
#pragma warning(disable: 4626)
#pragma warning(disable: 5026)
#pragma warning(disable: 5027)
#pragma warning(disable: 4457)
// 内联函数
#pragma warning(disable: 4710)
#pragma warning(disable: 4711)
// 数据类型转换
#pragma warning(disable: 4820) // 字节填充
#pragma warning(disable: 4365) // 有符号/无符号不匹配
#pragma warning(disable: 4388) // 有符号/无符号不匹配
#pragma warning(disable: 4267)
#pragma warning(disable: 5219)
#pragma warning(disable: 4946)
#pragma warning(disable: 5243)
#pragma warning(disable: 4242)
#pragma warning(disable: 5045)
#pragma warning(disable: 4668)
#pragma warning(disable: 4464)
#pragma warning(disable: 5039)
#pragma warning(disable: 5240) // 特性在此语法位置被忽略
#endif // WIN
#ifdef WIN
# define API_EXPORT _declspec(dllexport)
# define API_IMPORT _declspec(dllimport)
#else // Linux
# define API_EXPORT __attribute__((visibility("default")))
# define API_IMPORT
#endif // Linux
#ifndef CCK_DEFINE_H
#define CCK_DEFINE_H
#endif // CCK_DEFINE_H
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set(CCoreKitDir ${CMAKE_CURRENT_LIST_DIR})
set(LIB_NAME CCoreKit)
FILE(GLOB_RECURSE CCoreKit_SRC
${CCoreKitDir}/*.h
${CCoreKitDir}/*.hpp
${CCoreKitDir}/*.c
${CCoreKitDir}/*.cc
${CCoreKitDir}/*.cpp
)
if(NOT ANDROID)
source_group(
TREE ${CCoreKitDir}
PREFIX "CCoreKit"
FILES ${CCoreKit_SRC}
)
endif(NOT ANDROID)
set(LIB_DEPS )
add_library(${LIB_NAME} ${LIB_TYPE} ${CCoreKit_SRC})
target_include_directories(${LIB_NAME} PRIVATE ${INC_PY} ${CCoreKitDir} ${INC_GROUP} )
target_link_libraries(${LIB_NAME} ${LIB_PY} ${LIB_DEPS} )
# install libs & headers
INSTALL_INC(${CMAKE_CURRENT_LIST_DIR} include/)
INSTALL_TARGET(${LIB_NAME}) # lib bin exe
# from intern cmake module : apple_func.cmake
if(APPLE)
XCODE_SETTING(${LIB_NAME} ${OS_MIN_VERSION})
endif(APPLE)
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef CCOREKIT_H
#define CCOREKIT_H
#include <CCoreKit/CKSystemEnv.h>
#include <CCoreKit/CCKDefines.h>
#endif /* CCOREKIT_H */
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "CKSystemEnv.h"
#include <iostream>
#ifdef WIN32
# include <windows.h>
#endif // WIN32
/// https ://www.orcode.com/question/1012464_k5c59b.html
/// @param name upper-case is required!
std::string CKSystemEnv::GetEnv(const char* name)
{
#ifdef WIN32
//https ://www.orcode.com/question/1012464_k5c59b.html
const DWORD buf_size = 4096;
LPTSTR lp_buf = new TCHAR[buf_size];
const DWORD var_size = GetEnvironmentVariable(name, lp_buf, buf_size);
if (var_size == 0) {
DWORD err = GetLastError();
std::cout << __FUNCTION__ << "01: Error = " << err << std::endl;
return "";
}
else if (var_size > buf_size) // buf_size not enough
{
if (lp_buf) {
delete[] lp_buf;
}
lp_buf = new TCHAR[var_size];
const DWORD new_size = GetEnvironmentVariable(name, lp_buf, var_size);
if (new_size == 0 || new_size > var_size) {
DWORD err = GetLastError();
std::cout << __FUNCTION__ << "02: Error = " << err << std::endl;
return "";
}
return std::string(lp_buf, new_size);
}
return std::string(lp_buf, var_size);
#else
const char* val = std::getenv(name);
std::string env_var(val ? "" : std::string(val));
return env_var;
#endif
}
/// @brief Get Env PATH
std::string CKSystemEnv::GetPathEnv()
{
return GetEnv("PATH");
}
/// @brief Split Env Value By ";" and remove repeated
/// @param name upper-case is required!
std::set<std::string> CKSystemEnv::SplitEnvValue(const char* name)
{
std::set<std::string> values;
std::string env_value = GetEnv(name);
if (!env_value.empty()) {
// Split Env Value By ";"
std::string sub_str;
char tag = ';';
for (size_t idx = 0; idx < env_value.size(); idx++) {
if (tag == env_value[idx]) // Finish once
{
if (!sub_str.empty()) {
values.insert(sub_str);
sub_str.clear();
}
}
else // Finding next tag continue
{
sub_str.push_back(env_value[idx]);
}
}
if (!sub_str.empty()) {
values.insert(sub_str);
sub_str.clear();
}
}
//for (auto item = values.begin(); item != values.end(); item++) {
// std::cout << __FUNCTION__ << item->c_str() << std::endl;
//}
return values;
}
/// @brief Get PATH Env Value and Split to items by SplitEnvValue();
std::set<std::string> CKSystemEnv::GetPathEnvItems()
{
auto path_set = SplitEnvValue("PATH");
return path_set;
}
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// https://www.delftstack.com/zh/howto/cpp/cpp-get-environment-variables/
#pragma once
#include "CCKDefines.h"
#include <iostream>
#include <string>
#include <set>
#include <cstdlib> // GetEnv
class CKSystemEnv
{
public:
/// @param name upper-case is required!
static std::string GetEnv(const char*name);
/// @brief Get Env PATH
static std::string GetPathEnv();
/// @brief Split Env Value By ";" and remove repeated
/// @param name upper-case is required!
static std::set<std::string> SplitEnvValue(const char* name);
/// @brief Get PATH Env Value and Split to items by SplitEnvValue();
static std::set<std::string> GetPathEnvItems();
};
#include "AirportListParser.h"
#include "ProjectConfig.h"
#include <QDir>
#include <QFileInfo>
#include <QIODevice>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
#include <QMessageBox>
#include <QtCoreKit/utils/QCKFile.h>
static bool LoadJsonObjectConfig(QJsonObject& json_obj, const std::string &file)
{
// Load File
QByteArray file_data;
if (QCKFile::LoadFile(file.c_str(), file_data) != QCKFile::State::Succeed) {
QMessageBox::critical(NULL, __FUNCTION__, QString(file.c_str()) + " Not Exist!");
return false;
}
QString json_str = file_data;
QJsonDocument json_doc = QJsonDocument::fromJson(json_str.toUtf8());
if (json_doc.isEmpty() || !json_doc.isObject()) {
QMessageBox::critical(NULL, __FUNCTION__, QString(file.c_str()) + " parse json failed!");
return false;
}
json_obj = json_doc.object();
return true;
}
AirportListParser::AirportListParser()
{
// parse json key-values
QJsonObject json_obj;
std::string cfg_file = ProjectConfig::GetInstance()->GetConfigFile("Config.json");
if (LoadJsonObjectConfig(json_obj, cfg_file)) {
if (json_obj.contains("airport_max_num")) {
airport_max_num_ = json_obj["airport_max_num"].toInt();
}
}
}
bool AirportListParser::GetAirportList(std::vector<std::string>& list)
{
list.clear();
// parse json key-values
QJsonObject json_obj;
list_pool_file_ = ProjectConfig::GetInstance()->GetConfigFile("AirportList.json");
if (!LoadJsonObjectConfig(json_obj, list_pool_file_)) {
return false;
}
if (json_obj.contains("scenes") && json_obj["scenes"].isArray()) {
QJsonArray json_arr = json_obj["scenes"].toArray();
for (size_t idx = 0; idx < json_arr.size(); idx++) {
if (json_arr[idx].isObject())
{
QJsonObject item = json_arr[idx].toObject();
if (item.contains("name") && item["name"].toString() != u8"全局") {
list.push_back(item["name"].toString().toStdString());
}
}
//else if (json_arr[idx].isString())
//{
// QString item = json_arr[idx].toString();
// list.push_back(item.toStdString());
//}
}
}
return true;
}
bool AirportListParser::SaveAirportList(const std::set<std::string>& list)
{
// parse json key-values
QJsonObject json_obj;
list_pool_file_ = ProjectConfig::GetInstance()->GetConfigFile("AirportList.json");
if (!LoadJsonObjectConfig(json_obj, list_pool_file_)) {
return false;
}
if (json_obj.contains("scenes") && json_obj["scenes"].isArray()) {
QJsonArray json_arr = json_obj["scenes"].toArray();
for (size_t idx = 0; idx < json_arr.size(); idx++) {
if (json_arr[idx].isObject())
{
QJsonObject item = json_arr[idx].toObject();
if (item.contains("name") && item["name"].toString() != u8"全局") {
auto name = item["name"].toString().toStdString();
bool find_name = false;
for (auto iter = list.begin(); iter != list.end(); iter++) {
if ((*iter) == name) {
find_name = true;
break;
}
}
if (!find_name) {
json_arr.removeAt(idx);
idx--;
}
}
}
}
json_obj.remove("scenes");
json_obj.insert("scenes", json_arr);
}
QString save_json_str = QString(QJsonDocument(json_obj).toJson());
std::string save_file = ProjectConfig::GetInstance()->GetConfigFile("ExportList.vproj");
return QCKFile::SaveFile(QString::fromStdString(save_file), save_json_str.toUtf8());
}
#pragma once
#include <CCoreKit/CCKDefines.h>
#include <string>
#include <vector>
#include <set>
class AirportListParser
{
public:
AirportListParser();
~AirportListParser() {}
int GetAirportMaxNum() { return airport_max_num_; }
bool GetAirportList(std::vector<std::string>& list);
bool SaveAirportList(const std::set<std::string>& list);
protected:
std::string list_pool_file_;
int airport_max_num_ = 5;
};
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QLandscapeDBDialog</class>
<widget class="QDialog" name="QLandscapeDBDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1350</width>
<height>726</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>1350</width>
<height>725</height>
</size>
</property>
<property name="windowTitle">
<string>AirportData</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QDockWidget" name="dockWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1214</width>
<height>736</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>524287</width>
<height>524287</height>
</size>
</property>
<property name="font">
<font>
<family>Agency FB</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(70, 76, 91);</string>
</property>
<property name="features">
<set>QDockWidget::NoDockWidgetFeatures</set>
</property>
<property name="allowedAreas">
<set>Qt::NoDockWidgetArea</set>
</property>
<property name="windowTitle">
<string/>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="airportLayout">
<item>
<layout class="QHBoxLayout" name="configLayout">
<item>
<widget class="QLabel" name="icon">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Agency FB</family>
<pointsize>14</pointsize>
<weight>9</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(204, 204, 204);
font: 75 14pt &quot;Agency FB&quot;;</string>
</property>
<property name="text">
<string>机场配置</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="configVerticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_10">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>400</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>2160</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(49, 53, 64);
color: rgb(153, 153, 153);
font: 75 12pt &quot;Agency FB&quot;;</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="listPoolTitleLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>350</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<family>Microsoft JhengHei UI</family>
<pointsize>18</pointsize>
<weight>9</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">font: 75 18pt &quot;Microsoft JhengHei UI&quot;;
background-color: rgb(79, 90, 102);
color: rgb(204, 204, 204);</string>
</property>
<property name="text">
<string>机场列表</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QListWidget" name="listPoolWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>290</width>
<height>400</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>290</width>
<height>2160</height>
</size>
</property>
<property name="font">
<font>
<family>Agency FB</family>
<pointsize>12</pointsize>
<weight>9</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(49, 53, 64);
color: rgb(153, 153, 153);
font: 75 12pt &quot;Agency FB&quot;;</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectItems</enum>
</property>
<property name="spacing">
<number>5</number>
</property>
<property name="selectionRectVisible">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="middleLayout">
<item>
<spacer name="verticalSpacerUp">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="airportAddBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Microsoft YaHei UI</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(255, 255, 255);
selection-background-color: rgb(26, 188, 156);</string>
</property>
<property name="text">
<string>添加机场 -&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacerMid">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="airportDelBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<family>Microsoft YaHei UI</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>ArrowCursor</cursorShape>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(0, 0, 0);
selection-color: rgb(255, 255, 255);
background-color: rgb(255, 255, 255);
selection-background-color: rgb(26, 188, 156);</string>
</property>
<property name="text">
<string>&lt;- 删除机场</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacerDown">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QWidget" name="selectedWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(49, 53, 64);
color: rgb(153, 153, 153);
font: 75 12pt &quot;Agency FB&quot;;</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>380</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>380</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<family>Microsoft YaHei UI</family>
<pointsize>18</pointsize>
<weight>9</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">font: 75 18pt &quot;Microsoft YaHei UI&quot;;
color: rgb(204, 204, 204);
background-color: rgb(79, 90, 102);</string>
</property>
<property name="text">
<string>已选择机场</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QListWidget" name="selectedListWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>280</width>
<height>400</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>280</width>
<height>2160</height>
</size>
</property>
<property name="font">
<font>
<family>Agency FB</family>
<pointsize>12</pointsize>
<weight>9</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
selection-color: rgb(26, 188, 156);
border:1px #FFFFFF</string>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<property name="spacing">
<number>10</number>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="exportDataBtn">
<property name="font">
<font>
<family>Agency FB</family>
<pointsize>12</pointsize>
<weight>9</weight>
<italic>false</italic>
<bold>false</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">background-color:rgb(26, 188, 156);
color: rgb(255, 255, 255);
selection-background-color: rgb(26, 188, 156);</string>
</property>
<property name="text">
<string>应用</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_7">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#include "ProjectConfig.h"
#ifdef WIN
const char* PATH_SPLIT_TAG = "\\";
#else // Linux
const char* PATH_SPLIT_TAG = "/";
#endif // Linux
ProjectConfig *ProjectConfig::GetInstance()
{
static ProjectConfig *instance = new ProjectConfig();
return instance;
}
ProjectConfig::ProjectConfig()
{
}
void ProjectConfig::Init(const std::string& root)
{
std::string sub = root.substr(0, root.find_last_of(PATH_SPLIT_TAG));
sub = sub.substr(0, sub.find_last_of(PATH_SPLIT_TAG));
res_.root_dir = sub;
res_.conf_dir = sub + PATH_SPLIT_TAG + "conf" + PATH_SPLIT_TAG;
res_.tool_dir = sub + PATH_SPLIT_TAG + "tools" + PATH_SPLIT_TAG;
res_.plugin_dir = sub + PATH_SPLIT_TAG + "plugins" + PATH_SPLIT_TAG;
}
std::string ProjectConfig::GetConfigFile(const std::string& file)
{
return res_.conf_dir + file;
}
std::string ProjectConfig::GetToolFile(const std::string& file)
{
return res_.tool_dir + file;
}
std::string ProjectConfig::GetPluginFile(const std::string& file)
{
return res_.plugin_dir + file;
}
#pragma once
#include <string>
#include <CCoreKit/CCKDefines.h>
struct ProjectRes
{
std::string root_dir;
std::string conf_dir;
std::string tool_dir;
std::string plugin_dir;
};
API_EXPORT class ProjectConfig
{
public:
static ProjectConfig *GetInstance();
ProjectConfig();
~ProjectConfig() { }
void Init(const std::string& root);
std::string GetConfigFile(const std::string& file);
std::string GetToolFile(const std::string& file);
std::string GetPluginFile(const std::string& file);
protected:
ProjectRes res_;
};
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set(QLandscapeDBDir ${CMAKE_CURRENT_LIST_DIR})
set(LIB_NAME QLandscapeDB)
FILE(GLOB_RECURSE QLandscapeDB_SRC
${QLandscapeDBDir}/*.h
${QLandscapeDBDir}/*.hpp
${QLandscapeDBDir}/*.c
${QLandscapeDBDir}/*.cc
${QLandscapeDBDir}/*.cpp
)
FILE(GLOB_RECURSE QLandscapeDB_FORMs
${QLandscapeDBDir}/Forms/*.ui
)
FILE(GLOB_RECURSE QLandscapeDB_RES
${QLandscapeDBDir}/Res/*.qrc
${QLandscapeDBDir}/Res/*.qml
${QLandscapeDBDir}/Res/*.js
)
if(NOT ANDROID)
source_group(
TREE ${QLandscapeDBDir}
PREFIX "QLandscapeDB"
FILES ${QLandscapeDB_SRC} ${QLandscapeDB_FORMs} ${QLandscapeDB_RES}
)
endif(NOT ANDROID)
# gen src by forms
qt5_wrap_ui(QLandscapeDB_RES_UIC ${QLandscapeDB_FORMs})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
# update QLandscapeDB_SRC
set(QLandscapeDB_SRC ${QLandscapeDB_SRC} ${QLandscapeDB_FORMs} ${QLandscapeDB_RES} ${QLandscapeDB_RES_UIC})
set(LIB_DEPS QtCoreKit CCoreKit )
add_library(${LIB_NAME} ${LIB_TYPE} ${QLandscapeDB_SRC})
target_include_directories(${LIB_NAME} PRIVATE ${INC_QT} ${INC_PY} ${QLandscapeDBDir} ${INC_GROUP} )
target_link_libraries(${LIB_NAME} ${LIB_QT} ${LIB_PY} ${LIB_DEPS})
# install libs & headers
INSTALL_INC(${CMAKE_CURRENT_LIST_DIR} include/)
INSTALL_TARGET(${LIB_NAME}) # lib bin exe
# from intern cmake module : apple_func.cmake
if(APPLE)
XCODE_SETTING(${LIB_NAME} ${OS_MIN_VERSION})
endif(APPLE)
if(QtCoreKit)
add_dependencies(${LIB_NAME} QtCoreKit)
else()
message(FATAL_ERROR "option ON for QtCoreKit is required !")
endif(QtCoreKit)
if(CCoreKit)
add_dependencies(${LIB_NAME} CCoreKit)
else()
message(FATAL_ERROR "option ON for CCoreKit is required !")
endif(CCoreKit)
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef QLANDSCAPEDB_H
#define QLANDSCAPEDB_H
#include <QLandscapeDB/QLandscapeDBDialog.h>
#include <QLandscapeDB/ProjectConfig.h>
#include <QLandscapeDB/AirportListParser.h>
#endif /* QLANDSCAPEDB_H */
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "QLandscapeDBDialog.h"
#include "AirportListParser.h"
#include <QDebug>
#include <QResizeEvent>
#include <QMessageBox>
#include <QStyleFactory>
#include <QtCoreKit/script/QCKCmd.h>
#include <QtCoreKit/utils/QCKMessage.h>
#include "ui_QLandscapeDBDialog.h"
#include "ProjectConfig.h"
QLandscapeDBDialog::QLandscapeDBDialog(QWidget *parent) :
QDialog(parent), ui(new Ui::QLandscapeDBDialog)
{
setWindowFlags(Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
setStyleSheet("QWidget { background-color: rgb(70, 76, 91); }");
ui->setupUi(this);
parser_ = std::make_shared<AirportListParser>();
//ui->dockWidget->setWindowFlag(Qt::FramelessWindowHint);
//ui->dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
ui->listPoolWidget->setStyleSheet("\
QListView::item{ height: 55px; border:0px; } \
QListWidget::Item:hover{ color:white; } \
QListWidget::item:selected{ color:rgb(26, 188, 156); } \
");
connect(ui->listPoolWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(OnItemClicked(QListWidgetItem*)));
ui->selectedListWidget->setStyle(QStyleFactory::create("windows"));
ui->selectedListWidget->setStyleSheet("\
QListView::item{ height: 55px; border:1px solid #797979; } \
QListWidget::Item:hover{ color:white; } \
QListWidget::item:selected{ color:rgb(26, 188, 156); border:1px solid #797979; } \
");
QStringList list;
for (size_t idx = 0; idx < parser_->GetAirportMaxNum(); idx++) {
list << " ";
}
ui->selectedListWidget->addItems(list);
connect(ui->selectedListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(OnItemClicked(QListWidgetItem*)));
ui->airportAddBtn->setStyleSheet("\
QPushButton{ border-radius:6px; background-color: white; width:150px; height:44px;} \
QPushButton::hover{ color:white; background-color: rgb(26, 188, 156); } \
");
connect(ui->airportAddBtn, SIGNAL(clicked(bool)), this, SLOT(OnAddAirport(bool)));
ui->airportDelBtn->setStyleSheet("\
QPushButton{ border-radius:6px; background-color: white; width:150px; height:44px;} \
QPushButton::hover{ color:white; background-color: rgb(26, 188, 156); } \
");
connect(ui->airportDelBtn, SIGNAL(clicked(bool)), this, SLOT(OnDelAirport(bool)));
ui->exportDataBtn->setStyleSheet("\
QPushButton{ border-radius:6px; color:white; background-color: #1ABC9C; width:150px; height:44px;} \
");
connect(ui->exportDataBtn, SIGNAL(clicked(bool)), this, SLOT(OnExportAirports(bool)));
InitData();
ListWidgetSortAndTextCenter(ui->listPoolWidget);
ListWidgetSortAndTextCenter(ui->selectedListWidget);
}
QLandscapeDBDialog::~QLandscapeDBDialog()
{
delete ui;
}
void QLandscapeDBDialog::InitData()
{
std::vector<std::string> list;
if (parser_->GetAirportList(list))
{
// Fill Data
for (size_t idx = 0; idx < list.size(); idx++) {
auto text = QString(list[idx].c_str()).trimmed();
ui->listPoolWidget->addItem(text);
}
}
}
void QLandscapeDBDialog::ListWidgetSortAndTextCenter(QListWidget* widget)
{
// Sort and TextCenter
//widget->setSortingEnabled(true);
for (size_t idx = 0; idx < widget->count(); idx++)
{
widget->item(idx)->setTextAlignment(Qt::AlignCenter);
}
}
void QLandscapeDBDialog::ListWidgetUpdateSelection(QListWidget* widget, QListWidgetItem* selected)
{
bool has_selected = false;
for (size_t idx = 0; idx < widget->count(); idx++)
{
if (widget->item(idx) == selected) {
has_selected = true;
break;
}
}
if (!selected || !has_selected) {
ListWidgetCancelSelection(widget);
}
}
void QLandscapeDBDialog::ListWidgetCancelSelection(QListWidget* widget)
{
for (size_t idx = 0; idx < widget->count(); idx++) {
widget->item(idx)->setSelected(false);
}
}
void QLandscapeDBDialog::resizeEvent(QResizeEvent* event)
{
if (event->size() != event->oldSize()) {
ui->dockWidget->resize(event->size());
}
}
void QLandscapeDBDialog::OnItemClicked(QListWidgetItem* item)
{
ListWidgetUpdateSelection(ui->listPoolWidget, item);
ListWidgetUpdateSelection(ui->selectedListWidget, item);
}
void QLandscapeDBDialog::OnAddAirport(bool clicked)
{
ListWidgetCancelSelection(ui->selectedListWidget);
QSet<QString> selected_list, keeped_list;
// Already Selected
for (size_t idx = 0; idx < ui->selectedListWidget->count(); idx++) {
auto item = ui->selectedListWidget->item(idx);
auto text = item->text().trimmed();
if (!text.isEmpty()) {
selected_list << text;
}
else { // Remove Empty
ui->selectedListWidget->takeItem(idx);
idx--;
}
}
// Select Pool
bool reach_max = false;
for (size_t idx = 0; idx < ui->listPoolWidget->count(); idx++) {
auto item = ui->listPoolWidget->item(idx);
auto text = item->text().trimmed();
if (!text.isEmpty()) {
if (item->isSelected()) {
if (selected_list.size() < parser_->GetAirportMaxNum()) { // Add
selected_list << text;
ui->selectedListWidget->addItem(text);
}
else { // Reach Max Limit : parser_->GetAirportMaxNum()
keeped_list << text;
reach_max = true;
}
}
else { // Not Selected In Pool
keeped_list << text;
}
}
else { // Remove Empty
ui->listPoolWidget->takeItem(idx);
idx--;
}
}
if (reach_max) {
QString text = QString(u8"最多支持加载") + QString::number(parser_->GetAirportMaxNum()) + QString(u8"座机场!");
//QCKMessage::ShowMsgBox(u8"提示", text);
QMessageBox::warning(NULL, u8"提示", text);
}
else if (selected_list.size() < parser_->GetAirportMaxNum()) {
for (size_t idx = selected_list.size(); idx < parser_->GetAirportMaxNum(); idx++) {
ui->selectedListWidget->insertItem(idx, " ");
}
}
ui->listPoolWidget->clear();
QSetIterator<QString> iter(keeped_list);
int idx = 0;
while (iter.hasNext()) {
ui->listPoolWidget->addItem(iter.next());
}
ListWidgetSortAndTextCenter(ui->listPoolWidget);
ListWidgetSortAndTextCenter(ui->selectedListWidget);
}
void QLandscapeDBDialog::OnDelAirport(bool clicked)
{
ListWidgetCancelSelection(ui->listPoolWidget);
QSet<QString> selected_list, keeped_list;
// Select Pool
for (size_t idx = 0; idx < ui->listPoolWidget->count(); idx++) {
auto item = ui->listPoolWidget->item(idx);
auto text = item->text().trimmed();
if (!text.isEmpty()) {
keeped_list << text;
}
else { // Remove Empty
ui->listPoolWidget->takeItem(idx);
idx--;
}
}
// Already Selected
for (size_t idx = 0; idx < ui->selectedListWidget->count(); idx++) {
auto item = ui->selectedListWidget->item(idx);
auto text = item->text().trimmed();
if (!text.isEmpty()) {
if (item->isSelected()) {
keeped_list << text; // Move to Select Pool
ui->listPoolWidget->addItem(text);
}
else { // Not Selected In Pool
selected_list << text;
}
}
else { // Remove Empty
ui->selectedListWidget->takeItem(idx);
idx--;
}
}
ui->selectedListWidget->clear();
QSetIterator<QString> iter(selected_list);
while (iter.hasNext()) {
ui->selectedListWidget->addItem(iter.next());
}
if (selected_list.size() < parser_->GetAirportMaxNum()) {
for (size_t idx = selected_list.size(); idx < parser_->GetAirportMaxNum(); idx++) {
ui->selectedListWidget->insertItem(idx," ");
}
}
ListWidgetSortAndTextCenter(ui->listPoolWidget);
ListWidgetSortAndTextCenter(ui->selectedListWidget);
}
void QLandscapeDBDialog::OnExportAirports(bool clicked)
{
ListWidgetCancelSelection(ui->listPoolWidget);
QSet<QString> selected_list, keeped_list;
// Already Selected
for (size_t idx = 0; idx < ui->selectedListWidget->count(); idx++) {
auto item = ui->selectedListWidget->item(idx);
auto text = item->text().trimmed();
if (!text.isEmpty()) {
selected_list << text;
}
}
if (selected_list.size() == 0) {
QMessageBox::critical(NULL, u8"Export .vproj", "No Airport Selected!");
return;
}
std::set<std::string> list;
for (auto iter=selected_list.begin(); iter != selected_list.end(); iter++) {
list.insert(iter->toStdString());
}
if (parser_->SaveAirportList(list)) {
std::string bat_path = ProjectConfig::GetInstance()->GetToolFile("dispatch.bat");
//"D:\Research\ViTools\ViConfigTool\bin64\tools"
//"D:\Research\ViTools\ViConfigTool\bin64\tools\dispatch.bat"
QByteArray output;
bool ret = QCKCmd::ExecCmd(QString::fromStdString(bat_path), QStringList(), output);
if (!ret) {
qDebug() << QString(output);
QMessageBox::critical(NULL, u8"Update .vproj", "Run tools/dispatch.bat failed ! Try it mannual with double click first!");
}
else {
QMessageBox::information(NULL, u8"Update .vproj", u8"操作成功!");
}
}
}
\ No newline at end of file
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef QLANDSCAPEDB_DIALOG_H
#define QLANDSCAPEDB_DIALOG_H
#include <CCoreKit/CCKDefines.h>
#include <QDialog>
namespace Ui {
class QLandscapeDBDialog;
}
class QTreeWidgetItem;
class QListWidget;
class QListWidgetItem;
class AirportListParser;
class QLandscapeDBDialog : public QDialog
{
Q_OBJECT
public:
explicit QLandscapeDBDialog(QWidget *parent = nullptr);
~QLandscapeDBDialog();
void InitData();
Q_SIGNALS:
public Q_SLOTS:
void OnAddAirport(bool clicked);
void OnDelAirport(bool clicked);
void OnExportAirports(bool clicked);
void OnItemClicked(QListWidgetItem* item);
private:
Ui::QLandscapeDBDialog *ui;
std::shared_ptr<AirportListParser> parser_;
void ListWidgetSortAndTextCenter(QListWidget* widget);
void ListWidgetUpdateSelection(QListWidget* widget, QListWidgetItem *selected);
void ListWidgetCancelSelection(QListWidget* widget);
virtual void resizeEvent(QResizeEvent* event) override;
};
#endif // QLANDSCAPEDB_DIALOG_H
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set(QtCoreKitDir ${CMAKE_CURRENT_LIST_DIR})
set(LIB_NAME QtCoreKit)
FILE(GLOB_RECURSE QtCoreKit_SRC
${QtCoreKitDir}/*.h
${QtCoreKitDir}/*.hpp
${QtCoreKitDir}/*.c
${QtCoreKitDir}/*.cc
${QtCoreKitDir}/*.cpp
)
FILE(GLOB_RECURSE QtCoreKit_FORMs
${QtCoreKitDir}/Forms/*.ui
)
FILE(GLOB_RECURSE QtCoreKit_RES
${QtCoreKitDir}/Res/*.qrc
${QtCoreKitDir}/Res/*.qml
${QtCoreKitDir}/Res/*.js
)
if(NOT ANDROID)
source_group(
TREE ${QtCoreKitDir}
PREFIX "QtCoreKit"
FILES ${QtCoreKit_SRC} ${QtCoreKit_FORMs} ${QtCoreKit_RES}
)
endif(NOT ANDROID)
# gen src by forms
qt5_wrap_ui(QtCoreKit_RES_UIC ${QtCoreKit_FORMs})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
# update QtCoreKit_SRC
set(QtCoreKit_SRC ${QtCoreKit_SRC} ${QtCoreKit_FORMs} ${QtCoreKit_RES} ${QtCoreKit_RES_UIC})
set(LIB_DEPS CCoreKit )
add_library(${LIB_NAME} ${LIB_TYPE} ${QtCoreKit_SRC})
target_include_directories(${LIB_NAME} PRIVATE ${INC_QT} ${INC_PY} ${QtCoreKitDir} ${INC_GROUP} )
target_link_libraries(${LIB_NAME} ${LIB_QT} ${LIB_PY} ${LIB_DEPS})
# install libs & headers
INSTALL_INC(${CMAKE_CURRENT_LIST_DIR} include/)
INSTALL_TARGET(${LIB_NAME}) # lib bin exe
# from intern cmake module : apple_func.cmake
if(APPLE)
XCODE_SETTING(${LIB_NAME} ${OS_MIN_VERSION})
endif(APPLE)
if(CCoreKit)
add_dependencies(${LIB_NAME} CCoreKit)
else()
message(FATAL_ERROR "option ON for CCoreKit is required !")
endif(CCoreKit)
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef QTCOREKIT_H
#define QTCOREKIT_H
#include <QtCoreKit/script/QCKCmd.h>
#include <QtCoreKit/utils/QCKDefines.h>
#include <QtCoreKit/utils/QCKFile.h>
#include <QtCoreKit/utils/QCKMessage.h>
#endif /* QTCOREKIT_H */
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
// https://blog.csdn.net/delphigbg/article/details/127781766
#include "QCKCmd.h"
#include <QDebug>
#include <QString>
#include <QProcess>
#include <QDir>
#include <QMessageBox>
#ifdef OSX
// const QString CMD_BIN = "pkexec /bin/bash";
const QString CMD_BIN = "/bin/bash";
const QString CMD_EXT = ".sh";
#elif WIN
// const QString CMD_BIN = "pkexec cmd.exe";
const QString CMD_BIN = "cmd.exe";
const QString CMD_EXT = ".bat";
#endif
static QString PY_BIN = "";
/// @param output if return true, output is cmd success info; if return false, output is cmd error info.
bool QCKCmd::ExecCmd(const QString &toolPath, const QStringList &options, QByteArray &output)
{
qDebug() << toolPath;
bool is_succeed = false;
QProcess *process = new QProcess();
// QProcess::execute() == QProcess::start() + QProcess::waitforFinished() 是阻塞的
if (options.size() > 0) {
process->start(toolPath, options);
} else {
process->start(toolPath);
}
process->waitForFinished(QCK_CMD_TIME_LIMIT);
QByteArray qby_err = process->readAllStandardError();
if (qby_err.size()>0) {
output = qby_err;
is_succeed = false;
} else {
output = process->readAllStandardOutput();
is_succeed = true;
}
if (process != nullptr) {
process->close(); // required: QProcess instance by new, will not exit normally.
delete process;
process = nullptr;
}
return is_succeed;
}
QString QCKCmd::GetSoftPath(const QString &name)
{
QByteArray output;
#ifdef OSX
bool ret = ExecCmd(CMD_BIN, QStringList() << "-c" << "whereis " + name, output);
#elif WIN
bool ret = ExecCmd(CMD_BIN, QStringList() << "/c" << "where " + name, output);
#endif
// qDebug() << output << endl;
if (!ret) {
QMessageBox::critical(NULL, "Check" + name , output.data());
return QString();
}
QString cmd = QString::fromUtf8(output);
#ifdef OSX
QStringList list = cmd.split(" ");
qDebug() << list << endl;
return list[1];
#elif WIN
QStringList list = cmd.split("\r\n");
qDebug() << list << endl;
return list[0];
#endif
}
QString QCKCmd::GetPyBin()
{
if (PY_BIN.isEmpty()) {
#ifdef OSX
PY_BIN = GetSoftPath("python3") + " ";
#elif WIN
PY_BIN = GetSoftPath("python") + " ";
#endif
}
return PY_BIN;
}
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef QCK_CMD_H
#define QCK_CMD_H
#define QCK_CMD_TIME_LIMIT 5000000
#include <CCoreKit/CCKDefines.h>
class QString;
class QStringList;
class QByteArray;
class QCKCmd
{
public:
/// @param output if return true, output is cmd success info; if return false, output is cmd error info.
static bool ExecCmd(const QString &toolPath, const QStringList &options, QByteArray &output);
static QString GetSoftPath(const QString &name);
static QString GetPyBin();
};
#endif /* QCK_CMD_H */
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef QCK_DEFINES_H
#define QCK_DEFINES_H
#define STRING(str) QStringLiteral(str)
//#define STRING(str) tr(u8str)
#endif /* QCK_DEFINES_H */
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "QCKFile.h"
#include <QDir>
#include <QStandardPaths>
#include <QFileDialog>
#include <QMessageBox>
#include "QCKDefines.h"
bool QCKFile::DirectoryCopy(const QString &srcDir, const QString &dstDir, bool coverIfExist)
{
QDir src_dir(srcDir);
QDir dst_dir(dstDir);
if (!dst_dir.exists() && !dst_dir.mkpath(dst_dir.absolutePath())) {
return false;
}
QFileInfoList list = src_dir.entryInfoList();
foreach(QFileInfo item, list) {
if (item.fileName() == "." || item.fileName() == "..") {
continue;
}
if (item.isDir()) {
if(!DirectoryCopy(item.filePath(), dst_dir.filePath(item.fileName()), coverIfExist)) {
return false;
}
} else {
if (coverIfExist && dst_dir.exists(item.fileName())) {
dst_dir.remove(item.fileName());
}
if (!QFile::copy(item.filePath(), dst_dir.filePath(item.fileName()))) {
return false;
}
}
}
return true;
}
bool QCKFile::DirectoryMove(const QString &srcDir, const QString &dstDir, bool coverIfExist)
{
QDir src_dir(srcDir);
QDir dst_dir(dstDir);
if (!dst_dir.exists() && !dst_dir.mkpath(dst_dir.absolutePath())) {
return false;
}
QFileInfoList list = src_dir.entryInfoList();
foreach(QFileInfo item, list) {
if (item.fileName() == "." || item.fileName() == "..") {
continue;
}
if (item.isDir()) {
if (!DirectoryMove(item.filePath(), dst_dir.filePath(item.fileName()), coverIfExist)) {
return false;
}
} else {
if (coverIfExist && dst_dir.exists(item.fileName())) {
dst_dir.remove(item.fileName());
}
if (!QFile::copy(item.filePath(), dst_dir.filePath(item.fileName()))) {
return false;
}
src_dir.remove(item.fileName());
}
}
if (src_dir.isEmpty()) {
src_dir.removeRecursively();
}
return true;
}
// QCKFile::filesWithFilter(".", QStringList() << "test.json", dstList)
bool QCKFile::FilesWithFilter(const QDir &srcDir, const QStringList &filters, QFileInfoList &dstList)
{
QFileInfoList list = srcDir.entryInfoList(filters, QDir::AllDirs|QDir::Files);
foreach(QFileInfo item, list)
{
if (item.fileName() == "." || item.fileName() == "..") {
continue;
}
if (item.isDir()) {
if (!FilesWithFilter(item.filePath(), filters, dstList)) {
return false;
}
} else {
dstList.append(item);
}
}
return true;
}
bool QCKFile::FilesWithExts(const QDir &srcDir, const QStringList &exts, QFileInfoList &dstList)
{
QFileInfoList list = srcDir.entryInfoList(QDir::AllDirs|QDir::Files);
foreach(QFileInfo item, list)
{
if (item.fileName() == "." || item.fileName() == "..") {
continue;
}
if (item.isDir()) {
if (!FilesWithExts(item.filePath(), exts, dstList)) {
return false;
}
} else {
foreach(QString ext, exts) {
if (item.suffix().toLower() == ext.toLower()) {
dstList.append(item);
}
}
}
}
return true;
}
// e.g. QCKFile::SelectFiles(STRING("Files(*.png; *.jpg)"), true);
QStringList QCKFile::SelectFiles(const QString &filter, bool isMulti) {
QString desktop = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
if (isMulti) {
QStringList list = QFileDialog::getOpenFileNames(nullptr, STRING("Select File(s)"), desktop, filter);
return list.size()>0 ? list : QStringList();
}
QString obj_path = QFileDialog::getOpenFileName(nullptr, STRING("Select File(s)"), desktop, filter);
if (obj_path.length() > 0) {
return QStringList() << obj_path;
}
return QStringList();
}
QStringList QCKFile::SelectDirectory(bool isMulti) {
QString desktop = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
QString dir_path = QFileDialog::getExistingDirectory(nullptr, STRING("Select Directory"), desktop, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (dir_path.length() > 0) {
return QStringList() << dir_path;
}
return QStringList();
}
QCKFile::State QCKFile::LoadFile(const QString& fileName, QByteArray &fileData)
{
QFileInfo info(fileName);
if (!info.isFile()) {
return State::Err_NotFile;
}
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
return State::Err_FileOpen;
}
// fileData = file.read(file.bytesAvailable());
fileData = file.readAll();
file.close();
if (fileData.isEmpty()) {
return State::Err_FileEmpty;
}
return State::Succeed;
}
QCKFile::State QCKFile::LoadFile(const QString& dirPath, const QString& fileSuffix, QByteArray &fileData)
{
QString filePath = "";
QDir dir(dirPath);
QFileInfoList list = dir.entryInfoList(QDir::Files);
foreach (QFileInfo item, list) {
if (item.absoluteFilePath().toLower().endsWith(fileSuffix.toLower())) {
filePath = item.absoluteFilePath();
break;
}
}
if (filePath.isEmpty()) {
return State::Err_NotFile;
}
return LoadFile(filePath, fileData);
}
bool QCKFile::SaveFile(const QString& fileName, const QByteArray &data)
{
QFileInfo info(fileName);
if (!info.dir().exists()) {
bool ret = info.dir().mkpath(info.dir().absolutePath());
if (!ret) {
//#ifdef DEBUG
QString tips = "mkpath : " + info.dir().absolutePath() + " failed !";
QMessageBox::warning(NULL, "SaveFile", tips);
//#endif
return false;
}
}
QFile file(fileName);
if (file.open(QIODevice::WriteOnly)) {
QDataStream outStream(&file);
outStream.writeRawData(data.data(), data.size());
file.close();
#ifdef DEBUG
QString tips = "Write File : " + fileName + " succeed !";
QMessageBox::information(NULL, "SaveFile", tips);
#endif
return true;
}
//#ifdef DEBUG
QString tips = "Open : " + fileName + " failed !";
QMessageBox::warning(NULL, "SaveFile", tips);
//#endif
return false;
}
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef QCK_FILE_H
#define QCK_FILE_H
#include <CCoreKit/CCKDefines.h>
#include <QString>
#include <QFileInfo>
// File Write
// https://blog.csdn.net/kllo__/article/details/120176545
// https://blog.csdn.net/xiao123456bin/article/details/123135669
// JSON
// https://blog.csdn.net/qq_45662588/article/details/118882717
// https://blog.51cto.com/dlican/3740655
// https://www.csdn.net/tags/NtDaEgzsMjgxNzItYmxvZwO0O0OO0O0O.html
// https://blog.csdn.net/dengjin20104042056/article/details/102747097
// https://blog.csdn.net/dengjin20104042056/article/details/102747691
class QCKFile
{
public:
enum class State {
Succeed,
Err_OOM,
Err_NotFile,
Err_FileOpen,
Err_FileEmpty
};
static bool DirectoryCopy(const QString &srcDir, const QString &dstDir, bool coverIfExist);
static bool DirectoryMove(const QString &srcDir, const QString &dstDir, bool coverIfExist);
static bool FilesWithFilter(const QDir &srcDir, const QStringList &filters, QFileInfoList &dstList);
static bool FilesWithExts(const QDir &srcDir, const QStringList &exts, QFileInfoList &dstList);
static QStringList SelectFiles(const QString &filter, bool isMulti = true);
static QStringList SelectDirectory(bool isMulti = true);
static State LoadFile(const QString& fileName, QByteArray &fileData);
static State LoadFile(const QString& dirPath, const QString& fileSuffix, QByteArray &fileData);
static bool SaveFile(const QString& fileName, const QByteArray& data);
};
#endif /* QCK_FILE_H */
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#include "QCKMessage.h"
#include <QMessageBox>
void QCKMessage::ShowMsgBox(const QString& title, const QString& text)
{
QMessageBox box;
box.setStyleSheet("QLabel{"
"min-width: 300px; min-height: 100px;"
"color: white; backround-color: #1ABC9C;"
"font-size: 12px;"
"}");
box.setText(text);
box.setWindowTitle(title);
box.exec();
}
\ No newline at end of file
// MIT License
//
// Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#ifndef QCK_MESSAGE_H
#define QCK_MESSAGE_H
#include <CCoreKit/CCKDefines.h>
#include <QFileInfo>
class QString;
class QCKMessage
{
public:
static void ShowMsgBox(const QString &title, const QString &text);
};
#endif /* QCK_MESSAGE_H */
# MIT License
#
# Copyright (c) 2021~2022 [coder4869](https://github.com/coder4869)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
set(SRC_ROOT ${CMAKE_CURRENT_LIST_DIR})
set(INC_FILES ${INC_FILES} ${SRC_ROOT})
message("SRC_ROOT = ${SRC_ROOT}")
# QLandscapeDB
if(WITH_QT AND QLandscapeDB)
include(${SRC_ROOT}/QLandscapeDB/QLandscapeDB.cmake)
endif(WITH_QT AND QLandscapeDB)
# QtCoreKit
if(WITH_QT AND QtCoreKit)
include(${SRC_ROOT}/QtCoreKit/QtCoreKit.cmake)
endif(WITH_QT AND QtCoreKit)
# CCoreKit
if(WITH_QT AND CCoreKit)
include(${SRC_ROOT}/CCoreKit/CCoreKit.cmake)
endif(WITH_QT AND CCoreKit)
cd %~dp0/../conf
echo f | xcopy /y ExportList.vproj "\\192.168.1.23\video\scene_u.vproj" >> tmp.log
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment