710 lines
23 KiB
CMake
710 lines
23 KiB
CMake
cmake_minimum_required(VERSION 3.0)
|
|
project(pip)
|
|
|
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
|
set(PIP_BUILD 1)
|
|
include(CheckFunctionExists)
|
|
include(PIPMacros.cmake)
|
|
|
|
set(_ICU_DEFAULT OFF)
|
|
if((NOT DEFINED WIN32) AND (NOT DEFINED ANDROID_PLATFORM) AND (NOT DEFINED APPLE))
|
|
set(_ICU_DEFAULT ON)
|
|
endif()
|
|
|
|
|
|
# Options
|
|
option(ICU "ICU support for convert codepages" ${_ICU_DEFAULT})
|
|
option(STD_IOSTREAM "Building with std iostream operators support" OFF)
|
|
option(INTROSPECTION "Build with introspection" OFF)
|
|
option(LIB "System install" ON)
|
|
option(STATIC_LIB OFF)
|
|
option(DEBUG "Build with -g3" OFF)
|
|
option(TESTS "Build tests and perform their before install step" OFF)
|
|
set(PIP_UTILS 1)
|
|
if(LIBPROJECT)
|
|
set(PIP_UTILS ${UTILS})
|
|
endif()
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
|
|
# Apple crosscompiling rpath patch
|
|
macro(apple_rpath_patch _T)
|
|
if (APPLE AND CMAKE_CROSSCOMPILING AND CMAKE_MACOSX_RPATH)
|
|
foreach(_RP ${CMAKE_INSTALL_RPATH})
|
|
add_custom_command(TARGET ${_T} POST_BUILD
|
|
COMMAND "${CMAKE_INSTALL_NAME_TOOL}"
|
|
"-add_rpath" "${_RP}"
|
|
"$<TARGET_FILE_DIR:${_T}>/$<TARGET_FILE_NAME:${_T}>"
|
|
COMMENT "Add to ${_T} rpath \"${_RP}\"")
|
|
endforeach()
|
|
endif()
|
|
endmacro()
|
|
|
|
|
|
# Basic
|
|
macro(gather_src DIR CPP H H_P)
|
|
set(CS)
|
|
set(HS)
|
|
set(PHS)
|
|
file(GLOB CS "${DIR}/*.cpp")
|
|
file(GLOB HS "${DIR}/*.h")
|
|
file(GLOB PHS "${DIR}/*_p.h")
|
|
list(REMOVE_ITEM HS "${PHS}")
|
|
list(APPEND ${CPP} ${CS})
|
|
list(APPEND ${H} ${HS})
|
|
list(APPEND ${H_P} ${PHS})
|
|
endmacro()
|
|
|
|
set(PIP_SRC_MAIN "src_main")
|
|
set(PIP_SRC_CRYPT "src_crypt")
|
|
set(PIP_SRC_COMPRESS "src_compress")
|
|
set(PIP_SRC_USB "src_usb")
|
|
set(PIP_SRC_FFTW "src_fftw")
|
|
set(PIP_SRC_OPENCL "src_opencl")
|
|
set(PIP_SRC_IO_UTILS "src_io_utils")
|
|
set(PIP_SRC_CONCURRENT "src_concurrent")
|
|
set(PIP_SRC_CLOUD "src_cloud")
|
|
set(PIP_SRC_DIRS "src_main" "src_crypt" "src_compress" "src_usb" "src_fftw" "src_opencl" "src_io_utils" "src_concurrent" "src_cloud")
|
|
set(PIP_LIBS_TARGETS pip)
|
|
set(LIBS_MAIN)
|
|
set(LIBS_STATUS)
|
|
|
|
if (TESTS)
|
|
set(PIP_SRC_CONCURRENT_TEST "src_concurrent/test")
|
|
endif()
|
|
|
|
if (DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
|
|
set(STATIC_LIB ON)
|
|
endif()
|
|
|
|
if(STATIC_LIB)
|
|
set(PIP_LIB_TYPE STATIC)
|
|
add_definitions(-DPIP_STATIC_DEFINE)
|
|
message(STATUS "Building PIP static library")
|
|
else()
|
|
set(PIP_LIB_TYPE SHARED)
|
|
message(STATUS "Building PIP shared library")
|
|
endif()
|
|
|
|
if(MINGW)
|
|
find_package(MinGW REQUIRED)
|
|
list(APPEND CMAKE_LIBRARY_PATH ${MINGW_LIB})
|
|
else()
|
|
if(APPLE)
|
|
if(NOT CMAKE_CROSSCOMPILING)
|
|
include_directories(/usr/local/include)
|
|
link_directories(/usr/local/lib)
|
|
endif()
|
|
set(CMAKE_INSTALL_RPATH "@executable_path/../Frameworks;@executable_path/lib;@loader_path/../lib")
|
|
set(CMAKE_MACOSX_RPATH 1)
|
|
else()
|
|
set(CMAKE_INSTALL_RPATH "\$ORIGIN/lib")
|
|
endif()
|
|
endif()
|
|
if(LIB)
|
|
if(WIN32)
|
|
if(MINGW)
|
|
set(CMAKE_INSTALL_PREFIX ${MINGW_DIR})
|
|
endif()
|
|
else()
|
|
if (DEFINED ANDROID_PLATFORM)
|
|
set(CMAKE_INSTALL_PREFIX ${ANDROID_SYSTEM_LIBRARY_PATH}/usr)
|
|
else()
|
|
if(CMAKE_CROSSCOMPILING)
|
|
set(CMAKE_INSTALL_PREFIX ${CMAKE_STAGING_PREFIX})
|
|
else()
|
|
set(CMAKE_INSTALL_PREFIX ${INSTALL_PREFIX}/usr/local)
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
|
|
if ("x${PIP_RC}" STREQUAL "x")
|
|
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")
|
|
endif()
|
|
|
|
|
|
# Version
|
|
macro(versionExtract _file _name _out _string)
|
|
file(STRINGS "${_file}" line REGEX "#define[ \t]+${_name}.*")
|
|
if (${_string})
|
|
string(REGEX MATCH "\".*\"" _str "${line}")
|
|
string(LENGTH ${_str} _sl)
|
|
math(EXPR _sl "${_sl}-2")
|
|
string(SUBSTRING "${_str}" 1 ${_sl} ${_out})
|
|
else()
|
|
string(REGEX MATCH "[0-9]+" ${_out} "${line}")
|
|
endif()
|
|
#message("found ${_name} = ${${_out}}")
|
|
endmacro()
|
|
set(SHARED_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libs/shared")
|
|
versionExtract("${PIP_SRC_MAIN}/piversion.h" "PIP_VERSION_MAJOR" VERSION_MAJOR 0)
|
|
versionExtract("${PIP_SRC_MAIN}/piversion.h" "PIP_VERSION_MINOR" VERSION_MINOR 0)
|
|
versionExtract("${PIP_SRC_MAIN}/piversion.h" "PIP_VERSION_REVISION" VERSION_REVISION 0)
|
|
versionExtract("${PIP_SRC_MAIN}/piversion.h" "PIP_VERSION_SUFFIX" VERSION_SUFFIX 1)
|
|
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION}")
|
|
set(SOVERSION ${VERSION})
|
|
set(_PIP_VERSION_CHANGED 0)
|
|
if ((NOT _PIP_FULL_VERSION) OR (NOT "x${_PIP_FULL_VERSION}" STREQUAL "x${VERSION}${VERSION_SUFFIX}"))
|
|
set(_PIP_VERSION_CHANGED 1)
|
|
set(_PIP_FULL_VERSION "${VERSION}${VERSION_SUFFIX}" CACHE STRING "pip_full_version" FORCE)
|
|
endif()
|
|
#message("${_PIP_VERSION_CHANGED}")
|
|
message(STATUS "Building PIP version ${_PIP_FULL_VERSION}")
|
|
if (_PIP_VERSION_CHANGED)
|
|
file(WRITE "${PIP_SRC_MAIN}/pip_version_str.h" "// This file was generated by PIP CMake, don`t edit it!\n#define __PIP_VERSION_STR__ \"${_PIP_FULL_VERSION}\"\n")
|
|
endif()
|
|
|
|
|
|
# Compiler
|
|
get_filename_component(C_COMPILER "${CMAKE_C_COMPILER}" NAME)
|
|
#link_directories(${CMAKE_CURRENT_BINARY_DIR})
|
|
#message("${C_COMPILER}")
|
|
|
|
|
|
# Sources
|
|
|
|
# Main lib
|
|
set(PIP_FOLDERS "." "core" "containers" "thread" "system" "io_devices" "io_utils" "console" "math" "code" "geo" "resources" "opencl" "crypt" "introspection" "concurrent" "cloud")
|
|
if(PIP_FREERTOS)
|
|
#list(REMOVE_ITEM PIP_FOLDERS "console")
|
|
#include_directories("${PIP_SRC_MAIN}/console")
|
|
endif()
|
|
include_directories("${PIP_SRC_MAIN}")
|
|
set(PIP_MAIN_FOLDERS)
|
|
foreach(F ${PIP_FOLDERS})
|
|
list(APPEND PIP_MAIN_FOLDERS "\"${PROJECT_SOURCE_DIR}/${PIP_SRC_MAIN}/${F}\"")
|
|
include_directories("${PIP_SRC_MAIN}/${F}")
|
|
gather_src("${PIP_SRC_MAIN}/${F}" CPP_LIB_MAIN HDRS PHDRS)
|
|
endforeach(F)
|
|
# Crypt lib
|
|
gather_src("${PIP_SRC_CRYPT}" CPP_LIB_CRYPT HDRS PHDRS)
|
|
|
|
# Compress lib
|
|
gather_src("${PIP_SRC_COMPRESS}" CPP_LIB_COMPRESS HDRS PHDRS)
|
|
|
|
# USB lib
|
|
gather_src("${PIP_SRC_USB}" CPP_LIB_USB HDRS PHDRS)
|
|
|
|
# FFTW lib
|
|
gather_src("${PIP_SRC_FFTW}" CPP_LIB_FFTW HDRS PHDRS)
|
|
|
|
# OpenCL lib
|
|
gather_src("${PIP_SRC_OPENCL}" CPP_LIB_OPENCL HDRS PHDRS)
|
|
|
|
# IO Utils lib
|
|
gather_src("${PIP_SRC_IO_UTILS}" CPP_LIB_IO_UTILS HDRS PHDRS)
|
|
|
|
# Concurrent lib
|
|
gather_src("${PIP_SRC_CONCURRENT}" CPP_LIB_CONCURRENT HDRS PHDRS)
|
|
|
|
gather_src("${PIP_SRC_CONCURRENT_TEST}" CPP_CONCURRENT_TEST HDRS PHDRS)
|
|
|
|
# Cloud lib
|
|
gather_src("${PIP_SRC_CLOUD}" CPP_LIB_CLOUD HDRS PHDRS)
|
|
|
|
if(PIP_FREERTOS)
|
|
add_definitions(-DPIP_FREERTOS)
|
|
set(ICU OFF)
|
|
set(LIB OFF)
|
|
endif()
|
|
|
|
# Check Bessel functions
|
|
set(CMAKE_REQUIRED_INCLUDES math.h)
|
|
set(CMAKE_REQUIRED_LIBRARIES m)
|
|
CHECK_FUNCTION_EXISTS(j0 PIP_MATH_J0)
|
|
CHECK_FUNCTION_EXISTS(j1 PIP_MATH_J1)
|
|
CHECK_FUNCTION_EXISTS(jn PIP_MATH_JN)
|
|
CHECK_FUNCTION_EXISTS(y0 PIP_MATH_Y0)
|
|
CHECK_FUNCTION_EXISTS(y1 PIP_MATH_Y1)
|
|
CHECK_FUNCTION_EXISTS(yn PIP_MATH_YN)
|
|
if(PIP_MATH_J0)
|
|
add_definitions(-DPIP_MATH_J0)
|
|
endif()
|
|
if(PIP_MATH_J1)
|
|
add_definitions(-DPIP_MATH_J1)
|
|
endif()
|
|
if(PIP_MATH_JN)
|
|
add_definitions(-DPIP_MATH_JN)
|
|
endif()
|
|
if(PIP_MATH_Y0)
|
|
add_definitions(-DPIP_MATH_Y0)
|
|
endif()
|
|
if(PIP_MATH_Y1)
|
|
add_definitions(-DPIP_MATH_Y1)
|
|
endif()
|
|
if(PIP_MATH_YN)
|
|
add_definitions(-DPIP_MATH_YN)
|
|
endif()
|
|
|
|
|
|
# Check if RT timers exists
|
|
set(CMAKE_REQUIRED_INCLUDES time.h)
|
|
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))
|
|
list(APPEND LIBS_MAIN rt)
|
|
set(CMAKE_REQUIRED_LIBRARIES rt)
|
|
endif()
|
|
CHECK_FUNCTION_EXISTS(timer_create PIP_TIMER_RT_0)
|
|
CHECK_FUNCTION_EXISTS(timer_settime PIP_TIMER_RT_1)
|
|
CHECK_FUNCTION_EXISTS(timer_delete PIP_TIMER_RT_2)
|
|
|
|
|
|
# Check if build debug version
|
|
if(DEBUG)
|
|
add_definitions(-DPIP_DEBUG)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
|
message(STATUS "Building PIP debug version")
|
|
else()
|
|
set(CMAKE_BUILD_TYPE "Release")
|
|
message(STATUS "Building PIP release version")
|
|
endif()
|
|
|
|
if (TESTS)
|
|
include(DownloadGTest.cmake)
|
|
set(CONCURRENT_TESTS 1) #"Enable tests for concurrent library"
|
|
else()
|
|
set(CONCURRENT_TESTS 0)
|
|
endif()
|
|
|
|
# Check if std::iostream operators support
|
|
if(STD_IOSTREAM)
|
|
add_definitions(-DPIP_STD_IOSTREAM)
|
|
message(STATUS "Building PIP with std iostream operators support")
|
|
else()
|
|
message(STATUS "Building PIP without std iostream operators support")
|
|
endif()
|
|
|
|
|
|
# Check if STL containers is on (to enable use "-DSTL=" argument of cmake)
|
|
if(STL)
|
|
message(STATUS "Building PIP with STL containers")
|
|
add_definitions(-DPIP_CONTAINERS_STL)
|
|
else()
|
|
message(STATUS "Building PIP with PIP containers")
|
|
endif()
|
|
|
|
|
|
# Check if ICU used for PIString and PIChar
|
|
if(ICU)
|
|
message(STATUS "Building PIP with ICU")
|
|
add_definitions(-DPIP_ICU)
|
|
list(APPEND LIBS_MAIN icuuc)
|
|
else()
|
|
message(STATUS "Building PIP without ICU")
|
|
endif()
|
|
|
|
|
|
# Check if PIP should be built with introspection
|
|
set(_PIP_DEFS "")
|
|
set(_PIP_DEFS_FILE "${CMAKE_CURRENT_BINARY_DIR}/pip_defs.h")
|
|
if(INTROSPECTION)
|
|
message(STATUS "Building PIP with introspection")
|
|
message(STATUS "Warning: Introspection reduces the performance!")
|
|
add_definitions(-DPIP_INTROSPECTION)
|
|
set(_PIP_DEFS "PIP_INTROSPECTION")
|
|
else()
|
|
message(STATUS "Building PIP without introspection")
|
|
endif()
|
|
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)
|
|
file(WRITE ${_PIP_DEFS_FILE} "// This file was generated by PIP CMake, don`t edit it!\n")
|
|
if (NOT "x${_PIP_DEFS}" STREQUAL "x")
|
|
file(APPEND ${_PIP_DEFS_FILE} "#ifndef ${_PIP_DEFS}\n# define ${_PIP_DEFS}\n#endif\n")
|
|
endif()
|
|
endif()
|
|
list(APPEND HDRS ${_PIP_DEFS_FILE})
|
|
#message("${_PIP_DEFS_CHANGED}")
|
|
|
|
|
|
# Check if RT timers exists
|
|
if(PIP_TIMER_RT_0 AND PIP_TIMER_RT_1 AND PIP_TIMER_RT_2)
|
|
add_definitions(-DPIP_TIMER_RT)
|
|
message(STATUS "Building PIP with timers: Thread, ThreadRT, Pool")
|
|
else()
|
|
message(STATUS "Building PIP with timers: Thread, Pool")
|
|
endif()
|
|
|
|
|
|
|
|
# Add main library
|
|
if(APPLE)
|
|
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE)
|
|
endif()
|
|
if ((NOT DEFINED LIBPROJECT) AND (DEFINED ANDROID_PLATFORM))
|
|
include_directories(${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include)
|
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I${ANDROID_NDK}/sysroot/usr/include")
|
|
#message("${ANDROID_SYSTEM_LIBRARY_PATH}/usr/include")
|
|
#message("${ANDROID_NDK}/sysroot/usr/include")
|
|
endif()
|
|
if(NOT PIP_FREERTOS)
|
|
if(WIN32)
|
|
if(${C_COMPILER} STREQUAL "cl.exe")
|
|
else()
|
|
list(APPEND LIBS_MAIN ws2_32 iphlpapi psapi)
|
|
endif()
|
|
else()
|
|
list(APPEND LIBS_MAIN dl)
|
|
if(DEFINED ENV{QNX_HOST})
|
|
list(APPEND LIBS_MAIN socket)
|
|
else()
|
|
if (NOT DEFINED ANDROID_PLATFORM)
|
|
list(APPEND LIBS_MAIN pthread util)
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endif()
|
|
set(PIP_LIBS)
|
|
if(PIP_FREERTOS)
|
|
set(PIP_LIBS ${LIBS_MAIN})
|
|
else()
|
|
foreach(LIB_ ${LIBS_MAIN})
|
|
find_library(${LIB_}_FOUND ${LIB_})
|
|
if(${LIB_}_FOUND)
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES ${${LIB_}_FOUND})
|
|
list(APPEND PIP_LIBS ${${LIB_}_FOUND})
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
list(APPEND LIBS_STATUS ${LIBS_MAIN})
|
|
if(WIN32)
|
|
list(APPEND CPP_LIB_MAIN "pip_resource_win.rc")
|
|
add_definitions(-DPSAPI_VERSION=1)
|
|
add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN} ${HDRS} ${PHDRS})
|
|
if(${C_COMPILER} STREQUAL "cl.exe")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /O2 /Ob2 /Ot /W0")
|
|
else()
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
|
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
|
endif()
|
|
else()
|
|
set(${CMAKE_CXX_FLAGS} "${CMAKE_CXX_FLAGS} -O3 -fPIC")
|
|
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
|
|
if(DEFINED ENV{QNX_HOST} OR PIP_FREERTOS)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth-32")
|
|
else()
|
|
endif()
|
|
add_library(pip ${PIP_LIB_TYPE} ${CPP_LIB_MAIN})
|
|
endif()
|
|
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
|
|
include(GenerateExportHeader)
|
|
generate_export_header(pip)
|
|
list(APPEND HDRS "${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
|
|
target_link_libraries(pip ${PIP_LIBS})
|
|
|
|
if (NOT PIP_FREERTOS)
|
|
# Check if USB is supported
|
|
find_library(usb_FOUND usb SHARED)
|
|
if(usb_FOUND)
|
|
message(STATUS "Building PIP with USB support")
|
|
add_definitions(-DPIP_USB)
|
|
add_library(pip_usb ${PIP_LIB_TYPE} ${CPP_LIB_USB})
|
|
target_link_libraries(pip_usb pip ${usb_FOUND})
|
|
list(APPEND LIBS_STATUS usb)
|
|
list(APPEND PIP_LIBS_TARGETS pip_usb)
|
|
else()
|
|
message(STATUS "Building PIP without USB support")
|
|
endif()
|
|
|
|
|
|
# Check if PIP support cryptographic encryption/decryption using sodium library
|
|
find_library(sodium_FOUND sodium)
|
|
if(sodium_FOUND)
|
|
message(STATUS "Building PIP with crypt support")
|
|
add_definitions(-DPIP_CRYPT)
|
|
add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT})
|
|
target_link_libraries(pip_crypt pip ${sodium_FOUND})
|
|
list(APPEND LIBS_STATUS sodium)
|
|
list(APPEND PIP_LIBS_TARGETS pip_crypt)
|
|
else()
|
|
message(STATUS "Building PIP without crypt support")
|
|
endif()
|
|
|
|
|
|
# Check if PIP support compress/decompress using zlib library
|
|
find_library(zlib_FOUND NAMES z zlib)
|
|
if(zlib_FOUND)
|
|
message(STATUS "Building PIP with zlib compress support")
|
|
add_definitions(-DPIP_COMPRESS)
|
|
add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS})
|
|
target_link_libraries(pip_compress pip ${zlib_FOUND})
|
|
list(APPEND LIBS_STATUS zlib)
|
|
list(APPEND PIP_LIBS_TARGETS pip_compress)
|
|
else()
|
|
message(STATUS "Building PIP without compress support")
|
|
endif()
|
|
|
|
|
|
# Check if PIP support fftw3 for PIFFT using in math module
|
|
set(FFTW_LIB_NAME fftw3)
|
|
set(FFTW_LIB_SUFFIXES "" "f" "l" "q")
|
|
set(FFTW_LIB_SUFFIXES2 "" "-3")
|
|
set(FFTW_LIBS)
|
|
set(FFTW_ABS_LIBS)
|
|
set(PIP_FFTW_FOUND)
|
|
set(CMAKE_REQUIRED_INCLUDES fftw3.h)
|
|
foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES)
|
|
set(FFTW_BREAK false)
|
|
foreach(FFTW_S2_ IN LISTS FFTW_LIB_SUFFIXES2)
|
|
if(NOT FFTW_BREAK)
|
|
set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}")
|
|
set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}")
|
|
find_library(${FFTW_CLN}_FOUND ${FFTW_CLN})
|
|
find_library(${FFTW_CLNT}_FOUND ${FFTW_CLNT})
|
|
if(${FFTW_CLN}_FOUND)
|
|
list(APPEND FFTW_LIBS "${FFTW_CLN}")
|
|
list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_FOUND}")
|
|
#message(STATUS "PIFFTW found ${FFTW_CLN} = ${${FFTW_CLN}_FOUND}")
|
|
set(${FFTW_CLN}_CTS "${FFTW_CLN}")
|
|
if(${FFTW_CLNT}_FOUND)
|
|
list(APPEND FFTW_LIBS "${FFTW_CLNT}")
|
|
list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_FOUND}")
|
|
list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}")
|
|
endif()
|
|
set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS})
|
|
CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE)
|
|
add_definitions(-DPIP_FFTW${FFTW_S_})
|
|
set(PIP_FFTW_FOUND true)
|
|
if(${FFTW_CLN}_TSFE)
|
|
add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE)
|
|
else()
|
|
message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe")
|
|
endif()
|
|
#message(STATUS "${FFTW_CLN} -> ${${FFTW_CLN}_TSFE}")
|
|
endif()
|
|
endif()
|
|
endforeach()
|
|
endforeach()
|
|
if(FFTW_LIBS)
|
|
message(STATUS "Building PIP with fftw3 support: ${FFTW_LIBS}")
|
|
add_library(pip_fftw ${PIP_LIB_TYPE} ${CPP_LIB_FFTW})
|
|
target_link_libraries(pip_fftw pip ${FFTW_ABS_LIBS})
|
|
list(APPEND LIBS_STATUS ${FFTW_LIBS})
|
|
list(APPEND PIP_LIBS_TARGETS pip_fftw)
|
|
else()
|
|
message(STATUS "Building PIP without fftw3 support")
|
|
endif()
|
|
|
|
|
|
# Check if PIP support OpenCL
|
|
find_package(OpenCL QUIET)
|
|
if(OpenCL_FOUND)
|
|
message(STATUS "Building PIP with OpenCL support")
|
|
if(APPLE)
|
|
include_directories(${OpenCL_INCLUDE_DIRS}/Headers)
|
|
else()
|
|
include_directories(${OpenCL_INCLUDE_DIRS})
|
|
endif()
|
|
add_definitions(-DPIP_OPENCL)
|
|
pip_resources(CL_RES "src_opencl/resources.conf")
|
|
add_library(pip_opencl ${PIP_LIB_TYPE} ${CPP_LIB_OPENCL} ${CL_RES})
|
|
add_dependencies(pip_opencl pip_rc)
|
|
if(${CMAKE_VERSION} VERSION_LESS "3.7.0")
|
|
target_link_libraries(pip_opencl pip OpenCL)
|
|
else()
|
|
target_link_libraries(pip_opencl pip OpenCL::OpenCL)
|
|
endif()
|
|
list(APPEND LIBS_STATUS OpenCL)
|
|
list(APPEND PIP_LIBS_TARGETS pip_opencl)
|
|
set(OpenCL_FOUND ${OpenCL_LIBRARIES})
|
|
else()
|
|
message(STATUS "Building PIP without OpenCL support")
|
|
endif()
|
|
|
|
|
|
# Check if PIP IO Utils library supports crypt
|
|
set(IO_UTILS_LIBS pip)
|
|
add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS})
|
|
if(sodium_FOUND)
|
|
message(STATUS "Building PIP IO Utils library with crypt support")
|
|
list(APPEND IO_UTILS_LIBS pip_crypt)
|
|
else()
|
|
message(STATUS "Building PIP IO Utils library without crypt support, attention!")
|
|
endif()
|
|
target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
|
|
list(APPEND PIP_LIBS_TARGETS pip_io_utils)
|
|
|
|
|
|
# Concurrent module
|
|
set(CONCURRENT_LIBS pip)
|
|
add_library(pip_concurrent ${PIP_LIB_TYPE} ${CPP_LIB_CONCURRENT})
|
|
target_link_libraries(pip_concurrent ${CONCURRENT_LIBS})
|
|
set_property(TARGET pip_concurrent PROPERTY CXX_STANDARD 11)
|
|
list(APPEND PIP_LIBS_TARGETS pip_concurrent)
|
|
|
|
# Enable build tests for concurrent module
|
|
if(CONCURRENT_TESTS)
|
|
add_executable(pip_concurrent_test ${CPP_CONCURRENT_TEST})
|
|
target_link_libraries(pip_concurrent_test gtest_main gmock_main pip_concurrent)
|
|
add_test(NAME pip_concurrent_test COMMAND tests)
|
|
add_custom_target(pip_concurrent_test_perform ALL COMMAND pip_concurrent_test)
|
|
endif()
|
|
|
|
|
|
# Build cloud library if crypt enabled
|
|
if(sodium_FOUND)
|
|
message(STATUS "Building PICloud support")
|
|
add_definitions(-DPIP_CLOUD)
|
|
add_library(pip_cloud ${PIP_LIB_TYPE} ${CPP_LIB_CLOUD})
|
|
target_link_libraries(pip_cloud pip pip_crypt)
|
|
list(APPEND PIP_LIBS_TARGETS pip_cloud)
|
|
endif()
|
|
|
|
|
|
# Test program
|
|
if(PIP_UTILS)
|
|
add_executable(pip_test "main.cpp")
|
|
target_link_libraries(pip_test pip)
|
|
endif()
|
|
|
|
else(NOT PIP_FREERTOS)
|
|
message(STATUS "Building PIP with crypt support")
|
|
add_definitions(-DPIP_CRYPT)
|
|
add_library(pip_crypt ${PIP_LIB_TYPE} ${CPP_LIB_CRYPT})
|
|
target_link_libraries(pip_crypt pip)
|
|
list(APPEND PIP_LIBS_TARGETS pip_crypt)
|
|
set(IO_UTILS_LIBS pip)
|
|
add_library(pip_io_utils ${PIP_LIB_TYPE} ${CPP_LIB_IO_UTILS})
|
|
message(STATUS "Building PIP IO Utils library with crypt support")
|
|
list(APPEND IO_UTILS_LIBS pip_crypt)
|
|
target_link_libraries(pip_io_utils ${IO_UTILS_LIBS})
|
|
list(APPEND PIP_LIBS_TARGETS pip_io_utils)
|
|
message(STATUS "Building PIP with zlib compress support")
|
|
add_definitions(-DPIP_COMPRESS)
|
|
add_library(pip_compress ${PIP_LIB_TYPE} ${CPP_LIB_COMPRESS})
|
|
target_link_libraries(pip_compress pip)
|
|
list(APPEND PIP_LIBS_TARGETS pip_compress)
|
|
endif(NOT PIP_FREERTOS)
|
|
|
|
# Install
|
|
# Check if system or local install will be used (to system install use "-DLIB=" argument of cmake)
|
|
if(LIB)
|
|
if(WIN32)
|
|
if(MINGW)
|
|
install(FILES ${HDRS} DESTINATION ${MINGW_INCLUDE}/pip)
|
|
install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${MINGW_LIB})
|
|
install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION ${MINGW_BIN})
|
|
find_library(STDLIB "stdc++-6")
|
|
#message("${STDLIB}")
|
|
if (STDLIB)
|
|
file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/code_model_generator")
|
|
file(COPY "${STDLIB}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/utils/resources_compiler")
|
|
endif()
|
|
else()
|
|
#message("${CMAKE_CURRENT_BINARY_DIR}/pip_export.h")
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pip_export.h DESTINATION include)
|
|
endif()
|
|
else()
|
|
install(FILES ${HDRS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/pip)
|
|
install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
|
|
endif()
|
|
message(STATUS "Install ${PROJECT_NAME} to system \"${CMAKE_INSTALL_PREFIX}\"")
|
|
# Precompiled header
|
|
#add_custom_target(pip_pch ALL COMMAND ${CMAKE_CXX_COMPILER} -O2 -fPIC -g3 ${CMAKE_INSTALL_PREFIX}/include/pip/pip.h DEPENDS pip SOURCES ${HDRS})
|
|
#list(APPEND HDRS "pip.h.gch")
|
|
file(GLOB CMAKES "*.cmake")
|
|
install(FILES ${CMAKES} DESTINATION ${CMAKE_ROOT}/Modules)
|
|
else()
|
|
if(NOT PIP_FREERTOS)
|
|
install(TARGETS ${PIP_LIBS_TARGETS} RUNTIME DESTINATION bin)
|
|
install(TARGETS ${PIP_LIBS_TARGETS} DESTINATION lib)
|
|
install(FILES ${HDRS} DESTINATION include/pip)
|
|
message(STATUS "Install ${PROJECT_NAME} to local \"bin\", \"lib\" and \"include\"")
|
|
endif()
|
|
endif()
|
|
|
|
foreach(_T ${PIP_LIBS_TARGETS})
|
|
apple_rpath_patch(${_T})
|
|
endforeach()
|
|
|
|
if(NOT PIP_FREERTOS)
|
|
|
|
# Auxiliary
|
|
add_subdirectory("${PIP_SRC_MAIN}/auxiliary/piterminal")
|
|
|
|
|
|
# Utils
|
|
add_subdirectory("utils/code_model_generator")
|
|
add_subdirectory("utils/resources_compiler")
|
|
if(PIP_UTILS)
|
|
add_subdirectory("utils/system_test")
|
|
add_subdirectory("utils/remote_console")
|
|
add_subdirectory("utils/udp_file_transfer")
|
|
if(sodium_FOUND)
|
|
add_subdirectory("utils/system_daemon")
|
|
add_subdirectory("utils/crypt_tool")
|
|
add_subdirectory("utils/cloud_dispatcher")
|
|
endif()
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
# Libraries messages
|
|
message(STATUS "Building PIP modules: ${PIP_LIBS_TARGETS}")
|
|
if(DEFINED LIBPROJECT)
|
|
set(PIP_LIBS_TARGETS ${PIP_LIBS_TARGETS} PARENT_SCOPE)
|
|
list(APPEND _ALL_TARGETS ${PIP_LIBS_TARGETS})
|
|
set(_ALL_TARGETS ${_ALL_TARGETS} PARENT_SCOPE)
|
|
endif()
|
|
if(NOT PIP_FREERTOS)
|
|
foreach(LIB_ ${LIBS_STATUS})
|
|
message(STATUS "Library ${LIB_} -> " ${${LIB_}_FOUND})
|
|
if(NOT ${LIB_}_FOUND)
|
|
message(WARNING "Library ${LIB_} not found, please install it")
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
#
|
|
# Build Documentation
|
|
#
|
|
|
|
# find_package(Doxygen QUIET)
|
|
# if(Doxygen_FOUND)
|
|
# message(STATUS "Building PIP with documentation via Doxygen")
|
|
|
|
# #set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in)
|
|
# set(DOXYFILE ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
|
|
# #configure_file(${DOXYFILE_IN} ${DOXYFILE} @ONLY)
|
|
|
|
# add_custom_target(DOC
|
|
# COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE}
|
|
# WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
# COMMENT "Generating API documentation with Doxygen"
|
|
# VERBATIM)
|
|
|
|
# add_custom_command(TARGET DOC
|
|
# POST_BUILD
|
|
# COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/source/doc/Documentation.html ${CMAKE_SOURCE_DIR}/doc
|
|
# )
|
|
# install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/doc)
|
|
# endif()
|
|
if (NOT PIP_FREERTOS)
|
|
include(PIPDocumentation.cmake)
|
|
find_package(Doxygen)
|
|
if(DOXYGEN_FOUND)
|
|
set(DOXY_PROJECT_NUMBER "${_PIP_FULL_VERSION}")
|
|
set(DOXY_QHP_CUST_FILTER_ATTRS "\"PIP ${_PIP_FULL_VERSION}\"")
|
|
set(DOXY_QHP_SECT_FILTER_ATTRS "\"PIP ${_PIP_FULL_VERSION}\"")
|
|
set(DOXY_EXAMPLE_PATH "\"${PROJECT_SOURCE_DIR}/doc/examples\"")
|
|
set(DOXY_IMAGE_PATH "\"${PROJECT_SOURCE_DIR}/doc/images\"")
|
|
if(DOXYGEN_DOT_EXECUTABLE)
|
|
string(REPLACE "\\" "" _DOT_PATH "${DOXYGEN_DOT_PATH}")
|
|
set(DOXY_DOT_PATH "\"${_DOT_PATH}\"")
|
|
set(DOXY_MSCGEN_PATH "\"${_DOT_PATH}\"")
|
|
set(DOXY_DIA_PATH "\"${_DOT_PATH}\"")
|
|
endif()
|
|
set(DOXY_INPUT)
|
|
foreach(F ${PIP_SRC_DIRS})
|
|
list(APPEND DOXY_INPUT "\"${PROJECT_SOURCE_DIR}/${F}\"")
|
|
endforeach(F)
|
|
string(REPLACE ";" " " DOXY_INPUT "${DOXY_INPUT}")
|
|
string(REPLACE ";" " " DOXY_INCLUDE_PATH "${PIP_MAIN_FOLDERS}")
|
|
add_documentation(doc Doxyfile.in)
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc/html DESTINATION ../share/doc/pip COMPONENT doc EXCLUDE_FROM_ALL OPTIONAL)
|
|
endif()
|
|
endif()
|
|
|