From ba212dbc0a9d0a8e730d1ad32fec1f995f8d9f91 Mon Sep 17 00:00:00 2001 From: "Dmitriy A. Gerasimov" <dmitriy.gerasimov@demlabs.net> Date: Mon, 13 Apr 2020 16:29:50 +0700 Subject: [PATCH] [+] Added OS, arch and others detections --- CMakeLists.txt | 52 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34f2777c68..6c3e93b611 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,60 @@ project(cellframe-sdk C) cmake_minimum_required(VERSION 2.8) set(CMAKE_C_STANDARD 11) -set(CELLFRAME_SDK_NATIVE_VERSION "1.1-0") +set(CELLFRAME_SDK_NATIVE_VERSION "1.1-1") add_definitions ("-DCELLFRAME_SDK_VERSION=\"${CELLFRAME_SDK_NATIVE_VERSION}\"") +if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (DAP_DEBUG)) + message("Debug build") + SET(DAP_DEBUG ON) +else() + message("Release build") + SET(DAP_RELEASE ON) +endif() + +if(CMAKE_SIZEOF_VOID_P EQUAL "8") + set(DEFAULT_BUILD_64 ON) +else() + set(DEFAULT_BUILD_64 OFF) +endif() +option(BUILD_64 "Build for 64-bit? 'OFF' builds for 32-bit." ${DEFAULT_BUILD_64}) + +if(BUILD_64) + set(ARCH_WIDTH "64") +else() + set(ARCH_WIDTH "32") +endif() +message(STATUS "Building for a ${ARCH_WIDTH}-bit system") + +if(UNIX) + add_definitions ("-DDAP_OS_LINUX -DDAP_OS_UNIX") + # add_definitions ("-DDAP_LOG_MT") + if(DAP_DEBUG) + set(_CCOPT "-DDAP_DEBUG -Wall -Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -pg -g3 -ggdb -fno-eliminate-unused-debug-symbols") + set(_LOPT "-pg") + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pg") + else() + set(_CCOPT "-Wno-unused-function -Wno-implicit-fallthrough -Wno-unused-variable -Wno-unused-parameter -Wno-unused-but-set-variable -O3 -fPIC -fno-ident -ffast-math -ftree-vectorize -fno-asynchronous-unwind-tables -ffunction-sections -Wl,--gc-sections -Wl,--strip-all -std=gnu11") + endif() + + if (ANDROID) + set(_CCOPT "${_CCOPT} -fforce-enable-int128 -std=gnu11") + add_definitions ("-DDAP_OS_ANDROID -DDAP_OS_UNIX") + endif() + + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}") + set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} ${_LOPT}") + + if (ANDROID) + add_subdirectory(lib/json-c) + add_subdirectory(lib/sqlite3) + #add_subdirectory(lib/libev) + include_directories(lib/) + else() + endif(ANDROID) +endif() + if(WIN32) add_definitions("-DHAVE_PREAD") add_definitions("-DHAVE_MMAP") -- GitLab