Skip to content
Snippets Groups Projects
Select Git revision
  • 2126f1a82f8438c88836620afac624ffc8042f58
  • master default protected
  • android-7.1.2_r28_klist
  • pie-cts-release
  • pie-vts-release
  • pie-cts-dev
  • oreo-mr1-iot-release
  • sdk-release
  • oreo-m6-s4-release
  • oreo-m4-s12-release
  • pie-release
  • pie-r2-release
  • pie-r2-s1-release
  • oreo-vts-release
  • oreo-cts-release
  • oreo-dev
  • oreo-mr1-dev
  • pie-gsi
  • pie-platform-release
  • pie-dev
  • oreo-cts-dev
  • android-o-mr1-iot-release-1.0.4
  • android-9.0.0_r8
  • android-9.0.0_r7
  • android-9.0.0_r6
  • android-9.0.0_r5
  • android-8.1.0_r46
  • android-8.1.0_r45
  • android-n-iot-release-smart-display-r2
  • android-vts-8.1_r5
  • android-cts-8.1_r8
  • android-cts-8.0_r12
  • android-cts-7.1_r20
  • android-cts-7.0_r24
  • android-o-mr1-iot-release-1.0.3
  • android-cts-9.0_r1
  • android-8.1.0_r43
  • android-8.1.0_r42
  • android-n-iot-release-smart-display
  • android-p-preview-5
  • android-9.0.0_r3
41 results

fs_use

