CMakeLists.txt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. cmake_minimum_required(VERSION 3.6)
  2. set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib/)
  3. set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/)
  4. set(INS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
  5. add_compile_options(-std=c++17)
  6. # compile flags
  7. set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed")
  8. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O2")
  9. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g")
  10. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -D_REENTRANT -fPIC -Wall -Werror")
  11. set(CNSTREAM_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
  12. set(LIBRARY_OUTPUT_PATH ${CNSTREAM_ROOT_DIR}/lib)
  13. set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/)
  14. set(CMAKE_MODULE_PATH ${CNSTREAM_ROOT_DIR}/cmake)
  15. set(VERSION_HEAD_FILE ${INS_ROOT_DIR}/framework/core/include/ins_version.hpp)
  16. execute_process(COMMAND awk /INS_MAJOR_VERSION/ ${VERSION_HEAD_FILE} OUTPUT_VARIABLE VERSION_STR)
  17. string(REGEX MATCH "[0-9]+" MAJOR_VERSION ${VERSION_STR})
  18. execute_process(COMMAND awk /INS_MINOR_VERSION/ ${VERSION_HEAD_FILE} OUTPUT_VARIABLE VERSION_STR)
  19. string(REGEX MATCH "[0-9]+" MINOR_VERSION ${VERSION_STR})
  20. execute_process(COMMAND awk /INS_PATCH_VERSION/ ${VERSION_HEAD_FILE} OUTPUT_VARIABLE VERSION_STR)
  21. string(REGEX MATCH "[0-9]+" PATCH_VERSION ${VERSION_STR})
  22. set(ISNS_TARGET_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
  23. include_directories(${3RDPARTY_INCLUDE_DIRS})
  24. include_directories(${PROJECT_SOURCE_DIR}/framework/core/include/)
  25. include_directories(${PROJECT_SOURCE_DIR}/3rdparty/)
  26. include_directories(${PROJECT_SOURCE_DIR}/3rdparty/rapidjson/include/)
  27. include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dataType/include/)
  28. aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/core/src core_srcs)
  29. aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/dataType/src core_srcs)
  30. add_library(ins_core SHARED ${core_srcs} )
  31. target_link_libraries(ins_core protobuf ${SOURCE_LINKER_LIBS})
  32. target_link_libraries(ins_core dl pthread ${CNRT_LIBS} ${GFLAGS_LIBRARIES})
  33. set_target_properties(ins_core PROPERTIES LINK_FLAGS_RELEASE -s)
  34. set_target_properties(ins_core PROPERTIES VERSION ${ISNS_TARGET_VERSION})