add PIP_BUILD_<MODULE> options for PIP build to force disabling modules

This commit is contained in:
2025-01-09 17:36:40 +03:00
parent f334a6603f
commit 7757ac10ec

View File

@@ -94,6 +94,8 @@ set(PIP_EXPORTS)
set(PIP_SRC_MODULES "console;crypt;compress;usb;fftw;opencl;io_utils;client_server;cloud;lua;http_client;http_server") set(PIP_SRC_MODULES "console;crypt;compress;usb;fftw;opencl;io_utils;client_server;cloud;lua;http_client;http_server")
foreach(_m ${PIP_SRC_MODULES}) foreach(_m ${PIP_SRC_MODULES})
set(PIP_MSG_${_m} "no") set(PIP_MSG_${_m} "no")
string(TOUPPER "${_m}" _mu)
option(PIP_BUILD_${_mu} "Build \"${_m}\" module" ON)
endforeach() endforeach()
macro(pip_module NAME LIBS LABEL INCLUDES SOURCES MSG) macro(pip_module NAME LIBS LABEL INCLUDES SOURCES MSG)
@@ -392,142 +394,163 @@ endif()
if (NOT CROSSTOOLS) if (NOT CROSSTOOLS)
if (NOT PIP_FREERTOS) if (NOT PIP_FREERTOS)
if (PIP_BUILD_CONSOLE)
pip_module(console "" "PIP console support" "" "" "")
endif()
pip_module(console "" "PIP console support" "" "" "") if (PIP_BUILD_USB)
pip_find_lib(usb)
if(usb_FOUND)
pip_find_lib(usb) pip_module(usb "usb" "PIP usb support" "" "" "")
if(usb_FOUND) endif()
pip_module(usb "usb" "PIP usb support" "" "" "")
endif() endif()
pip_find_lib(zlib NAMES z zlib) if (PIP_BUILD_COMPRESS)
if(zlib_FOUND) pip_find_lib(zlib NAMES z zlib)
pip_module(compress "zlib" "PIP compression support" "" "" "") if(zlib_FOUND)
pip_module(compress "zlib" "PIP compression support" "" "" "")
endif()
endif() endif()
pip_find_lib(sodium) if (PIP_BUILD_CRYPT)
if(sodium_FOUND) pip_find_lib(sodium)
pip_module(crypt "sodium" "PIP crypt support" "" "" "") if(sodium_FOUND)
pip_module(client_server "pip_io_utils" "PIP client-server helper" "" "" "") pip_module(crypt "sodium" "PIP crypt support" "" "" "")
pip_module(cloud "pip_io_utils" "PIP cloud support" "" "" "") pip_module(client_server "pip_io_utils" "PIP client-server helper" "" "" "")
pip_module(cloud "pip_io_utils" "PIP cloud support" "" "" "")
endif()
endif() endif()
# Check if PIP support fftw3 for PIFFT using in math module if (PIP_BUILD_FFTW)
set(FFTW_LIB_NAME fftw3) # Check if PIP support fftw3 for PIFFT using in math module
set(FFTW_LIB_SUFFIXES "" "f" "l" "q") set(FFTW_LIB_NAME fftw3)
set(FFTW_LIB_SUFFIXES2 "" "-3") set(FFTW_LIB_SUFFIXES "" "f" "l" "q")
set(FFTW_LIBS) set(FFTW_LIB_SUFFIXES2 "" "-3")
set(FFTW_ABS_LIBS) set(FFTW_LIBS)
set(CMAKE_REQUIRED_INCLUDES fftw3.h) set(FFTW_ABS_LIBS)
foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES) set(CMAKE_REQUIRED_INCLUDES fftw3.h)
set(FFTW_BREAK false) foreach(FFTW_S_ IN LISTS FFTW_LIB_SUFFIXES)
foreach(FFTW_S2_ IN LISTS FFTW_LIB_SUFFIXES2) set(FFTW_BREAK false)
if(NOT FFTW_BREAK) foreach(FFTW_S2_ IN LISTS FFTW_LIB_SUFFIXES2)
set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}") if(NOT FFTW_BREAK)
set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}") set(FFTW_CLN "${FFTW_LIB_NAME}${FFTW_S_}${FFTW_S2_}")
find_library(${FFTW_CLN}_LIBRARIES ${FFTW_CLN}) set(FFTW_CLNT "${FFTW_LIB_NAME}${FFTW_S_}_threads${FFTW_S2_}")
find_library(${FFTW_CLNT}_LIBRARIES ${FFTW_CLNT}) find_library(${FFTW_CLN}_LIBRARIES ${FFTW_CLN})
set(${FFTW_CLN}_FOUND FALSE) find_library(${FFTW_CLNT}_LIBRARIES ${FFTW_CLNT})
set(${FFTW_CLNT}_FOUND FALSE) set(${FFTW_CLN}_FOUND FALSE)
if(${FFTW_CLN}_LIBRARIES) set(${FFTW_CLNT}_FOUND FALSE)
set(${FFTW_CLN}_FOUND TRUE) if(${FFTW_CLN}_LIBRARIES)
list(APPEND FFTW_LIBS "${FFTW_CLN}") set(${FFTW_CLN}_FOUND TRUE)
list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_LIBRARIES}") list(APPEND FFTW_LIBS "${FFTW_CLN}")
set(${FFTW_CLN}_CTS "${FFTW_CLN}") list(APPEND FFTW_ABS_LIBS "${${FFTW_CLN}_LIBRARIES}")
if(${FFTW_CLNT}_FLIBRARIES) set(${FFTW_CLN}_CTS "${FFTW_CLN}")
set(${FFTW_CLNT}_FOUND TRUE) if(${FFTW_CLNT}_FLIBRARIES)
list(APPEND FFTW_LIBS "${FFTW_CLNT}") set(${FFTW_CLNT}_FOUND TRUE)
list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_LIBRARIES}") list(APPEND FFTW_LIBS "${FFTW_CLNT}")
list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}") list(APPEND FFTW_ABS_LIBS "${${FFTW_CLNT}_LIBRARIES}")
endif() list(APPEND ${FFTW_CLN}_CTS "${FFTW_CLNT}")
set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS}) endif()
CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE) set(CMAKE_REQUIRED_LIBRARIES ${${FFTW_CLN}_CTS})
add_definitions(-DPIP_FFTW${FFTW_S_}) CHECK_FUNCTION_EXISTS(fftw${FFTW_S_}_make_planner_thread_safe ${FFTW_CLN}_TSFE)
if(${FFTW_CLN}_TSFE) add_definitions(-DPIP_FFTW${FFTW_S_})
add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE) if(${FFTW_CLN}_TSFE)
else() add_definitions(-DPIP_FFTW${FFTW_S_}_THREADSAFE)
message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe") else()
message(STATUS "Warning: PIFFTW${FFTW_S_}::preparePlan was not threadsafe")
endif()
endif() endif()
endif() endif()
endif() endforeach()
endforeach() endforeach()
endforeach() if(FFTW_LIBS)
if(FFTW_LIBS) pip_module(fftw "${FFTW_LIBS}" "PIP FFTW support" "" "" "")
pip_module(fftw "${FFTW_LIBS}" "PIP FFTW support" "" "" "")
endif()
if (NOT "x${MINGW_INCLUDE}" STREQUAL "x")
list(APPEND CMAKE_INCLUDE_PATH "${MINGW_INCLUDE}")
endif()
find_package(OpenCL QUIET) #OpenCL_VERSION_STRING
if(OpenCL_FOUND)
set(_opencl_inc "${OpenCL_INCLUDE_DIRS}")
if(APPLE)
set(_opencl_inc "${OpenCL_INCLUDE_DIRS}/Headers")
endif() endif()
pip_module(opencl "OpenCL" "PIP OpenCL support" "${_opencl_inc}" "" " (${OpenCL_VERSION_STRING})")
endif() endif()
if(sodium_FOUND) if (PIP_BUILD_OPENCL)
pip_module(io_utils "pip_crypt" "PIP I/O support" "" "" " (+crypt)") if (NOT "x${MINGW_INCLUDE}" STREQUAL "x")
else() list(APPEND CMAKE_INCLUDE_PATH "${MINGW_INCLUDE}")
pip_module(io_utils "" "PIP I/O support" "" "" "") endif()
endif() find_package(OpenCL QUIET) #OpenCL_VERSION_STRING
if(OpenCL_FOUND)
set(_opencl_inc "${OpenCL_INCLUDE_DIRS}")
# Lua module if(APPLE)
set(_lua_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/3rd/lua") set(_opencl_inc "${OpenCL_INCLUDE_DIRS}/Headers")
set(_lua_bri_dir "${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd")
set(_lua_src_hdr "${_lua_src_dir}/lua.hpp" "${_lua_src_dir}/lua.h" "${_lua_src_dir}/luaconf.h" "${_lua_src_dir}/lualib.h")
pip_module(lua "" "PIP Lua support" "${_lua_src_dir};${_lua_bri_dir}" "${_lua_src_dir}" " (internal)")
target_include_directories(pip_lua PUBLIC "${_lua_src_dir}" "${_lua_bri_dir}")
if (WIN32)
target_compile_definitions(pip_lua PRIVATE LUA_BUILD_AS_DLL LUA_CORE)
endif()
list(APPEND HDR_DIRS "${_lua_bri_dir}/LuaBridge")
list(APPEND HDRS ${_lua_src_hdr})
# libmicrohttpd
pip_find_lib(microhttpd HINTS "${MINGW_LIB}")
if (microhttpd_FOUND)
set(_microhttpd_add_libs microhttpd)
if(WIN32)
if("${C_COMPILER}" STREQUAL "cl.exe")
else()
list(APPEND _microhttpd_add_libs ws2_32)
endif() endif()
pip_module(opencl "OpenCL" "PIP OpenCL support" "${_opencl_inc}" "" " (${OpenCL_VERSION_STRING})")
endif()
endif()
if (PIP_BUILD_IO_UTILS)
if(sodium_FOUND)
pip_module(io_utils "pip_crypt" "PIP I/O support" "" "" " (+crypt)")
else() else()
list(APPEND _microhttpd_add_libs dl) pip_module(io_utils "" "PIP I/O support" "" "" "")
find_library(tls_lib gnutls) endif()
if (tls_lib) endif()
set(gnutls_FOUND TRUE)
set(gnutls_LIBRARIES "${tls_lib}")
list(APPEND _microhttpd_add_libs gnutls) if (PIP_BUILD_LUA)
endif() # Lua module
if(DEFINED ENV{QNX_HOST}) set(_lua_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/3rd/lua")
list(APPEND _microhttpd_add_libs socket) set(_lua_bri_dir "${CMAKE_CURRENT_SOURCE_DIR}/libs/lua/3rd")
set(_lua_src_hdr "${_lua_src_dir}/lua.hpp" "${_lua_src_dir}/lua.h" "${_lua_src_dir}/luaconf.h" "${_lua_src_dir}/lualib.h")
pip_module(lua "" "PIP Lua support" "${_lua_src_dir};${_lua_bri_dir}" "${_lua_src_dir}" " (internal)")
target_include_directories(pip_lua PUBLIC "${_lua_src_dir}" "${_lua_bri_dir}")
if (WIN32)
target_compile_definitions(pip_lua PRIVATE LUA_BUILD_AS_DLL LUA_CORE)
endif()
list(APPEND HDR_DIRS "${_lua_bri_dir}/LuaBridge")
list(APPEND HDRS ${_lua_src_hdr})
endif()
if (PIP_BUILD_HTTP_SERVER)
# libmicrohttpd
pip_find_lib(microhttpd HINTS "${MINGW_LIB}")
if (microhttpd_FOUND)
set(_microhttpd_add_libs microhttpd)
if(WIN32)
if("${C_COMPILER}" STREQUAL "cl.exe")
else()
list(APPEND _microhttpd_add_libs ws2_32)
endif()
else() else()
if (NOT DEFINED ANDROID_PLATFORM) list(APPEND _microhttpd_add_libs dl)
list(APPEND _microhttpd_add_libs pthread util) find_library(tls_lib gnutls)
if (tls_lib)
set(gnutls_FOUND TRUE)
set(gnutls_LIBRARIES "${tls_lib}")
list(APPEND _microhttpd_add_libs gnutls)
endif()
if(DEFINED ENV{QNX_HOST})
list(APPEND _microhttpd_add_libs socket)
else()
if (NOT DEFINED ANDROID_PLATFORM)
list(APPEND _microhttpd_add_libs pthread util)
endif()
endif() endif()
endif() endif()
#list(APPEND microhttpd_LIBRARIES "${_microhttpd_add_libs}")
pip_module(http_server "${_microhttpd_add_libs}" "PIP HTTP server" "" "" "")
endif() endif()
#list(APPEND microhttpd_LIBRARIES "${_microhttpd_add_libs}")
pip_module(http_server "${_microhttpd_add_libs}" "PIP HTTP server" "" "" "")
endif() endif()
# libcurl
pip_find_lib(curl HINTS "${MINGW_LIB}") if (PIP_BUILD_HTTP_CLIENT)
if (curl_FOUND) # libcurl
pip_module(http_client curl "PIP HTTP client" "" "" "") pip_find_lib(curl HINTS "${MINGW_LIB}")
if (curl_FOUND)
pip_module(http_client curl "PIP HTTP client" "" "" "")
endif()
endif() endif()
# Test program # Test program
if(PIP_UTILS) if(PIP_UTILS)
@@ -547,9 +570,19 @@ if (NOT CROSSTOOLS)
endif() endif()
else() else()
pip_module(crypt "" "PIP crypt support" "" "" "")
pip_module(compress "" "PIP compression support" "" "" "") if (PIP_BUILD_CRYPT)
pip_module(io_utils "pip_crypt" "PIP I/O support" "" "" " (+crypt)") pip_module(crypt "" "PIP crypt support" "" "" "")
endif()
if (PIP_BUILD_COMPRESS)
pip_module(compress "" "PIP compression support" "" "" "")
endif()
if (PIP_BUILD_IO_UTILS)
pip_module(io_utils "pip_crypt" "PIP I/O support" "" "" " (+crypt)")
endif()
endif() endif()
endif() endif()