Blame
  • CMakeLists.txt 5.14 KiB
    cmake_minimum_required(VERSION 3.3)
    
    project(EMPER)
    
    set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
    message("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
    include(doxygen)
    
    set(CMAKE_CXX_STANDARD 14)
    set(CMAKE_CXX_STANDARD_REQUIRED on)
    set(CMAKE_EXPORT_COMPILE_COMMANDS on)
    
    set(COMMON_FLAGS "-Wall -pedantic -Wextra")# -Werror")
    set(COMMON_FLAGS "${COMMON_FLAGS} -fno-exceptions -fno-omit-frame-pointer")
    
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -faligned-new")
    
    message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
    message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
    
    set(COMMON_DEBUG_FLAGS "-ggdb3")
    set(COMMON_BUILD_DEBUG_FLAGS "${COMMON_DEBUG_FLAGS} -O0")
    
    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMMON_BUILD_DEBUG_FLAGS}")
    set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMMON_BUILD_DEBUG_FLAGS}")
    
    set(COMMON_BUILD_RELWITHDEBUG_FLAGS "${COMMON_DEBUG_FLAGS} -O3")
    set(CMAKE_C_FLAGS_RELWITHDEBUG "${CMAKE_C_FLAGS_RELWITHDEBUG} ${COMMON_BUILD_RELWITHDEBUG_FLAGS}")
    set(CMAKE_CXX_FLAGS_RELWITHDEBUG "${CMAKE_CXX_FLAGS_RELWITHDEBUG} ${COMMON_BUILD_RELWITHDEBUG_FLAGS}")
    
    # For "-rdynamic" see https://stackoverflow.com/a/77336/194894 and "man gcc"
    # We probably don't need it since EMPER is mostly statically linked,
    # but it can't hurt to have it (hopefully).
    set(CMAKE_EXEC_LINKER_FLAGS_DEBUG "${CMAKE_EXEC_LINKER_FLAGS_DEBUG} -rdynamic")
    
    add_definitions(-D_GNU_SOURCE)
    
    set(THREADS_PREFER_PTHREAD_FLAG ON)
    find_package(Threads REQUIRED)
    
    enable_testing()
    
    # Custom options, enable with "cmake -DEMPER_WORKER_SLEEP=ON"
    # Source: https://stackoverflow.com/a/10364240/194894
    macro(emper_option option_name option_description)
        option(EMPER_${option_name} ${option_description})
        if(EMPER_${option_name})
            add_definitions(-DEMPER_${option_name})
        endif(EMPER_${option_name})
    endmacro()
    
    emper_option(WORKER_SLEEP "Enable sleeping worker support")
    emper_option(LOCKED_WS_QUEUE "Use a fully locked queue for work-stealing")
    emper_option(OVERFLOW_QUEUE "Use a overflow queue in case the primary queue is full")
    emper_option(LOCKED_MPSC_QUEUE "Use the locked variant for the MPSC queue")
    emper_option(STATS "Collect stats and print them at the end of the execution")
    emper_option(SPAWN_ON_BLOCK "Runs a backup thread when a fiber gets blocked by the linux scheduler")
    emper_option(CHECK_BLOCK "Checks if any of the fibers call functions which results in a blocked state in the linux scheduler")
    emper_option(ASYNC_NETWORK "Adds support for asynchronous network IO")
    emper_option(ASYNC_DISK_IO "Adds support for asynchronous disk IO")
    
    if(EMPER_ASYNC_NETWORK OR EMPER_ASYNC_DISK_IO)
        add_definitions(-DEMPER_ASYNC_LIB)
    endif(EMPER_ASYNC_NETWORK OR EMPER_ASYNC_DISK_IO)
    
    # Macro to add files to a var. Can even be used in subdirectories.
    # Source: http://stackoverflow.com/a/7049380/194894
    macro (add_files var)
        file (RELATIVE_PATH _relPath "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
        foreach (_src ${ARGN})
            if (_relPath)
                list (APPEND ${var} "${_relPath}/${_src}")
            else()
                list (APPEND ${var} "${_src}")
            endif()
        endforeach()
        if (_relPath)
            # propagate ${var} to parent directory
            set (${var} ${${var}} PARENT_SCOPE)
        endif()
    endmacro()
    
    enable_language(ASM_NASM)
    
    add_subdirectory("emper")
    
    message("EMPER_SOURCE: ${EMPER_SOURCE}")
    message("EMPER_INCLUDE: ${EMPER_INCLUDE}")
    message("CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")
    message("CMAKE_CXX_FLAGS_RELWITHDEBUG: ${CMAKE_CXX_FLAGS_RELWITHDEBUG}")
    message("CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
    
    add_library(emper_asm_source STATIC ${EMPER_ASM_SOURCE})
    
    add_library(emper STATIC ${EMPER_SOURCE})
    foreach(include_dir ${EMPER_INCLUDE})
      message("Adding include directory: ${include_dir}")
      target_include_directories(emper PUBLIC
    	$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${include_dir}>
    	$<INSTALL_INTERFACE:${include_dir}>
      )
    endforeach()
    if (EMPER_CHECK_BLOCK)
        target_link_libraries(emper bcc)
        target_include_directories(emper PUBLIC "/usr/include/bcc")
    endif()
    # The following property is supposed to enable something like LTO. But
    # CMake appearantly only supports it for the icc. See
    # http://stackoverflow.com/a/31522585/194894
    # set_property(TARGET emper PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
    target_link_libraries(emper Threads::Threads emper_asm_source)
    
    if(EMPER_ASYNC_DISK_IO)
        target_link_libraries(emper uring)
    endif(EMPER_ASYNC_DISK_IO)
    
    add_library(c_emper STATIC ${C_EMPER_SOURCE})
    # See comment above regarding INTERPROCEDURAL_OPTIMIZATION
    # set_property(TARGET c_emper PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
    target_link_libraries(c_emper emper)
    
    add_subdirectory("apps")
    
    add_subdirectory("tests")
    
    add_subdirectory("eval")
    
    file(GLOB ALL_SOURCE_FILES *.cpp)
    file(GLOB ALL_HEADER_FILES *.hpp)
    
    add_custom_target(clang-tidy
      COMMAND clang-tidy
      -config=''
      -p ${CMAKE_BINARY_DIR}
      ${ALL_SOURCE_FILES}
      )
    add_dependencies(clang-tidy Main)
    
    add_custom_target(CheckEmperVersionHeader
      COMMAND ${PROJECT_SOURCE_DIR}/scripts/versionManager.sh -v check
      COMMENT "Checking if EMPER version header is up-to-date"
      )
    add_dependencies(emper CheckEmperVersionHeader)