CMakeLists.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. cmake_minimum_required(VERSION 3.10)
  2. project(
  3. FastExtract
  4. VERSION 0.0.1
  5. LANGUAGES C CXX
  6. )
  7. set(CMAKE_BUILD_TYPE Release CACHE STRING "build type")
  8. set(CMAKE_C_STANDARD 99)
  9. set(CMAKE_CXX_STANDARD 17)
  10. if(NOT MSVC)
  11. set(CMAKE_CXX_FLAGS "-Wno-format -g0 -O3")
  12. if(NEED_ABI0)
  13. add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
  14. else()
  15. add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
  16. endif()
  17. endif(NOT MSVC)
  18. option(ENABLE_GPU "" ON)
  19. option(BUILD_CLIENT "" OFF)
  20. option(BUILD_SERVER "" OFF)
  21. option(BUILD_TUTORIAL "" OFF)
  22. option(ENABLE_HEADER_FOOTER "" ON)
  23. option(ENABLE_POSTPROCESS "" ON)
  24. set(Workflow_DIR "" CACHE PATH "WORKFLOW_DIRECTORY")
  25. set(TRT_DRECTORY "" CACHE PATH "TRT_DRECTORY")
  26. set(FASTDEPLOY_DRECTORY "" CACHE PATH "FASTDEPLOY_DRECTORY")
  27. set(RAPIDJSON_DRECTORY "" CACHE PATH "RAPIDJSON_DRECTORY")
  28. set(Srpc_DIR "" CACHE PATH "Srpc_DIR")
  29. set(THIRDPARTY_PATH ${PROJECT_SOURCE_DIR}/third_party)
  30. set(RUNTIME_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/bin)
  31. set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build)
  32. set(PROJECT_SOURCE_PATH ${PROJECT_SOURCE_DIR}/src)
  33. set(PROJECT_ROOT_PATH ${PROJECT_SOURCE_DIR})
  34. if (WIN32)
  35. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /wd4200")
  36. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /wd4200 /std:c++17")
  37. else ()
  38. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC -pipe -std=gnu99")
  39. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fPIC -pipe -std=c++17 -Wno-invalid-offsetof")
  40. endif ()
  41. if(BUILD_CLIENT OR BUILD_SERVER)
  42. find_package(srpc REQUIRED CONFIG HINTS ${Srpc_DIR})
  43. find_package(OpenSSL REQUIRED)
  44. find_package(Protobuf)
  45. if ("x${Protobuf_DIR}" STREQUAL "xProtobuf_DIR-NOTFOUND")
  46. if (APPLE)
  47. message (FATAL_ERROR ${Protobuf_ERROR_MSG_MACOS})
  48. else ()
  49. message (FATAL_ERROR ${Protobuf_ERROR_MSG_LINUX})
  50. endif ()
  51. endif ()
  52. get_filename_component(Protobuf_LIB_DIR ${Protobuf_LIBRARY} DIRECTORY)
  53. if (NOT EXISTS "${Srpc_DIR}/third_party/lz4/lib/lz4.h")
  54. set(LZ4_LIB lz4)
  55. endif ()
  56. if (NOT EXISTS "${Srpc_DIR}/third_party/snappy/cmake")
  57. set(SNAPPY_LIB snappy)
  58. endif ()
  59. find_package(ZLIB REQUIRED)
  60. find_package(Workflow REQUIRED CONFIG HINTS ${Workflow_DIR})
  61. # Prefer to static link first
  62. set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ${CMAKE_FIND_LIBRARY_SUFFIXES})
  63. find_library(Workflow_LIB workflow HINTS ${Workflow_DIR}/_lib)
  64. find_library(Srpc_LIB srpc HINTS ${Srpc_DIR}/_lib)
  65. endif(BUILD_CLIENT OR BUILD_SERVER)
  66. add_subdirectory(src)