deepcam/CMakeLists.txt

126 lines
3.9 KiB
CMake
Raw Normal View History

2025-06-26 13:47:54 +08:00
cmake_minimum_required(VERSION 3.10)
project(DeepCam)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Find required packages
find_package(OpenCV REQUIRED)
set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/)
set(MNN_IMGCODECS ON CACHE BOOL "Open MNN_IMGCODECS" FORCE)
set(MNN_CPU_WEIGHT_DEQUANT_GEMM ON CACHE BOOL "Open MNN_CPU_WEIGHT_DEQUANT_GEMM" FORCE)
set(MNN_BUILD_LLM ON CACHE BOOL "Open MNN_BUILD_LLM" FORCE)
set(MNN_SUPPORT_TRANSFORMER_FUSE ON CACHE BOOL "Open MNN_SUPPORT_TRANSFORMER_FUSE" FORCE)
set(LLM_SUPPORT_VISION ON CACHE BOOL "Open LLM_SUPPORT_VISION" FORCE)
set(MNN_LOW_MEMORY ON CACHE BOOL "Open MNN_LOW_MEMORY" FORCE)
set(MNN_BUILD_OPENCV ON CACHE BOOL "Open MNN_BUILD_OPENCV" FORCE)
set(MNN_IMGCODECS ON CACHE BOOL "Open MNN_IMGCODECS" FORCE)
# add_definitions(-DMNN_IMGCODECS)
option(ENABLE_PLUGIN_LOADING "Support loading of plugins" ON)
add_definitions(-DENABLE_PLUGIN_LOADING)
if (ENABLE_PLUGIN_LOADING)
set(PLUGIN_LOADING_SUPPORTED_AND_ENABLED TRUE)
install(DIRECTORY DESTINATION ${PLUGIN_DIRECTORY} DIRECTORY_PERMISSIONS
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
endif()
# check_c_source_compiles(
# "#if !defined(__x86_64) && !defined(__i386__) \
# && !defined(_M_IX86) && !defined(_M_AMD64)
# #error not x86
# #endif
# int main(){return 0;}"
# HAVE_X86)
if(HAVE_X86)
if (MSVC)
set(SUPPORTS_SSE2 1)
set(SUPPORTS_SSSE3 1)
set(SUPPORTS_SSE4_1 1)
else (MSVC)
check_c_compiler_flag(-msse2 SUPPORTS_SSE2)
check_c_compiler_flag(-mssse3 SUPPORTS_SSSE3)
check_c_compiler_flag(-msse4.1 SUPPORTS_SSE4_1)
endif (MSVC)
if(SUPPORTS_SSE4_1)
add_definitions(-DHAVE_SSE4_1)
endif()
endif()
add_subdirectory(${ROOT_DIR}/third_party/MNN/ MNN)
link_directories(${ROOT_DIR}/build/MNN)
link_directories(${ROOT_DIR}/build/MNN/express)
link_directories(${ROOT_DIR}/build/MNN/tools/cv/)
# Include directories
include_directories(${CMAKE_SOURCE_DIR}/deepcam/sources)
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${CURL_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/third_party/)
include_directories(${CMAKE_SOURCE_DIR}/third_party/MNN/include)
include_directories(${CMAKE_SOURCE_DIR}/third_party/MNN/include/MNN)
include_directories(${CMAKE_SOURCE_DIR}/third_party/MNN/source/)
include_directories(${CMAKE_SOURCE_DIR}/third_party/MNN/tools/)
include_directories(${CMAKE_SOURCE_DIR}/third_party/MNN/tools/cv/include)
file(GLOB DEEP_CAM_SRC ${CMAKE_CURRENT_LIST_DIR}/deepcam/sources/*
${CMAKE_CURRENT_LIST_DIR}/deepcam/sources/speculative_decoding/*
${CMAKE_CURRENT_LIST_DIR}/deepcam/sources/minjia/*)
# Sources directory is already included above
add_library(DeepCam STATIC ${DEEP_CAM_SRC})
# Link libraries to DeepCam
target_link_libraries(DeepCam
MNN
MNN_Express
MNNOpenCV
${OpenCV_LIBS}
${CURL_LIBRARIES}
)
if(JSONCPP_FOUND)
include_directories(${JSONCPP_INCLUDE_DIRS})
endif()
# Add subdirectories
add_subdirectory(test)
# Print configuration information
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "OpenCV version: ${OpenCV_VERSION}")
message(STATUS "OpenCV include dirs: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "OpenCV libraries: ${OpenCV_LIBS}")
message(STATUS "CURL libraries: ${CURL_LIBRARIES}")
if(JSONCPP_FOUND)
message(STATUS "JSONCPP found: ${JSONCPP_VERSION}")
message(STATUS "JSONCPP libraries: ${JSONCPP_LIBRARIES}")
else()
message(STATUS "JSONCPP not found - AutoProcessor will have limited functionality")
message(STATUS "To install jsoncpp on Ubuntu: sudo apt-get install libjsoncpp-dev")
message(STATUS "To install jsoncpp on macOS: brew install jsoncpp")
endif()
install(TARGETS DeepCam DESTINATION lib)
# Optional: Enable testing
enable_testing()
# add_test(NAME vision_process_test COMMAND vision_process_example)