1 Star 0 Fork 3

edision/std_com

forked from ThinkingT/std_com 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CMakeLists.txt 9.82 KB
一键复制 编辑 原始数据 按行查看 历史
shangyuwei 提交于 2022-09-25 03:14 . up
cmake_minimum_required(VERSION 2.8)
project(mainapp)
# C compiler
if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(USING_GCC 1)
message("-- C:Compiler: gcc")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
set(USING_CLANG 1)
message("-- C:Compiler: clang")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "AppleClang")
set(USING_APPLECLANG 1)
message("-- C:Compiler: apple_clang")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "TI")
set(USING_TI 1)
message("-- C:Compiler: ti")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
set(USING_MSVC 1)
message("-- C:Compiler: MSVC")
endif()
#CPP compiler
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(USING_GCC 1)
message("-- CXX:Compiler: g++")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(USING_CLANG 1)
message("-- CXX:Compiler: clang")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
set(USING_APPLECLANG 1)
message("-- CXX:Compiler: apple_clang")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "TI")
set(USING_TI 1)
message("-- CXX:Compiler: ti")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(USING_MSVC 1)
message("-- CXX:Compiler: MSVC")
endif()
message("-- C_Compiler_Path: ${CMAKE_C_COMPILER}")
message("-- CXX_Compiler_Path:${CMAKE_CXX_COMPILER}")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv5te")
set(Target32Bit true)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7-a")
add_definitions("-DTARGET32BIT")
set(Target32Bit true)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "mips")
add_definitions("-DTARGET32BIT")
set(Target32Bit true)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "i686")
add_definitions("-DTARGET32BIT")
set(Target32Bit true)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
add_definitions("-DTARGET32BIT")
set(Target32Bit true)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
add_definitions("-DTARGET64BIT")
set(Target64Bit true)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "mips64")
add_definitions("-DTARGET64BIT")
set(Target64Bit true)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
add_definitions("-DTARGET64BIT")
set(Target64Bit true)
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64")
add_definitions("-DTARGET64BIT")
set(Target64Bit true)
else()
message(FATAL_ERROR "Unknown Process Bit=${CMAKE_SYSTEM_PROCESSOR}")
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Android")
add_definitions("-DNDEBUG")
add_definitions("-DANDROID")
set(LINUX_OS true)
set(UNIX_OS true)
set(ANDROID_OS true)
if (${ANDROID_ABI} STREQUAL "x86_64")
include_directories(${ANDROID_SYSROOT}/usr/include/x86_64-linux-android)
elseif (${ANDROID_ABI} STREQUAL "x86")
include_directories(${ANDROID_SYSROOT}/usr/include/i686-linux-android)
elseif (${ANDROID_ABI} STREQUAL "armeabi-v7a")
include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
elseif (${ANDROID_ABI} STREQUAL "arm64-v8a")
include_directories(${ANDROID_SYSROOT}/usr/include/aarch64-linux-android)
elseif (${ANDROID_ABI} STREQUAL "armeabi")
include_directories(${ANDROID_SYSROOT}/usr/include/arm-linux-androideabi)
elseif (${ANDROID_ABI} STREQUAL "mips")
#include_directories(${ANDROID_SYSROOT}/usr/include/mipsel-linux-android)
elseif (${ANDROID_ABI} STREQUAL "mips64")
#include_directories(${ANDROID_SYSROOT}/usr/include/mips64el-linux-android)
endif()
message("-- ANDROID Cpu: ${ANDROID_ABI}")
set(compile_os "Android")
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
add_definitions("-DLINUX")
set(LINUX_OS true)
set(UNIX_OS true)
set(compile_os "Linux")
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions("-DUNIX")
set(UNIX_OS true)
set(CMAKE_MACOSX_RPATH 0)
set(compile_os "Darwin")
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
add_definitions("-DUNIX")
set(UNIX_OS true)
set(compile_os "FreeBSD")
elseif (CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
add_definitions("-DWINDOWS")
set(WIN_OS true)
set(compile_os "CYGWIN")
add_definitions("-DWIN32")
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions("-DWINDOWS")
add_definitions("-DUNICODE")
add_definitions("-DWIN32")
set(WIN_OS true)
elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS")
add_definitions("-DOHOS")
set(UNIX_OS true)
set(OHOS_OS "ture")
set(compile_os "Ohos")
message("-- OHOS Cpu: ${OHOS_ARCH}")
else()
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Android")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/${ANDROID_ABI})
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/${ANDROID_ABI})
link_directories(${PROJECT_SOURCE_DIR}/libs/${ANDROID_ABI})
message("-- Android: LibraryProject-Project: ${PROJECT_SOURCE_DIR}/libs/${ANDROID_ABI}")
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
link_directories(${PROJECT_SOURCE_DIR}/libs/)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
link_directories(${PROJECT_SOURCE_DIR}/libs/)
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
link_directories(${PROJECT_SOURCE_DIR}/libs/)
elseif (CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
link_directories(${PROJECT_SOURCE_DIR}/libs/)
elseif (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/)
link_directories(${PROJECT_SOURCE_DIR}/libs/)
elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS")
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/${OHOS_ARCH})
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/libs/${OHOS_ARCH})
link_directories(${PROJECT_SOURCE_DIR}/libs/${OHOS_ARCH})
message("-- OHOS: LibraryProject-Project: ${PROJECT_SOURCE_DIR}/libs/${OHOS_ARCH}")
else()
message(FATAL_ERROR "unknown CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}")
endif()
option(ENABLE_STDCOM "open stdcom framework" ON)
option(ENABLE_FSANITIZE "debug fsanitize" OFF)
if(Target64Bit STREQUAL true)
message("-- CPU-Target: 64")
message("-- void* ptr size =>${CMAKE_SIZEOF_VOID_P}")
elseif (Target32Bit STREQUAL true)
message("-- CPU-Target: 32")
message("-- void* ptr size =>${CMAKE_SIZEOF_VOID_P}")
else()
message(FATAL_ERROR "-- void* ptr size =>${CMAKE_SIZEOF_VOID_P}")
endif()
if (${WIN_OS})
add_definitions(-DUNICODE
-D_UNICODE
-DWIN32_LEAN_AND_MEAN
-D_WIN32_WINNT>=0x500)
else()
SET(CMAKE_C_FLAGS -std=gnu99)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CMAKE_BUILD_TYPE Debug)
add_definitions(-DDEBUG)
if (${WIN_OS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo")
set(compile ${CMAKE_C_FLAGS_DEBUG})
set(static_compile ${CMAKE_CXX_FLAGS_DEBUG})
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG /OPT:REF /OPT:ICF")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /DEBUG /OPT:REF /OPT:ICF")
message("-- Win Dll Link param: ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
message("-- Win Exe Link param: ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
else()
set(compile "-g3 -fPIC -fvisibility=hidden")
set(static_compile "-g3 -fPIC -fvisibility=hidden")
endif()
message("-- Debug Compile Project")
else()
set(CMAKE_BUILD_TYPE Release)
if (${WIN_OS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /nologo")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /nologo")
set(compile ${CMAKE_C_FLAGS})
set(static_compile ${CMAKE_C_FLAGS})
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
message("-- Win Dll Link param: ${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
message("-- Win Exe Link param: ${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
else()
set(compile "-O3 -g3 -fPIC -fvisibility=hidden")
set(static_compile "-g3 -fPIC -fvisibility=hidden")
endif()
message("-- Release Compile Project")
endif()
set(by3rd_library_output "${PROJECT_SOURCE_DIR}/3rd/lib" CACHE INTERNAL "3rd Library" )
set(by3rd_library_include "${PROJECT_SOURCE_DIR}/3rd/include" CACHE INTERNAL "3rd include" )
set(dynamic "-fvisibility=hidden -Wl,--no-as-needed -frtti -Wall -Werror -fexceptions")
set(execute "-Wall -Werror -fexceptions")
set(static "-fPIC -fvisibility=hidden -Wl,--no-as-needed -frtti -Wall -Werror -fexceptions")
message("-- base-include: ${PROJECT_SOURCE_DIR}/include/")
message("-- base-include: ${by3rd_library_include}/")
message("-- base-lib: ${PROJECT_SOURCE_DIR}/libs/${CMAKE_BUILD_TYPE}/")
message("-- base-lib: ${PROJECT_SOURCE_DIR}/lib/${CMAKE_BUILD_TYPE}/")
message("-- Compile: ${CMAKE_BUILD_TYPE}")
message("-- Compile param: ${compile}")
message("-- System: ${CMAKE_SYSTEM_NAME}")
message("-- System_Info_file: ${CMAKE_SYSTEM_INFO_FILE}")
message("-- System_Processor: ${CMAKE_SYSTEM_PROCESSOR}")
message("-- Host_System_Processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
message("-- System: ${CMAKE_SYSTEM}")
message("-- OutPut-Project: ${EXECUTABLE_OUTPUT_PATH}")
message("-- OutPut-LibraryProject: ${LIBRARY_OUTPUT_PATH}")
add_subdirectory(stdcrt)
add_subdirectory(stdcrt_test)
add_subdirectory(nettls)
if(ENABLE_STDCOM)
add_subdirectory(container)
add_subdirectory(license)
add_subdirectory(access)
add_subdirectory(asynio)
add_subdirectory(net)
add_subdirectory(logs)
add_subdirectory(mainview)
add_subdirectory(testmain)
add_subdirectory(main)
add_subdirectory(runtime)
add_subdirectory(stdcom_tool)
add_subdirectory(msgbus)
if (${WIN_OS})
add_subdirectory(uibase)
endif()
endif()
if (CMAKE_SYSTEM_NAME MATCHES "Android")
add_subdirectory(dispatch)
elseif (CMAKE_SYSTEM_NAME MATCHES "OHOS")
add_subdirectory(dispatch)
else()
endif()
if(ENABLE_FSANITIZE)
message("-- Enable-fSanitize")
endif()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/edisionLee/std_com.git
[email protected]:edisionLee/std_com.git
edisionLee
std_com
std_com
dev

搜索帮助