You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.2 KiB

3 years ago
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "Please create a separate directory for build files.")
endif()
3 years ago
cmake_minimum_required(VERSION 3.6)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
3 years ago
project(ISNS C CXX)
set(CMAKE_VERBOSE_MAKEFILE OFF)
# ---[ Options
option(build_modules "build modules" ON)
# set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/source/bin/)
if(build_modules)
add_subdirectory(modules)
endif()
set(ENABLE_MYSQL ON CACHE BOOL "enable mysql")
3 years ago
##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()
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/)
include_directories(/usr/local/include/hv)
include_directories(${PROJECT_SOURCE_DIR}/modules/UserApp/include/)
include_directories(${PROJECT_SOURCE_DIR}/modules/dataType/include/)
include_directories(${PROJECT_SOURCE_DIR}/modules/Disposition/include/)
include_directories(${PROJECT_SOURCE_DIR}/modules/TcpProxySession/include/)
3 years ago
# 寻找当前目录下所有源文件
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 models)
# 指定生成的目标
add_executable(main ${DIR_SRCS})
# 链接
target_link_libraries(main ${ALL_LINKER_LIBS})