12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
- message(FATAL_ERROR "Please create a separate directory for build files.")
- endif()
- cmake_minimum_required(VERSION 3.6)
- project(INS C CXX)
- set(CMAKE_VERBOSE_MAKEFILE OFF)
- set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
- # ---[ Options
- option(build_modules "build modules" ON)
- if(build_modules)
- add_subdirectory(modules)
- endif()
- set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
- ##OpenCV
- if(WITH_OPENCV)
- if(CMAKE_TOOLCHAIN_FILE)
- if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv)
- set(OpenCV_LIBS opencv_core opencv_imgproc opencv_highgui opencv_features2d opencv_flann)
- if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/imgcodecs)
- list(APPEND OpenCV_LIBS opencv_imgcodecs)
- endif()
- if(EXISTS ${PROJECT_SOURCE_DIR}/include/opencv2/videoio)
- list(APPEND OpenCV_LIBS opencv_videoio)
- endif()
- message(STATUS "HAVE_OPENCV enabled")
- message(STATUS "opencv libraries: ${OpenCV_LIBS}")
- set(HAVE_OPENCV true)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV")
- else()
- set (HAVE_OPENCV false)
- endif()
- else()
- set(OpenCV_FIND_QUIETLY true)
- #find_package(OpenCV REQUIRED) //this will include opencv_ts which result in crash on centos
- find_package(OpenCV OPTIONAL_COMPONENTS imgcodecs)
- find_package(OpenCV OPTIONAL_COMPONENTS videoio)
- set(optional_opencv_libs ${OpenCV_LIBS})
- find_package(OpenCV REQUIRED core imgproc highgui features2d)
- if(OpenCV_FOUND)
- if(imgcodecs_FOUND)
- list(APPEND OpenCV_LIBS optional_opencv_libs)
- endif()
- message(STATUS "HAVE_OPENCV enabled")
- message(STATUS "opencv libraries: ${OpenCV_LIBS}")
- set(HAVE_OPENCV true)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENCV")
- else()
- set (HAVE_OPENCV false)
- endif()
- endif()
- else()
- set (HAVE_OPENCV false)
- endif()
- #查找mysql是否安装
- find_package(MYSQL QUIET)
- if(MYSQL_FOUND AND ENABLE_MYSQL)
- message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
- include_directories(${MYSQL_INCLUDE_DIR})
- include_directories(${MYSQL_INCLUDE_DIR}/mysql)
- add_definitions(-DENABLE_MYSQL)
- list(APPEND 3RDPARTY_LIBS ${MYSQL_LIBRARIES})
- endif()
- add_subdirectory(${PROJECT_SOURCE_DIR}/framework)
- add_subdirectory(${PROJECT_SOURCE_DIR}/source/)
- # # 寻找当前目录下所有源文件
- # aux_source_directory(./source/src DIR_SRCS)
- # add_compile_options(-Wall -std=c++11 -O2 -g)
- # link_directories(${PROJECT_SOURCE_DIR}/lib)
- # link_directories(/usr/local/lib)
- # list(APPEND ALL_LINKER_LIBS mk_api ZLToolKit dl ${3RDPARTY_LIBS} ${OpenCV_LIBS} pthread hv ins_core ins_va)
- # # 指定生成的目标
- # add_executable(main ${DIR_SRCS})
- # # 链接
- # target_link_libraries(main ${ALL_LINKER_LIBS})
|