SHARE
TWEET

Untitled

a guest Sep 21st, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cmake_minimum_required(VERSION 3.4)
  2.  
  3. set(CMAKE_CXX_STANDARD 17)
  4. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  5.  
  6. option(BUILD_COVERAGE "Build coverage" OFF)
  7.  
  8. set(
  9.   HUNTER_CACHE_SERVERS
  10.   "https://github.com/bmstu-iu8-cpp-sem-3/hunter-cache"
  11.   CACHE STRING "Default cache server"
  12. )
  13.  
  14. include("tools/gate/cmake/HunterGate.cmake")
  15.  
  16. huntergate(
  17.   URL "https://github.com/ruslo/hunter/archive/v0.23.34.tar.gz"
  18.   SHA1 "70287b1ffa810ee4e952052a9adff9b4856d0d54"
  19. )
  20.  
  21.  
  22. project(json)
  23. string(APPEND CMAKE_CXX_FLAGS " -pedantic -Werror -Wall -Wextra")
  24. string(APPEND CMAKE_CXX_FLAGS " -Wno-unused-command-line-argument")
  25. string(APPEND CMAKE_CXX_FLAGS " -Wshadow -Wnon-virtual-dtor")
  26.  
  27. hunter_add_package(GTest)
  28. find_package(GTest CONFIG REQUIRED)
  29.  
  30.  
  31. add_library(${PROJECT_NAME} STATIC
  32.   # enum your files and delete this comment
  33.   ${CMAKE_CURRENT_SOURCE_DIR}/sources/json.cpp
  34. #   json.h
  35. #   ${CMAKE_CURRENT_SOURCE_DIR}/sources/source.cpp
  36. )
  37. add_executable(tests
  38.   # TODO: enum your files and delete this comment
  39.   ${CMAKE_CURRENT_SOURCE_DIR}/tests/test.cpp
  40.  
  41.   ${CMAKE_CURRENT_SOURCE_DIR}/sources/json.cpp
  42. )
  43.  
  44. find_library(
  45.     GTEST_LOCAL_LIB
  46.     NAMES gtest
  47.     PATHS ${GTEST_ROOT}/lib
  48. )
  49.  
  50. find_library(
  51.     GTEST_LOCAL_LIB_MAIN
  52.     NAMES gtest_main
  53.     PATHS ${GTEST_ROOT}/lib
  54. )
  55.  
  56. target_include_directories(json
  57.   PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
  58. )
  59. target_include_directories(tests
  60.   PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
  61.   ${GTEST_ROOT}/include
  62. )
  63.  
  64. # target_link_libraries(tests GTest::main json)
  65.  
  66. target_link_libraries(tests
  67.     pthread
  68.     ${PROJECT_NAME}
  69.     ${GTEST_LOCAL_LIB}
  70.     ${GTEST_LOCAL_LIB_MAIN}
  71.     )
  72.  
  73. enable_testing()
  74. add_test(NAME unit_tests COMMAND tests)
  75.  
  76. if(BUILD_COVERAGE)
  77.   set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)
  78.   list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
  79.   find_package(codecov)
  80.  
  81.   add_coverage(json)
  82.   add_coverage(tests)
  83.   list(APPEND LCOV_REMOVE_PATTERNS "'${PROJECT_SOURCE_DIR}/tests/*'")
  84.   coverage_evaluate()
  85. endif()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top