Files
pip/cmake/FindPIP.cmake
peri4 1c7fc39b6c version 4.0.0_alpha
in almost all methods removed timeouts in milliseconds, replaced to PISystemTime
PITimer rewrite, remove internal impl, now only thread implementation, API similar to PIThread
PITimer API no longer pass void*
PIPeer, PIConnection improved stability on reinit and exit
PISystemTime new methods
pisd now exit without hanging
2024-07-30 14:18:02 +03:00

149 lines
4.4 KiB
CMake

#[[
Create imported targets:
* PIP - main library
* PIP::USB
* PIP::Console
* PIP::Crypt
* PIP::Compress
* PIP::FFTW
* PIP::OpenCL
* PIP::IOUtils
* PIP::Cloud
* PIP::Lua
These targets include directories and depends on
main library
]]
cmake_policy(SET CMP0011 NEW) # don`t affect includer policies
include(SHSTKMacros)
shstk_set_find_dirs(PIP)
set(__libs "usb;crypt;console;fftw;compress;io_utils;opencl;cloud;lua")
if (BUILDING_PIP)
#set(_libs "pip;pip_usb;pip_console;pip_crypt;pip_fftw;pip_compress;pip_opencl;pip_io_utils;pip_cloud;pip_lua")
#set(_bins "pip_cmg;pip_rc;deploy_tool")
#get_target_property(_path pip BINARY_DIR)
#get_target_property(_path pip LIBRARY_OUTPUT_NAME)
#message("${_path}")
#set(PIP_LIBRARY "$<TARGET_FILE_DIR:pip>/$<TARGET_FILE_NAME:pip>" CACHE STRING "")
set(PIP_LIBRARY pip CACHE STRING "")
set(PIP_FOUND ON CACHE BOOL "")
else()
find_library(PIP_LIBRARY pip HINTS ${PIP_LIBDIR})
foreach (_l ${__libs})
find_library(PIP_LIBRARY_${_l} pip_${_l} HINTS ${PIP_LIBDIR})
endforeach()
endif()
if (BUILDING_PIP AND (NOT CMAKE_CROSSCOMPILING))
set(PIP_CMG "$<TARGET_FILE_DIR:pip_cmg>/$<TARGET_FILE_NAME:pip_cmg>" CACHE STRING "")
set(PIP_RC "$<TARGET_FILE_DIR:pip_rc>/$<TARGET_FILE_NAME:pip_rc>" CACHE STRING "")
set(PIP_DEPLOY_TOOL "$<TARGET_FILE_DIR:deploy_tool>/$<TARGET_FILE_NAME:deploy_tool>" CACHE STRING "")
else()
find_program(PIP_CMG pip_cmg${PIP_BINEXT} HINTS ${PIP_BINDIR} ${PIP_FIND_PROGRAM_ARG})
find_program(PIP_RC pip_rc${PIP_BINEXT} HINTS ${PIP_BINDIR} ${PIP_FIND_PROGRAM_ARG})
find_program(PIP_DEPLOY_TOOL deploy_tool${PIP_BINEXT} HINTS ${PIP_BINDIR} ${PIP_FIND_PROGRAM_ARG})
endif()
if (NOT PIP_LIBRARY)
if(PIP_FIND_REQUIRED)
message(FATAL_ERROR "Can`t find PIP library!")
endif()
return()
endif()
set(_PIP_LIBRARY_PATH_ "${PIP_LIBRARY}")
set(_PIP_ADD_LIBS_ "")
if (NOT BUILDING_PIP)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
find_library(DL_LIBRARY dl)
list(APPEND PIP_LIBRARY ${DL_LIBRARY})
if (NOT DEFINED ANDROID_PLATFORM)
find_library(PTHREAD_LIBRARY pthread)
find_library(UTIL_LIBRARY util)
set(_PIP_ADD_LIBS_ ${PTHREAD_LIBRARY} ${UTIL_LIBRARY})
list(APPEND PIP_LIBRARY ${_PIP_ADD_LIBS_})
endif()
endif()
endif()
if (NOT BUILDING_PIP)
shstk_find_header(PIP "pip_version.h" "${_PIP_LIBRARY_PATH_}")
set(PIP_INCLUDES "${PIP_INCLUDES}" CACHE STRING "")
endif()
if(PIP_FIND_VERSION VERSION_GREATER PIP_VERSION)
message(FATAL_ERROR "PIP version ${PIP_VERSION} is available, but ${PIP_FIND_VERSION} requested!")
endif()
set(__module_usb USB )
set(__module_console Console )
set(__module_crypt Crypt )
set(__module_fftw FFTW )
set(__module_compress Compress )
set(__module_opencl OpenCL )
set(__module_io_utils IOUtils )
set(__module_cloud Cloud )
set(__module_lua Lua )
foreach (_l ${__libs})
set( __inc_${_l} "")
set(__deps_${_l} "")
set(__libs_${_l} "")
endforeach()
set(__deps_io_utils "PIP::Crypt")
set(__deps_cloud "PIP::IOUtils")
if (BUILDING_PIP)
if (NOT SET_TARGETS_PIP)
set(SET_TARGETS_PIP ON CACHE BOOL "")
#message("create aliases")
if((NOT TARGET PIP) AND PIP_LIBRARY)
#message("alias PIP = pip")
add_library(PIP ALIAS pip)
endif()
foreach (_l ${__libs})
set(_m ${__module_${_l}})
if((NOT TARGET PIP::${_m}) AND TARGET pip_${_l})
#message("alias PIP::${_m} = pip_${_l}")
add_library(PIP::${_m} ALIAS pip_${_l})
endif()
endforeach()
endif()
else()
#message("create interfaces")
if((NOT TARGET PIP) AND PIP_LIBRARY)
add_library(PIP UNKNOWN IMPORTED)
set_target_properties(PIP PROPERTIES
IMPORTED_LOCATION "${_PIP_LIBRARY_PATH_}"
INTERFACE_INCLUDE_DIRECTORIES "${PIP_INCLUDES}"
INTERFACE_LINK_LIBRARIES "${_PIP_ADD_LIBS_}")
#message("imported PIP = ${PIP_LIBRARY}")
endif()
foreach (_l ${__libs})
set(_m ${__module_${_l}})
if((NOT TARGET PIP::${_m}) AND PIP_LIBRARY_${_l})
add_library(PIP::${_m} UNKNOWN IMPORTED)
set_target_properties(PIP::${_m} PROPERTIES
IMPORTED_LOCATION "${PIP_LIBRARY_${_l}}"
INTERFACE_INCLUDE_DIRECTORIES "${__inc_${_l}}"
INTERFACE_LINK_LIBRARIES "PIP;${__deps_${_l}};${__libs_${_l}}")
#message("imported PIP::${_m} = ${PIP_LIBRARY_${_l}} ${__deps_${_l}} ${__libs_${_l}} ${__inc_${_l}}")
endif()
endforeach()
endif()
set(PIP_FOUND ON CACHE BOOL "")
include(PIPMacros)