Fixed tests and improve multithread sync #9

Merged
andrey merged 2 commits from atomic into master 2020-07-08 15:36:37 +03:00
5 changed files with 774 additions and 770 deletions

View File

@@ -1,764 +1,764 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0017 NEW) # need include() with .cmake cmake_policy(SET CMP0017 NEW) # need include() with .cmake
project(pip) project(pip)
set(_PIP_MAJOR 1) set(_PIP_MAJOR 1)
set(_PIP_MINOR 22) set(_PIP_MINOR 23)
set(_PIP_REVISION 0) set(_PIP_REVISION 0)
set(_PIP_SUFFIX ) set(_PIP_SUFFIX )
set(_PIP_COMPANY SHS) set(_PIP_COMPANY SHS)
set(_PIP_DOMAIN org.SHS) set(_PIP_DOMAIN org.SHS)
if ("x${CMAKE_MODULE_PATH}" STREQUAL "x") if ("x${CMAKE_MODULE_PATH}" STREQUAL "x")
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
endif() endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
set(PIP_BUILD 1) set(PIP_BUILD 1)
include(CheckFunctionExists) include(CheckFunctionExists)
include(DeployMacros) include(DeployMacros)
include(PIPMacros) include(PIPMacros)
if(NOT DEFINED BUILD_NUMBER) if(NOT DEFINED BUILD_NUMBER)
set(BUILD_NUMBER 9999) set(BUILD_NUMBER 9999)
endif() endif()
if("x${BUILD_NUMBER}" STREQUAL "x") if("x${BUILD_NUMBER}" STREQUAL "x")
set(BUILD_NUMBER 0) set(BUILD_NUMBER 0)
endif() endif()
set(_ICU_DEFAULT OFF) set(_ICU_DEFAULT OFF)
if((NOT DEFINED WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT DEFINED APPLE)) if((NOT DEFINED WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT DEFINED APPLE))
set(_ICU_DEFAULT ON) set(_ICU_DEFAULT ON)
endif() endif()
# Options # Options
option(ICU "ICU support for convert codepages" ${_ICU_DEFAULT}) option(ICU "ICU support for convert codepages" ${_ICU_DEFAULT})
option(STD_IOSTREAM "Building with std iostream operators support" OFF) option(STD_IOSTREAM "Building with std iostream operators support" OFF)
option(INTROSPECTION "Build with introspection" OFF) option(INTROSPECTION "Build with introspection" OFF)
option(LIB "System install" ON) option(LIB "System install" ON)
option(STATIC_LIB OFF) option(STATIC_LIB OFF)
option(TESTS "Build tests and perform their before install step" OFF) option(TESTS "Build tests and perform their before install step" OFF)
set(PIP_UTILS 1) set(PIP_UTILS 1)
if(LIBPROJECT) if(LIBPROJECT)
set(PIP_UTILS ${UTILS}) set(PIP_UTILS ${UTILS})
endif() endif()
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
# Basic # Basic
macro(gather_src DIR CPP H H_P) macro(gather_src DIR CPP H H_P)
set(CS) set(CS)
set(HS) set(HS)
set(PHS) set(PHS)
file(GLOB CS "${DIR}/*.cpp") file(GLOB CS "${DIR}/*.cpp")
file(GLOB HS "${DIR}/*.h") file(GLOB HS "${DIR}/*.h")
file(GLOB PHS "${DIR}/*_p.h") file(GLOB PHS "${DIR}/*_p.h")
list(REMOVE_ITEM HS "${PHS}") list(REMOVE_ITEM HS "${PHS}")
list(APPEND ${CPP} ${CS}) list(APPEND ${CPP} ${CS})
list(APPEND ${H} ${HS}) list(APPEND ${H} ${HS})
list(APPEND ${H_P} ${PHS}) list(APPEND ${H_P} ${PHS})
endmacro() endmacro()
set(PIP_SRC_MAIN "lib/main") set(PIP_SRC_MAIN "lib/main")
set(PIP_SRC_CONSOLE "lib/console") set(PIP_SRC_CONSOLE "lib/console")
set(PIP_SRC_CRYPT "lib/crypt") set(PIP_SRC_CRYPT "lib/crypt")
set(PIP_SRC_COMPRESS "lib/compress") set(PIP_SRC_COMPRESS "lib/compress")
set(PIP_SRC_USB "lib/usb") set(PIP_SRC_USB "lib/usb")
set(PIP_SRC_FFTW "lib/fftw") set(PIP_SRC_FFTW "lib/fftw")
set(PIP_SRC_OPENCL "lib/opencl") set(PIP_SRC_OPENCL "lib/opencl")
set(PIP_SRC_IO_UTILS "lib/io_utils") set(PIP_SRC_IO_UTILS "lib/io_utils")
set(PIP_SRC_CONCURRENT "lib/concurrent") set(PIP_SRC_CONCURRENT "lib/concurrent")
set(PIP_SRC_CLOUD "lib/cloud") set(PIP_SRC_CLOUD "lib/cloud")
set(PIP_SRC_DIRS ${PIP_SRC_MAIN} set(PIP_SRC_DIRS ${PIP_SRC_MAIN}
${PIP_SRC_CONSOLE} ${PIP_SRC_CONSOLE}
${PIP_SRC_CRYPT} ${PIP_SRC_CRYPT}
${PIP_SRC_COMPRESS} ${PIP_SRC_COMPRESS}
${PIP_SRC_USB} ${PIP_SRC_USB}
${PIP_SRC_FFTW} ${PIP_SRC_FFTW}
${PIP_SRC_OPENCL} ${PIP_SRC_OPENCL}
${PIP_SRC_IO_UTILS} ${PIP_SRC_IO_UTILS}
${PIP_SRC_CONCURRENT} ${PIP_SRC_CONCURRENT}
${PIP_SRC_CLOUD} ${PIP_SRC_CLOUD}
) )
set(PIP_LIBS_TARGETS pip) set(PIP_LIBS_TARGETS pip)
set(LIBS_MAIN) set(LIBS_MAIN)
set(LIBS_STATUS) set(LIBS_STATUS)
set(HDRS) set(HDRS)
set(PHDRS) set(PHDRS)
if (TESTS) if (TESTS)
set(PIP_SRC_CONCURRENT_TEST "src_concurrent/test") set(PIP_SRC_CONCURRENT_TEST "lib/concurrent/test")
endif() endif()
if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
set(STATIC_LIB ON) set(STATIC_LIB ON)
endif() endif()
if(STATIC_LIB) if(STATIC_LIB)
set(PIP_LIB_TYPE STATIC) set(PIP_LIB_TYPE STATIC)
add_definitions(-DPIP_STATIC_DEFINE) add_definitions(-DPIP_STATIC_DEFINE)
#message(STATUS "Building PIP static library") #message(STATUS "Building PIP static library")
else() else()
set(PIP_LIB_TYPE SHARED) set(PIP_LIB_TYPE SHARED)
#message(STATUS "Building PIP shared library") #message(STATUS "Building PIP shared library")
endif() endif()
# Version # Version
set_version(PIP set_version(PIP
MAJOR "${_PIP_MAJOR}" MAJOR "${_PIP_MAJOR}"
MINOR "${_PIP_MINOR}" MINOR "${_PIP_MINOR}"
REVISION "${_PIP_REVISION}" REVISION "${_PIP_REVISION}"
BUILD "${BUILD_NUMBER}" BUILD "${BUILD_NUMBER}"
SUFFIX "${_PIP_SUFFIX}" SUFFIX "${_PIP_SUFFIX}"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h") OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
set_deploy_property(pip ${PIP_LIB_TYPE} set_deploy_property(pip ${PIP_LIB_TYPE}
LABEL "PIP main library" LABEL "PIP main library"
FULLNAME "${_PIP_DOMAIN}.pip" FULLNAME "${_PIP_DOMAIN}.pip"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h") if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h") file(REMOVE "${CMAKE_CURRENT_SOURCE_DIR}/${PIP_SRC_MAIN}/piversion.h")
endif() endif()
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/piversion.h") list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/piversion.h")
message(STATUS "Building PIP version ${PIP_VERSION} (${PIP_LIB_TYPE})") message(STATUS "Building PIP version ${PIP_VERSION} (${PIP_LIB_TYPE})")
if(MINGW) if(MINGW)
find_package(MinGW REQUIRED) find_package(MinGW REQUIRED)
list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB}) list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB})
else() else()
if(APPLE) if(APPLE)
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
set(CMAKE_INSTALL_NAME_DIR "@rpath") set(CMAKE_INSTALL_NAME_DIR "@rpath")
else() else()
include_directories(/usr/local/include) include_directories(/usr/local/include)
link_directories(/usr/local/lib) link_directories(/usr/local/lib)
endif() endif()
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib") set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib")
set(CMAKE_MACOSX_RPATH 1) set(CMAKE_MACOSX_RPATH 1)
else() else()
set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib") set(CMAKE_INSTALL_RPATH "\$ORIGIN;\$ORIGIN/lib")
endif() endif()
endif() endif()
if(LIB) if(LIB)
if(WIN32) if(WIN32)
if(MINGW) if(MINGW)
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR}) set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
endif() endif()
else() else()
if (DEFINED ANDROID_PLATFORM) if (DEFINED ANDROID_PLATFORM)
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr) set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
else() else()
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX}) set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX})
else() else()
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local) set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
endif() endif()
endif() endif()
endif() endif()
endif() endif()
if (NOT DEFINED PIP_CMG) if (NOT DEFINED PIP_CMG)
if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM)) if (CMAKE_CROSSCOMPILING OR (DEFINED ANDROID_PLATFORM))
set(PIP_CMG "pip_cmg") set(PIP_CMG "pip_cmg")
set(PIP_RC "pip_rc") set(PIP_RC "pip_rc")
set(PIP_DEPLOY_TOOL "deploy_tool") set(PIP_DEPLOY_TOOL "deploy_tool")
else() else()
set(PIP_CMG "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator/pip_cmg") set(PIP_CMG "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator/pip_cmg")
set(PIP_RC "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler/pip_rc") set(PIP_RC "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler/pip_rc")
set(PIP_DEPLOY_TOOL "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool/deploy_tool") set(PIP_DEPLOY_TOOL "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool/deploy_tool")
endif() endif()
endif() endif()
# Compiler # Compiler
get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME) get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
#message("${C_COMPILER}") #message("${C_COMPILER}")
# Sources # Sources
# Main lib # Main lib
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent" "cloud") set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent" "cloud")
include_directories("${PIP_SRC_MAIN}") include_directories("${PIP_SRC_MAIN}")
set(PIP_MAIN_FOLDERS) set(PIP_MAIN_FOLDERS)
foreach(F ${PIP_FOLDERS}) foreach(F ${PIP_FOLDERS})
list(APPEND PIP_MAIN_FOLDERS "\"${PROJECT_SOURCE_DIR}/${PIP_SRC_MAIN}/${F}\"") list(APPEND PIP_MAIN_FOLDERS "\"${PROJECT_SOURCE_DIR}/${PIP_SRC_MAIN}/${F}\"")
include_directories("${PIP_SRC_MAIN}/${F}") include_directories("${PIP_SRC_MAIN}/${F}")
gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS) gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS)
endforeach(F) endforeach(F)
# Crypt lib # Crypt lib
gather_src("${PIP_SRC_CRYPT}" CPP_LIB_CRYPT HDRS PHDRS) gather_src("${PIP_SRC_CRYPT}" CPP_LIB_CRYPT HDRS PHDRS)
# Console lib # Console lib
gather_src("${PIP_SRC_CONSOLE}" CPP_LIB_CONSOLE HDRS PHDRS) gather_src("${PIP_SRC_CONSOLE}" CPP_LIB_CONSOLE HDRS PHDRS)
# Compress lib # Compress lib
gather_src("${PIP_SRC_COMPRESS}" CPP_LIB_COMPRESS HDRS PHDRS) gather_src("${PIP_SRC_COMPRESS}" CPP_LIB_COMPRESS HDRS PHDRS)
# USB lib # USB lib
gather_src("${PIP_SRC_USB}" CPP_LIB_USB HDRS PHDRS) gather_src("${PIP_SRC_USB}" CPP_LIB_USB HDRS PHDRS)
# FFTW lib # FFTW lib
gather_src("${PIP_SRC_FFTW}" CPP_LIB_FFTW HDRS PHDRS) gather_src("${PIP_SRC_FFTW}" CPP_LIB_FFTW HDRS PHDRS)
# OpenCL lib # OpenCL lib
gather_src("${PIP_SRC_OPENCL}" CPP_LIB_OPENCL HDRS PHDRS) gather_src("${PIP_SRC_OPENCL}" CPP_LIB_OPENCL HDRS PHDRS)
# IO Utils lib # IO Utils lib
gather_src("${PIP_SRC_IO_UTILS}" CPP_LIB_IO_UTILS HDRS PHDRS) gather_src("${PIP_SRC_IO_UTILS}" CPP_LIB_IO_UTILS HDRS PHDRS)
# Concurrent lib # Concurrent lib
gather_src("${PIP_SRC_CONCURRENT}" CPP_LIB_CONCURRENT HDRS PHDRS) gather_src("${PIP_SRC_CONCURRENT}" CPP_LIB_CONCURRENT HDRS PHDRS)
gather_src("${PIP_SRC_CONCURRENT_TEST}" CPP_CONCURRENT_TEST HDRS PHDRS) gather_src("${PIP_SRC_CONCURRENT_TEST}" CPP_CONCURRENT_TEST HDRS PHDRS)
# Cloud lib # Cloud lib
gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS) gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS)
if(PIP_FREERTOS) if(PIP_FREERTOS)
add_definitions(-DPIP_FREERTOS) add_definitions(-DPIP_FREERTOS)
set(ICU OFF) set(ICU OFF)
set(LIB OFF) set(LIB OFF)
endif() endif()
# Check Bessel functions # Check Bessel functions
set(CMAKE_REQUIRED_INCLUDES math.h) set(CMAKE_REQUIRED_INCLUDES math.h)
set(CMAKE_REQUIRED_LIBRARIES m) set(CMAKE_REQUIRED_LIBRARIES m)
CHECK_FUNCTION_EXISTS(j0 PIP_MATH_J0) CHECK_FUNCTION_EXISTS(j0 PIP_MATH_J0)
CHECK_FUNCTION_EXISTS(j1 PIP_MATH_J1) CHECK_FUNCTION_EXISTS(j1 PIP_MATH_J1)
CHECK_FUNCTION_EXISTS(jn PIP_MATH_JN) CHECK_FUNCTION_EXISTS(jn PIP_MATH_JN)
CHECK_FUNCTION_EXISTS(y0 PIP_MATH_Y0) CHECK_FUNCTION_EXISTS(y0 PIP_MATH_Y0)
CHECK_FUNCTION_EXISTS(y1 PIP_MATH_Y1) CHECK_FUNCTION_EXISTS(y1 PIP_MATH_Y1)
CHECK_FUNCTION_EXISTS(yn PIP_MATH_YN) CHECK_FUNCTION_EXISTS(yn PIP_MATH_YN)
if(PIP_MATH_J0) if(PIP_MATH_J0)
add_definitions(-DPIP_MATH_J0) add_definitions(-DPIP_MATH_J0)
endif() endif()
if(PIP_MATH_J1) if(PIP_MATH_J1)
add_definitions(-DPIP_MATH_J1) add_definitions(-DPIP_MATH_J1)
endif() endif()
if(PIP_MATH_JN) if(PIP_MATH_JN)
add_definitions(-DPIP_MATH_JN) add_definitions(-DPIP_MATH_JN)
endif() endif()
if(PIP_MATH_Y0) if(PIP_MATH_Y0)
add_definitions(-DPIP_MATH_Y0) add_definitions(-DPIP_MATH_Y0)
endif() endif()
if(PIP_MATH_Y1) if(PIP_MATH_Y1)
add_definitions(-DPIP_MATH_Y1) add_definitions(-DPIP_MATH_Y1)
endif() endif()
if(PIP_MATH_YN) if(PIP_MATH_YN)
add_definitions(-DPIP_MATH_YN) add_definitions(-DPIP_MATH_YN)
endif() endif()
# Check if RT timers exists # Check if RT timers exists
set(CMAKE_REQUIRED_INCLUDES time.h) set(CMAKE_REQUIRED_INCLUDES time.h)
set(CMAKE_REQUIRED_LIBRARIES ) set(CMAKE_REQUIRED_LIBRARIES )
if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT PIP_FREERTOS)) if((NOT DEFINED ENV{QNX_HOST}) AND (NOT APPLE) AND (NOT WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT PIP_FREERTOS))
list(APPEND LIBS_MAIN rt) list(APPEND LIBS_MAIN rt)
set(CMAKE_REQUIRED_LIBRARIES rt) set(CMAKE_REQUIRED_LIBRARIES rt)
endif() endif()
CHECK_FUNCTION_EXISTS(timer_create PIP_TIMER_RT_0) CHECK_FUNCTION_EXISTS(timer_create PIP_TIMER_RT_0)
CHECK_FUNCTION_EXISTS(timer_settime PIP_TIMER_RT_1) CHECK_FUNCTION_EXISTS(timer_settime PIP_TIMER_RT_1)
CHECK_FUNCTION_EXISTS(timer_delete PIP_TIMER_RT_2) CHECK_FUNCTION_EXISTS(timer_delete PIP_TIMER_RT_2)
# Check if build debug version # Check if build debug version
if (CMAKE_BUILD_TYPE MATCHES Debug) if (CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall")
add_definitions(-DPIP_DEBUG) add_definitions(-DPIP_DEBUG)
message(STATUS "Building PIP debug version") message(STATUS "Building PIP debug version")
else() else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
message(STATUS "Building PIP release version") message(STATUS "Building PIP release version")
endif() endif()
if (TESTS) if (TESTS)
include(DownloadGTest) include(DownloadGTest)
set(CONCURRENT_TESTS 1) #"Enable tests for concurrent library" set(CONCURRENT_TESTS 1) #"Enable tests for concurrent library"
else() else()
set(CONCURRENT_TESTS 0) set(CONCURRENT_TESTS 0)
endif() endif()
# Check if std::iostream operators support # Check if std::iostream operators support
if(STD_IOSTREAM) if(STD_IOSTREAM)
add_definitions(-DPIP_STD_IOSTREAM) add_definitions(-DPIP_STD_IOSTREAM)
message(STATUS "Building PIP with std iostream operators support") message(STATUS "Building PIP with std iostream operators support")
else() else()
message(STATUS "Building PIP without std iostream operators support") message(STATUS "Building PIP without std iostream operators support")
endif() endif()
# Check if ICU used for PIString and PIChar # Check if ICU used for PIString and PIChar
if(ICU) if(ICU)
message(STATUS "Building PIP with ICU") message(STATUS "Building PIP with ICU")
add_definitions(-DPIP_ICU) add_definitions(-DPIP_ICU)
list(APPEND LIBS_MAIN icuuc) list(APPEND LIBS_MAIN icuuc)
else() else()
message(STATUS "Building PIP without ICU") message(STATUS "Building PIP without ICU")
endif() endif()
# Check if PIP should be built with introspection # Check if PIP should be built with introspection
set(_PIP_DEFS "") set(_PIP_DEFS "")
set(_PIP_DEFS_FILE "${CMAKE_CURRENT_BINARY_DIR}/pip_defs.h") set(_PIP_DEFS_FILE "${CMAKE_CURRENT_BINARY_DIR}/pip_defs.h")
if(INTROSPECTION) if(INTROSPECTION)
message(STATUS "Building PIP with introspection") message(STATUS "Building PIP with introspection")
message(STATUS "Warning: Introspection reduces the performance!") message(STATUS "Warning: Introspection reduces the performance!")
add_definitions(-DPIP_INTROSPECTION) add_definitions(-DPIP_INTROSPECTION)
set(_PIP_DEFS "PIP_INTROSPECTION") set(_PIP_DEFS "PIP_INTROSPECTION")
else() else()
message(STATUS "Building PIP without introspection") message(STATUS "Building PIP without introspection")
endif() endif()
if ((NOT DEFINED _PIP_SAVED_DEFS) OR (NOT "x${_PIP_SAVED_DEFS}" STREQUAL "x${_PIP_DEFS}")) if ((NOT DEFINED _PIP_SAVED_DEFS) OR (NOT "x${_PIP_SAVED_DEFS}" STREQUAL "x${_PIP_DEFS}"))
set(_PIP_SAVED_DEFS "${_PIP_DEFS}" CACHE STRING "pip_defs" FORCE) set(_PIP_SAVED_DEFS "${_PIP_DEFS}" CACHE STRING "pip_defs" FORCE)
file(WRITE ${_PIP_DEFS_FILE} "// This file was generated by PIP CMake, don`t edit it!\n") file(WRITE ${_PIP_DEFS_FILE} "// This file was generated by PIP CMake, don`t edit it!\n")
if (NOT "x${_PIP_DEFS}" STREQUAL "x") if (NOT "x${_PIP_DEFS}" STREQUAL "x")
file(APPEND ${_PIP_DEFS_FILE} "#ifndef ${_PIP_DEFS}\n# define ${_PIP_DEFS}\n#endif\n") file(APPEND ${_PIP_DEFS_FILE} "#ifndef ${_PIP_DEFS}\n# define ${_PIP_DEFS}\n#endif\n")
endif() endif()
endif() endif()
list(APPEND HDRS ${_PIP_DEFS_FILE}) list(APPEND HDRS ${_PIP_DEFS_FILE})
#message("${_PIP_DEFS_CHANGED}") #message("${_PIP_DEFS_CHANGED}")
# Check if RT timers exists # Check if RT timers exists
if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2) if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2)
add_definitions(-DPIP_TIMER_RT) add_definitions(-DPIP_TIMER_RT)
message(STATUS "Building PIP with timers: Thread, ThreadRT, Pool") message(STATUS "Building PIP with timers: Thread, ThreadRT, Pool")
else() else()
message(STATUS "Building PIP with timers: Thread, Pool") message(STATUS "Building PIP with timers: Thread, Pool")
endif() endif()
# Add main library # Add main library
if(APPLE) if(APPLE)
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE) add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
endif() endif()
if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM)) if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM))
include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include) include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include)
#message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include") #message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include")
#message("${ANDROID_NDK}/sysroot/usr/include") #message("${ANDROID_NDK}/sysroot/usr/include")
endif() endif()
if(NOT PIP_FREERTOS) if(NOT PIP_FREERTOS)
if(WIN32) if(WIN32)
if(${C_COMPILER} STREQUAL "cl.exe") if(${C_COMPILER} STREQUAL "cl.exe")
else() else()
list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi cfgmgr32 setupapi) list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi cfgmgr32 setupapi)
endif() endif()
else() else()
list(APPEND LIBS_MAIN dl) list(APPEND LIBS_MAIN dl)
if(DEFINED ENV{QNX_HOST}) if(DEFINED ENV{QNX_HOST})
list(APPEND LIBS_MAIN socket) list(APPEND LIBS_MAIN socket)
else() else()
if (NOT DEFINED ANDROID_PLATFORM) if (NOT DEFINED ANDROID_PLATFORM)
list(APPEND LIBS_MAIN pthread util) list(APPEND LIBS_MAIN pthread util)
endif() endif()
endif() endif()
endif() endif()
endif() endif()
set(PIP_LIBS) set(PIP_LIBS)
if(PIP_FREERTOS) if(PIP_FREERTOS)
set(PIP_LIBS ${LIBS_MAIN}) set(PIP_LIBS ${LIBS_MAIN})
else() else()
foreach(LIB_ ${LIBS_MAIN}) foreach(LIB_ ${LIBS_MAIN})
find_library(${LIB_}_FOUND ${LIB_}) find_library(${LIB_}_FOUND ${LIB_})
if(${LIB_}_FOUND) if(${LIB_}_FOUND)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${${LIB_}_FOUND}) list(APPEND CMAKE_REQUIRED_LIBRARIES ${${LIB_}_FOUND})
list(APPEND PIP_LIBS ${${LIB_}_FOUND}) list(APPEND PIP_LIBS ${${LIB_}_FOUND})
endif() endif()
endforeach() endforeach()
endif() endif()
list(APPEND LIBS_STATUS ${LIBS_MAIN}) list(APPEND LIBS_STATUS ${LIBS_MAIN})
import_version(pip PIP) import_version(pip PIP)
if(WIN32) if(WIN32)
make_rc(pip _RC) make_rc(pip _RC)
add_definitions(-DPSAPI_VERSION=1) add_definitions(-DPSAPI_VERSION=1)
add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN} ${HDRS} ${PHDRS} ${_RC}) add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN} ${HDRS} ${PHDRS} ${_RC})
if(${C_COMPILER} STREQUAL "cl.exe") if(${C_COMPILER} STREQUAL "cl.exe")
set(CMAKE_CXX_FLAGS "/O2 /Ob2 /Ot /W0") set(CMAKE_CXX_FLAGS "/O2 /Ob2 /Ot /W0")
endif() endif()
else() else()
set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -fPIC") set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -fPIC")
if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS) if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
else() else()
endif() endif()
add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN}) add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN})
endif() endif()
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
include(GenerateExportHeader) include(GenerateExportHeader)
generate_export_header(pip) generate_export_header(pip)
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
target_link_libraries(pip ${PIP_LIBS}) target_link_libraries(pip ${PIP_LIBS})
if (NOT CROSSTOOLS) if (NOT CROSSTOOLS)
if (NOT PIP_FREERTOS) if (NOT PIP_FREERTOS)
# Check if USB is supported # Check if USB is supported
find_library(usb_FOUND usb SHARED) find_library(usb_FOUND usb SHARED)
if(usb_FOUND) if(usb_FOUND)
message(STATUS "Building PIP with USB support") message(STATUS "Building PIP with USB support")
import_version(pip_usb pip) import_version(pip_usb pip)
set_deploy_property(pip_usb ${PIP_LIB_TYPE} set_deploy_property(pip_usb ${PIP_LIB_TYPE}
LABEL "PIP usb support" LABEL "PIP usb support"
FULLNAME "${_PIP_DOMAIN}.pip_usb" FULLNAME "${_PIP_DOMAIN}.pip_usb"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(pip_usb _RC) make_rc(pip_usb _RC)
add_definitions(-DPIP_USB) add_definitions(-DPIP_USB)
add_library(pip_usb ${PIP_LIB_TYPE} ${CPP_LIB_USB} ${_RC}) add_library(pip_usb ${PIP_LIB_TYPE} ${CPP_LIB_USB} ${_RC})
target_link_libraries(pip_usb pip ${usb_FOUND}) target_link_libraries(pip_usb pip ${usb_FOUND})
list(APPEND LIBS_STATUS usb) list(APPEND LIBS_STATUS usb)
list(APPEND PIP_LIBS_TARGETS pip_usb) list(APPEND PIP_LIBS_TARGETS pip_usb)
else() else()
message(STATUS "Building PIP without USB support") message(STATUS "Building PIP without USB support")
endif() endif()
# Add console library # Add console library
import_version(pip_console pip) import_version(pip_console pip)
set_deploy_property(pip_console ${PIP_LIB_TYPE} set_deploy_property(pip_console ${PIP_LIB_TYPE}
LABEL "PIP console support" LABEL "PIP console support"
FULLNAME "${_PIP_DOMAIN}.pip_console" FULLNAME "${_PIP_DOMAIN}.pip_console"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(pip_console _RC) make_rc(pip_console _RC)
add_library(pip_console ${PIP_LIB_TYPE} ${CPP_LIB_CONSOLE} ${_RC}) add_library(pip_console ${PIP_LIB_TYPE} ${CPP_LIB_CONSOLE} ${_RC})
target_link_libraries(pip_console pip) target_link_libraries(pip_console pip)
list(APPEND PIP_LIBS_TARGETS pip_console) list(APPEND PIP_LIBS_TARGETS pip_console)
# Check if PIP support cryptographic encryption/decryption using sodium library # Check if PIP support cryptographic encryption/decryption using sodium library
find_library(sodium_FOUND sodium) find_library(sodium_FOUND sodium)
if(sodium_FOUND) if(sodium_FOUND)
message(STATUS "Building PIP with crypt support") message(STATUS "Building PIP with crypt support")
import_version(pip_crypt pip) import_version(pip_crypt pip)
set_deploy_property(pip_crypt ${PIP_LIB_TYPE} set_deploy_property(pip_crypt ${PIP_LIB_TYPE}
LABEL "PIP crypt support" LABEL "PIP crypt support"
FULLNAME "${_PIP_DOMAIN}.pip_crypt" FULLNAME "${_PIP_DOMAIN}.pip_crypt"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(pip_crypt _RC) make_rc(pip_crypt _RC)
add_definitions(-DPIP_CRYPT) add_definitions(-DPIP_CRYPT)
add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT} ${_RC}) add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT} ${_RC})
target_link_libraries(pip_crypt pip ${sodium_FOUND}) target_link_libraries(pip_crypt pip ${sodium_FOUND})
list(APPEND LIBS_STATUS sodium) list(APPEND LIBS_STATUS sodium)
list(APPEND PIP_LIBS_TARGETS pip_crypt) list(APPEND PIP_LIBS_TARGETS pip_crypt)
else() else()
message(STATUS "Building PIP without crypt support") message(STATUS "Building PIP without crypt support")
endif() endif()
# Check if PIP support compress/decompress using zlib library # Check if PIP support compress/decompress using zlib library
find_library(zlib_FOUND NAMES z zlib) find_library(zlib_FOUND NAMES z zlib)
if(zlib_FOUND) if(zlib_FOUND)
message(STATUS "Building PIP with zlib compress support") message(STATUS "Building PIP with zlib compress support")
import_version(pip_compress pip) import_version(pip_compress pip)
set_deploy_property(pip_compress ${PIP_LIB_TYPE} set_deploy_property(pip_compress ${PIP_LIB_TYPE}
LABEL "PIP compression support" LABEL "PIP compression support"
FULLNAME "${_PIP_DOMAIN}.pip_compress" FULLNAME "${_PIP_DOMAIN}.pip_compress"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(pip_compress _RC) make_rc(pip_compress _RC)
add_definitions(-DPIP_COMPRESS) add_definitions(-DPIP_COMPRESS)
add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS} ${_RC}) add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS} ${_RC})
target_link_libraries(pip_compress pip ${zlib_FOUND}) target_link_libraries(pip_compress pip ${zlib_FOUND})
list(APPEND LIBS_STATUS zlib) list(APPEND LIBS_STATUS zlib)
list(APPEND PIP_LIBS_TARGETS pip_compress) list(APPEND PIP_LIBS_TARGETS pip_compress)
else() else()
message(STATUS "Building PIP without compress support") message(STATUS "Building PIP without compress support")
endif() endif()
# Check if PIP support fftw3 for PIFFT using in math module # Check if PIP support fftw3 for PIFFT using in math module
set(FFTW_LIB_NAME fftw3) set(FFTW_LIB_NAME fftw3)
set(FFTW_LIB_SUFFIXES "" "f" "l" "q") set(FFTW_LIB_SUFFIXES "" "f" "l" "q")
set(FFTW_LIB_SUFFIXES2 "" "-3") set(FFTW_LIB_SUFFIXES2 "" "-3")
set(FFTW_LIBS) set(FFTW_LIBS)
set(FFTW_ABS_LIBS) set(FFTW_ABS_LIBS)
set(PIP_FFTW_FOUND) set(PIP_FFTW_FOUND)
set(CMAKE_REQUIRED_INCLUDES fftw3.h) set(CMAKE_REQUIRED_INCLUDES fftw3.h)
foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES) foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES)
set(FFTW_BREAK false) set(FFTW_BREAK false)
foreach(FFTW_S2_ IN LISTS FFTW_LIB_SUFFIXES2) foreach(FFTW_S2_ IN LISTS FFTW_LIB_SUFFIXES2)
if(NOT FFTW_BREAK) if(NOT FFTW_BREAK)
set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}") set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}")
set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}") set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}")
find_library(${FFTW_CLN}_FOUND ${FFTW_CLN}) find_library(${FFTW_CLN}_FOUND ${FFTW_CLN})
find_library(${FFTW_CLNT}_FOUND ${FFTW_CLNT}) find_library(${FFTW_CLNT}_FOUND ${FFTW_CLNT})
if(${FFTW_CLN}_FOUND) if(${FFTW_CLN}_FOUND)
list(APPEND FFTW_LIBS "${FFTW_CLN}") list(APPEND FFTW_LIBS "${FFTW_CLN}")
list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_FOUND}") list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_FOUND}")
#message(STATUS "PIFFTW found ${FFTW_CLN} = ${${FFTW_CLN}_FOUND}") #message(STATUS "PIFFTW found ${FFTW_CLN} = ${${FFTW_CLN}_FOUND}")
set(${FFTW_CLN}_CTS "${FFTW_CLN}") set(${FFTW_CLN}_CTS "${FFTW_CLN}")
if(${FFTW_CLNT}_FOUND) if(${FFTW_CLNT}_FOUND)
list(APPEND FFTW_LIBS "${FFTW_CLNT}") list(APPEND FFTW_LIBS "${FFTW_CLNT}")
list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_FOUND}") list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_FOUND}")
list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}") list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}")
endif() endif()
set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS}) set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS})
CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE) CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE)
add_definitions(-DPIP_FFTW${FFTW_S_}) add_definitions(-DPIP_FFTW${FFTW_S_})
set(PIP_FFTW_FOUND true) set(PIP_FFTW_FOUND true)
if(${FFTW_CLN}_TSFE) if(${FFTW_CLN}_TSFE)
add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE) add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE)
else() else()
message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe") message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe")
endif() endif()
#message(STATUS "${FFTW_CLN} -> ${${FFTW_CLN}_TSFE}") #message(STATUS "${FFTW_CLN} -> ${${FFTW_CLN}_TSFE}")
endif() endif()
endif() endif()
endforeach() endforeach()
endforeach() endforeach()
if(FFTW_LIBS) if(FFTW_LIBS)
message(STATUS "Building PIP with fftw3 support: ${FFTW_LIBS}") message(STATUS "Building PIP with fftw3 support: ${FFTW_LIBS}")
import_version(pip_fftw pip) import_version(pip_fftw pip)
set_deploy_property(pip_fftw ${PIP_LIB_TYPE} set_deploy_property(pip_fftw ${PIP_LIB_TYPE}
LABEL "PIP FFTW support" LABEL "PIP FFTW support"
FULLNAME "${_PIP_DOMAIN}.pip_fftw" FULLNAME "${_PIP_DOMAIN}.pip_fftw"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(pip_fftw _RC) make_rc(pip_fftw _RC)
add_library(pip_fftw ${PIP_LIB_TYPE} ${CPP_LIB_FFTW} ${_RC}) add_library(pip_fftw ${PIP_LIB_TYPE} ${CPP_LIB_FFTW} ${_RC})
target_link_libraries(pip_fftw pip ${FFTW_ABS_LIBS}) target_link_libraries(pip_fftw pip ${FFTW_ABS_LIBS})
list(APPEND LIBS_STATUS ${FFTW_LIBS}) list(APPEND LIBS_STATUS ${FFTW_LIBS})
list(APPEND PIP_LIBS_TARGETS pip_fftw) list(APPEND PIP_LIBS_TARGETS pip_fftw)
else() else()
message(STATUS "Building PIP without fftw3 support") message(STATUS "Building PIP without fftw3 support")
endif() endif()
# Check if PIP support OpenCL # Check if PIP support OpenCL
find_package(OpenCL QUIET) find_package(OpenCL QUIET)
if(OpenCL_FOUND) if(OpenCL_FOUND)
message(STATUS "Building PIP with OpenCL support") message(STATUS "Building PIP with OpenCL support")
import_version(pip_opencl pip) import_version(pip_opencl pip)
set_deploy_property(pip_opencl ${PIP_LIB_TYPE} set_deploy_property(pip_opencl ${PIP_LIB_TYPE}
LABEL "PIP OpenCL support" LABEL "PIP OpenCL support"
FULLNAME "${_PIP_DOMAIN}.pip_opencl" FULLNAME "${_PIP_DOMAIN}.pip_opencl"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(pip_opencl _RC) make_rc(pip_opencl _RC)
if(APPLE) if(APPLE)
include_directories(${OpenCL_INCLUDE_DIRS}/Headers) include_directories(${OpenCL_INCLUDE_DIRS}/Headers)
else() else()
include_directories(${OpenCL_INCLUDE_DIRS}) include_directories(${OpenCL_INCLUDE_DIRS})
endif() endif()
add_definitions(-DPIP_OPENCL) add_definitions(-DPIP_OPENCL)
pip_resources(CL_RES "${PIP_SRC_OPENCL}/resources.conf") pip_resources(CL_RES "${PIP_SRC_OPENCL}/resources.conf")
add_library(pip_opencl ${PIP_LIB_TYPE} ${CPP_LIB_OPENCL} ${CL_RES} ${_RC}) add_library(pip_opencl ${PIP_LIB_TYPE} ${CPP_LIB_OPENCL} ${CL_RES} ${_RC})
add_dependencies(pip_opencl pip_rc) add_dependencies(pip_opencl pip_rc)
if(${CMAKE_VERSION} VERSION_LESS "3.7.0") if(${CMAKE_VERSION} VERSION_LESS "3.7.0")
target_link_libraries(pip_opencl pip OpenCL) target_link_libraries(pip_opencl pip OpenCL)
else() else()
target_link_libraries(pip_opencl pip OpenCL::OpenCL) target_link_libraries(pip_opencl pip OpenCL::OpenCL)
endif() endif()
list(APPEND LIBS_STATUS OpenCL) list(APPEND LIBS_STATUS OpenCL)
list(APPEND PIP_LIBS_TARGETS pip_opencl) list(APPEND PIP_LIBS_TARGETS pip_opencl)
set(OpenCL_FOUND ${OpenCL_LIBRARIES}) set(OpenCL_FOUND ${OpenCL_LIBRARIES})
else() else()
message(STATUS "Building PIP without OpenCL support") message(STATUS "Building PIP without OpenCL support")
endif() endif()
# Check if PIP IO Utils library supports crypt # Check if PIP IO Utils library supports crypt
set(IO_UTILS_LIBS pip) set(IO_UTILS_LIBS pip)
import_version(pip_io_utils pip) import_version(pip_io_utils pip)
set_deploy_property(pip_io_utils ${PIP_LIB_TYPE} set_deploy_property(pip_io_utils ${PIP_LIB_TYPE}
LABEL "PIP I/O utilites" LABEL "PIP I/O utilites"
FULLNAME "${_PIP_DOMAIN}.pip_io_utils" FULLNAME "${_PIP_DOMAIN}.pip_io_utils"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(pip_io_utils _RC) make_rc(pip_io_utils _RC)
add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS} ${_RC}) add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS} ${_RC})
if(sodium_FOUND) if(sodium_FOUND)
message(STATUS "Building PIP IO Utils library with crypt support") message(STATUS "Building PIP IO Utils library with crypt support")
list(APPEND IO_UTILS_LIBS pip_crypt) list(APPEND IO_UTILS_LIBS pip_crypt)
else() else()
message(STATUS "Building PIP IO Utils library without crypt support, attention!") message(STATUS "Building PIP IO Utils library without crypt support, attention!")
endif() endif()
target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
list(APPEND PIP_LIBS_TARGETS pip_io_utils) list(APPEND PIP_LIBS_TARGETS pip_io_utils)
# Concurrent module # Concurrent module
set(CONCURRENT_LIBS pip) set(CONCURRENT_LIBS pip)
import_version(pip_concurrent pip) import_version(pip_concurrent pip)
set_deploy_property(pip_concurrent ${PIP_LIB_TYPE} set_deploy_property(pip_concurrent ${PIP_LIB_TYPE}
LABEL "PIP concurrent support" LABEL "PIP concurrent support"
FULLNAME "${_PIP_DOMAIN}.pip_concurrent" FULLNAME "${_PIP_DOMAIN}.pip_concurrent"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(pip_concurrent _RC) make_rc(pip_concurrent _RC)
add_library(pip_concurrent ${PIP_LIB_TYPE} ${CPP_LIB_CONCURRENT} ${_RC}) add_library(pip_concurrent ${PIP_LIB_TYPE} ${CPP_LIB_CONCURRENT} ${_RC})
target_link_libraries(pip_concurrent ${CONCURRENT_LIBS}) target_link_libraries(pip_concurrent ${CONCURRENT_LIBS})
set_property(TARGET pip_concurrent PROPERTY CXX_STANDARD 11) set_property(TARGET pip_concurrent PROPERTY CXX_STANDARD 11)
list(APPEND PIP_LIBS_TARGETS pip_concurrent) list(APPEND PIP_LIBS_TARGETS pip_concurrent)
# Enable build tests for concurrent module # Enable build tests for concurrent module
if(CONCURRENT_TESTS) if(CONCURRENT_TESTS)
add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST}) add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST})
target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent) target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent)
add_test(NAME pip_concurrent_test COMMAND tests) add_test(NAME pip_concurrent_test COMMAND tests)
add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test) add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test)
endif() endif()
# Build cloud library if crypt enabled # Build cloud library if crypt enabled
if(sodium_FOUND) if(sodium_FOUND)
message(STATUS "Building PICloud support") message(STATUS "Building PICloud support")
import_version(pip_cloud pip) import_version(pip_cloud pip)
set_deploy_property(pip_cloud ${PIP_LIB_TYPE} set_deploy_property(pip_cloud ${PIP_LIB_TYPE}
LABEL "PIP cloud transport support" LABEL "PIP cloud transport support"
FULLNAME "${_PIP_DOMAIN}.pip_cloud" FULLNAME "${_PIP_DOMAIN}.pip_cloud"
COMPANY "${_PIP_COMPANY}" COMPANY "${_PIP_COMPANY}"
INFO "Platform-Independent Primitives") INFO "Platform-Independent Primitives")
make_rc(pip_cloud _RC) make_rc(pip_cloud _RC)
add_definitions(-DPIP_CLOUD) add_definitions(-DPIP_CLOUD)
add_library(pip_cloud ${PIP_LIB_TYPE} ${CPP_LIB_CLOUD} ${_RC}) add_library(pip_cloud ${PIP_LIB_TYPE} ${CPP_LIB_CLOUD} ${_RC})
target_link_libraries(pip_cloud pip pip_crypt) target_link_libraries(pip_cloud pip pip_crypt)
list(APPEND PIP_LIBS_TARGETS pip_cloud) list(APPEND PIP_LIBS_TARGETS pip_cloud)
endif() endif()
# Test program # Test program
if(PIP_UTILS) if(PIP_UTILS)
add_executable(pip_test "main.cpp") add_executable(pip_test "main.cpp")
target_link_libraries(pip_test pip) target_link_libraries(pip_test pip)
endif() endif()
else() else()
message(STATUS "Building PIP with crypt support") message(STATUS "Building PIP with crypt support")
add_definitions(-DPIP_CRYPT) add_definitions(-DPIP_CRYPT)
add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT}) add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT})
target_link_libraries(pip_crypt pip) target_link_libraries(pip_crypt pip)
list(APPEND PIP_LIBS_TARGETS pip_crypt) list(APPEND PIP_LIBS_TARGETS pip_crypt)
set(IO_UTILS_LIBS pip) set(IO_UTILS_LIBS pip)
add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS}) add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS})
message(STATUS "Building PIP IO Utils library with crypt support") message(STATUS "Building PIP IO Utils library with crypt support")
list(APPEND IO_UTILS_LIBS pip_crypt) list(APPEND IO_UTILS_LIBS pip_crypt)
target_link_libraries(pip_io_utils ${IO_UTILS_LIBS}) target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
list(APPEND PIP_LIBS_TARGETS pip_io_utils) list(APPEND PIP_LIBS_TARGETS pip_io_utils)
message(STATUS "Building PIP with zlib compress support") message(STATUS "Building PIP with zlib compress support")
add_definitions(-DPIP_COMPRESS) add_definitions(-DPIP_COMPRESS)
add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS}) add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS})
target_link_libraries(pip_compress pip) target_link_libraries(pip_compress pip)
list(APPEND PIP_LIBS_TARGETS pip_compress) list(APPEND PIP_LIBS_TARGETS pip_compress)
endif() endif()
endif() endif()
# Install # Install
# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake) # Check if system or local install will be used (to system install use "-DLIB=" argument of cmake)
if(LIB) if(LIB)
if(WIN32) if(WIN32)
if(MINGW) if(MINGW)
if (NOT CROSSTOOLS) if (NOT CROSSTOOLS)
install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip) install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip)
install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION ${MINGW_LIB}) install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION ${MINGW_LIB})
endif() endif()
install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION ${MINGW_BIN}) install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION ${MINGW_BIN})
find_library(STDLIB "stdc++-6" PATHS ${MINGW_BIN} NO_DEFAULT_PATH) find_library(STDLIB "stdc++-6" PATHS ${MINGW_BIN} NO_DEFAULT_PATH)
find_library(STDLIB "stdc++-6") find_library(STDLIB "stdc++-6")
#message("${STDLIB}") #message("${STDLIB}")
if (STDLIB) if (STDLIB)
file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator") file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator")
file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler") file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler")
file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool") file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/deploy_tool")
endif() endif()
else() else()
#message("${CMAKE_CURRENT_BINARY_DIR}/pip_export.h") #message("${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pip_export.h DESTINATION include) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pip_export.h DESTINATION include)
endif() endif()
else() else()
if (NOT CROSSTOOLS) if (NOT CROSSTOOLS)
install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip) install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip)
endif() endif()
install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif() endif()
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"") message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore") file(GLOB CMAKES "cmake/*.cmake" "cmake/*.in" "cmake/android_debug.keystore")
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules) install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
else() else()
if(NOT PIP_FREERTOS) if(NOT PIP_FREERTOS)
if(WIN32) if(WIN32)
install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION bin) install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION bin)
install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION lib) install(TARGETS ${PIP_LIBS_TARGETS} ARCHIVE DESTINATION lib)
else() else()
install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION lib) install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION lib)
endif() endif()
install(FILES ${HDRS} DESTINATION include/pip) install(FILES ${HDRS} DESTINATION include/pip)
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"") message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
endif() endif()
endif() endif()
if(NOT PIP_FREERTOS) if(NOT PIP_FREERTOS)
# Auxiliary # Auxiliary
if (NOT CROSSTOOLS) if (NOT CROSSTOOLS)
add_subdirectory("${PIP_SRC_MAIN}/auxiliary/piterminal") add_subdirectory("${PIP_SRC_MAIN}/auxiliary/piterminal")
endif() endif()
# Utils # Utils
add_subdirectory("utils/code_model_generator") add_subdirectory("utils/code_model_generator")
add_subdirectory("utils/resources_compiler") add_subdirectory("utils/resources_compiler")
add_subdirectory("utils/deploy_tool") add_subdirectory("utils/deploy_tool")
if(PIP_UTILS AND (NOT CROSSTOOLS)) if(PIP_UTILS AND (NOT CROSSTOOLS))
add_subdirectory("utils/system_test") add_subdirectory("utils/system_test")
add_subdirectory("utils/remote_console") add_subdirectory("utils/remote_console")
add_subdirectory("utils/udp_file_transfer") add_subdirectory("utils/udp_file_transfer")
if(sodium_FOUND) if(sodium_FOUND)
add_subdirectory("utils/system_daemon") add_subdirectory("utils/system_daemon")
add_subdirectory("utils/crypt_tool") add_subdirectory("utils/crypt_tool")
add_subdirectory("utils/cloud_dispatcher") add_subdirectory("utils/cloud_dispatcher")
endif() endif()
endif() endif()
endif() endif()
# Libraries messages # Libraries messages
message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}") message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}")
if(DEFINED LIBPROJECT) if(DEFINED LIBPROJECT)
set(PIP_LIBS_TARGETS ${PIP_LIBS_TARGETS} PARENT_SCOPE) set(PIP_LIBS_TARGETS ${PIP_LIBS_TARGETS} PARENT_SCOPE)
list(APPEND _ALL_TARGETS ${PIP_LIBS_TARGETS}) list(APPEND _ALL_TARGETS ${PIP_LIBS_TARGETS})
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE) set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
endif() endif()
if(NOT PIP_FREERTOS) if(NOT PIP_FREERTOS)
foreach(LIB_ ${LIBS_STATUS}) foreach(LIB_ ${LIBS_STATUS})
message(STATUS "Library ${LIB_} -> " ${${LIB_}_FOUND}) message(STATUS "Library ${LIB_} -> " ${${LIB_}_FOUND})
if(NOT ${LIB_}_FOUND) if(NOT ${LIB_}_FOUND)
message(WARNING "Library ${LIB_} not found, please install it") message(WARNING "Library ${LIB_} not found, please install it")
endif() endif()
endforeach() endforeach()
endif() endif()
# #
# Build Documentation # Build Documentation
# #
if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS)) if ((NOT PIP_FREERTOS) AND (NOT CROSSTOOLS))
include(PIPDocumentation) include(PIPDocumentation)
find_package(Doxygen) find_package(Doxygen)
if(DOXYGEN_FOUND) if(DOXYGEN_FOUND)
set(DOXY_PROJECT_NUMBER "${PIP_VERSION}") set(DOXY_PROJECT_NUMBER "${PIP_VERSION}")
set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"") set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${PIP_VERSION}\"")
set(DOXY_EXAMPLE_PATH "\"${PROJECT_SOURCE_DIR}/doc/examples\"") set(DOXY_EXAMPLE_PATH "\"${PROJECT_SOURCE_DIR}/doc/examples\"")
set(DOXY_IMAGE_PATH "\"${PROJECT_SOURCE_DIR}/doc/images\"") set(DOXY_IMAGE_PATH "\"${PROJECT_SOURCE_DIR}/doc/images\"")
if(DOXYGEN_DOT_EXECUTABLE) if(DOXYGEN_DOT_EXECUTABLE)
string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}") string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}")
set(DOXY_DOT_PATH "\"${_DOT_PATH}\"") set(DOXY_DOT_PATH "\"${_DOT_PATH}\"")
set(DOXY_MSCGEN_PATH "\"${_DOT_PATH}\"") set(DOXY_MSCGEN_PATH "\"${_DOT_PATH}\"")
set(DOXY_DIA_PATH "\"${_DOT_PATH}\"") set(DOXY_DIA_PATH "\"${_DOT_PATH}\"")
endif() endif()
set(DOXY_INPUT) set(DOXY_INPUT)
foreach(F ${PIP_SRC_DIRS}) foreach(F ${PIP_SRC_DIRS})
list(APPEND DOXY_INPUT "\"${PROJECT_SOURCE_DIR}/${F}\"") list(APPEND DOXY_INPUT "\"${PROJECT_SOURCE_DIR}/${F}\"")
endforeach(F) endforeach(F)
string(REPLACE ";" " " DOXY_INPUT "${DOXY_INPUT}") string(REPLACE ";" " " DOXY_INPUT "${DOXY_INPUT}")
string(REPLACE ";" " " DOXY_INCLUDE_PATH "${PIP_MAIN_FOLDERS}") string(REPLACE ";" " " DOXY_INCLUDE_PATH "${PIP_MAIN_FOLDERS}")
add_documentation(doc doc/Doxyfile.in) add_documentation(doc doc/Doxyfile.in)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION ../share/doc/pip COMPONENT doc EXCLUDE_FROM_ALL OPTIONAL) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION ../share/doc/pip COMPONENT doc EXCLUDE_FROM_ALL OPTIONAL)
endif() endif()
endif() endif()

View File

@@ -64,7 +64,7 @@ void PIThreadPoolExecutor::execute(const std::function<void()> &runnable) {
} }
volatile bool PIThreadPoolExecutor::isShutdown() const { bool PIThreadPoolExecutor::isShutdown() const {
return isShutdown_; return isShutdown_;
} }

View File

@@ -160,7 +160,7 @@ TEST_F(ConditionVariable, DISABLED_waitFor_is_block_before_timeout) {
} }
TEST_F(ConditionVariable, waitFor_is_unblock_when_timeout) { TEST_F(ConditionVariable, waitFor_is_unblock_when_timeout) {
volatile bool isUnblock = false; std::atomic_bool isUnblock(false);
createThread([&](){ createThread([&](){
m.lock(); m.lock();
variable->waitFor(m, WAIT_THREAD_TIME_MS); variable->waitFor(m, WAIT_THREAD_TIME_MS);

View File

@@ -2,6 +2,7 @@
#define AWRCANFLASHER_TESTUTIL_H #define AWRCANFLASHER_TESTUTIL_H
#include "pithread.h" #include "pithread.h"
#include <atomic>
/** /**
* Minimum wait thread start, switch context or another interthread communication action time. Increase it if tests * Minimum wait thread start, switch context or another interthread communication action time. Increase it if tests
@@ -16,10 +17,12 @@ PIOBJECT(TestUtil)
public: public:
double threadStartTime; double threadStartTime;
PIThread* thread = new PIThread(); PIThread* thread = new PIThread();
volatile bool isRunning = false; std::atomic_bool isRunning;
std::function<void()> adapterFunctionDefault; std::function<void()> adapterFunctionDefault;
bool createThread(const std::function<void()>& fun = nullptr, PIThread* thread_ = nullptr) { TestUtil() : isRunning(false) {}
bool createThread(const std::function<void()>& fun = nullptr, PIThread* thread_ = nullptr) {
std::function<void()> actualFun = fun == nullptr ? adapterFunctionDefault : fun; std::function<void()> actualFun = fun == nullptr ? adapterFunctionDefault : fun;
if (thread_ == nullptr) thread_ = thread; if (thread_ == nullptr) thread_ = thread;
thread_->startOnce([=](void*){ thread_->startOnce([=](void*){

View File

@@ -21,6 +21,7 @@
#define PIP_TESTS_EXECUTOR_H #define PIP_TESTS_EXECUTOR_H
#include "piblockingdequeue.h" #include "piblockingdequeue.h"
#include <atomic>
/** /**
* @brief Thread pools address two different problems: they usually provide improved performance when executing large * @brief Thread pools address two different problems: they usually provide improved performance when executing large
@@ -51,11 +52,11 @@ public:
*/ */
void shutdown(); void shutdown();
volatile bool isShutdown() const; bool isShutdown() const;
bool awaitTermination(int timeoutMs); bool awaitTermination(int timeoutMs);
private: private:
volatile bool isShutdown_; std::atomic_bool isShutdown_;
PIBlockingDequeue<std::function<void()> >* taskQueue; PIBlockingDequeue<std::function<void()> >* taskQueue;
PIVector<PIThread*> threadPool; PIVector<PIThread*> threadPool;
}; };