<commit_before>cmake_minimum_required(VERSION 3.0)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

project(ARK)

#check cxx flag in linux system
if(UNIX)
	#linux
	include(CheckCXXCompilerFlag)
	CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
	CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
	if(COMPILER_SUPPORTS_CXX11)
	    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
	elseif(COMPILER_SUPPORTS_CXX0X)
	    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
	else()
		message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
	endif()
endif()

########################################################################

set(ROOT_DIR ${PROJECT_SOURCE_DIR})

include_directories(
    ${ROOT_DIR}
    ${ROOT_DIR}/Dep
    ${ROOT_DIR}/Dep/libevent/include
    ${ROOT_DIR}/Dep/libevent/compat
    ${ROOT_DIR}/Dep/evpp
    ${ROOT_DIR}/Dep/protobuf/src
    ${ROOT_DIR}/Frame
)

if(UNIX)
    #linux
    include_directories(${ROOT_DIR}/Dep/libevent/include)

    if(CMAKE_BUILD_TYPE MATCHES "Debug")
        set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -fPIC")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O0 -Wall -g -ggdb -DDEBUG -fPIC")
        set(DEP_LIB_DIR ${ROOT_DIR}/Dep/lib/ ${ROOT_DIR}/Dep/lib/Debug/ ${ROOT_DIR}/Bin/Debug)
    else()
        set(CMAKE_BUILD_TYPE "Release")
        set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -fPIC")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -Wall -fPIC")
        set(DEP_LIB_DIR ${ROOT_DIR}/Dep/lib/ ${ROOT_DIR}/Dep/lib/Release/ ${ROOT_DIR}/Bin/Release)
    endif()
    set(LDFLAGS "$ENV{LDFLAGS} -stdlib=libc++")
    ADD_DEFINITIONS(-std=c++11)
    set(SDK_OUTPUT_DIR ${ROOT_DIR}/Bin/Comm/${CMAKE_BUILD_TYPE})
else()
    #windows
    include_directories(${ROOT_DIR}/Dep/libevent/WIN32-code/nmake)
    set(CMAKE_CXX_FLAGS "-D_X64 -D_WINDOWS /EHsc")
    set(DEP_LIB_DIR ${ROOT_DIR}/Dep/lib ${ROOT_DIR}/Bin/Comm)
    set(SDK_OUTPUT_DIR ${ROOT_DIR}/Bin/Comm)
    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

link_directories(${DEP_LIB_DIR})

#log
message("ROOT dir=${ROOT_DIR}")
message("SDK Output dir=${SDK_OUTPUT_DIR}")
message("DEP lib dir=${DEP_LIB_DIR}")

##################################################################
message("Start to build all...")
add_subdirectory(Frame/SDK)
add_subdirectory(Frame/Server)
#add_subdirectory(Frame/Examples)
#add_subdirectory(Frame/Tools)<commit_msg>add cxx_flags for linux<commit_after>cmake_minimum_required(VERSION 3.0)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

project(ARK)

#check cxx flag in linux system
if(UNIX)
	#linux
	include(CheckCXXCompilerFlag)
	CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
	CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
	if(COMPILER_SUPPORTS_CXX11)
	    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
	elseif(COMPILER_SUPPORTS_CXX0X)
	    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
	else()
		message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
	endif()
endif()

########################################################################

set(ROOT_DIR ${PROJECT_SOURCE_DIR})

include_directories(
    ${ROOT_DIR}
    ${ROOT_DIR}/Dep
    ${ROOT_DIR}/Dep/libevent/include
    ${ROOT_DIR}/Dep/libevent/compat
    ${ROOT_DIR}/Dep/evpp
    ${ROOT_DIR}/Dep/protobuf/src
    ${ROOT_DIR}/Frame
)

if(UNIX)
    #linux
    include_directories(${ROOT_DIR}/Dep/libevent/include)

    if(CMAKE_BUILD_TYPE MATCHES "Debug")
        set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -fPIC")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O0 -Wall -g -ggdb -DDEBUG -fPIC")
        set(DEP_LIB_DIR ${ROOT_DIR}/Dep/lib/ ${ROOT_DIR}/Dep/lib/Debug/ ${ROOT_DIR}/Bin/Debug)
    else()
        set(CMAKE_BUILD_TYPE "Release")
        set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -fPIC")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O2 -Wall -fPIC")
        set(DEP_LIB_DIR ${ROOT_DIR}/Dep/lib/ ${ROOT_DIR}/Dep/lib/Release/ ${ROOT_DIR}/Bin/Release)
    endif()
    set(LDFLAGS "$ENV{LDFLAGS} -stdlib=libc++")
    ADD_DEFINITIONS(-std=c++11)
    set(SDK_OUTPUT_DIR ${ROOT_DIR}/Bin/Comm/${CMAKE_BUILD_TYPE})

    set (CXX_FLAGS
        -g
        -Wall
        -Wno-unused-parameter
        -Wno-unused-function
        -Wunused-variable
        -Wunused-value
        -Wshadow
        -Wcast-qual
        -Wcast-align
        -Wwrite-strings
        -Wsign-compare
        -Winvalid-pch
        -fms-extensions
        -Wfloat-equal
        -Wextra
    )

    SET(CMAKE_CXX_FLAGS_DEBUG   "-O0 -g -ggdb -D_DEBUG")
    SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -ggdb -DNDEBUG")

else()
    #windows
    include_directories(${ROOT_DIR}/Dep/libevent/WIN32-code/nmake)
    set(CMAKE_CXX_FLAGS "-D_X64 -D_WINDOWS /EHsc")
    set(DEP_LIB_DIR ${ROOT_DIR}/Dep/lib ${ROOT_DIR}/Bin/Comm)
    set(SDK_OUTPUT_DIR ${ROOT_DIR}/Bin/Comm)
    add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif()

link_directories(${DEP_LIB_DIR})

#log
message("ROOT dir=${ROOT_DIR}")
message("SDK Output dir=${SDK_OUTPUT_DIR}")
message("DEP lib dir=${DEP_LIB_DIR}")

##################################################################
message("Start to build all...")
add_subdirectory(Frame/SDK)
add_subdirectory(Frame/Server)
#add_subdirectory(Frame/Examples)
#add_subdirectory(Frame/Tools)
{'fraction_non_alphanumeric': 0.18869309838472834, 'fraction_numerical': 0.010646108663729809, 'mean_word_length': 4.509605662285137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1917541', 'n_tokens_mistral': 2181, 'n_tokens_neox': 2065, 'n_words': 297}