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.
 
 

91 lines
3.3 KiB

cmake_minimum_required(VERSION 3.6)
set(INS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(NOT COMPILER_SUPPORTS_CXX11)
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
if(USE_libstdcpp)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")
endif()
# compile flags
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -D_REENTRANT -fPIC -Wall -Werror")
# ---[ Options
option(build_UserApp "build module UserApp " ON)
option(build_TcpProxySession "build module TcpProxySession" ON)
option(build_dataType "build module dataType" ON)
# ---[ 3rdparty
set(3RDPARTY_LIBS "")
set(DEPENDENCIES "")
set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake)
# ---[ opencv
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()
include_directories(${OpenCV_INCLUDE_DIRS})
list(APPEND 3RDPARTY_LIBS ${OpenCV_LIBS})
message(STATUS "opencv include: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "opencv libraries: ${OpenCV_LIBS}")
else()
message(FATAL_ERROR "opencv not found!")
endif()
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()
set(module_list "")
if(build_UserApp)
list(APPEND module_list UserApp)
include_directories(${PROJECT_SOURCE_DIR}/modules/UserApp/src)
install(DIRECTORY UserApp/include/ DESTINATION include)
endif()
if(build_TcpProxySession)
list(APPEND module_list TcpProxySession)
include_directories(${PROJECT_SOURCE_DIR}/modules/TcpProxySession/src)
install(DIRECTORY TcpProxySession/include/ DESTINATION include)
endif()
if(build_dataType)
list(APPEND module_list dataType)
include_directories(${PROJECT_SOURCE_DIR}/modules/dataType/src)
install(DIRECTORY dataType/include/ DESTINATION include)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(/usr/local/include/hv)
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/)
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/)
foreach(module ${module_list})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/${module}/include)
file(GLOB_RECURSE module_src ${CMAKE_CURRENT_SOURCE_DIR}/${module}/*.cpp)
list(APPEND srcs ${module_src})
endforeach()
add_library(models SHARED ${srcs})
install(TARGETS models LIBRARY DESTINATION lib)
target_link_libraries(models ${3RDPARTY_LIBS} rt dl pthread ZLToolKit hv )