CMakeLists.txt 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. cmake_minimum_required(VERSION 3.0)
  2. project(ex1
  3. VERSION 0.1
  4. LANGUAGES CXX)
  5. ###########
  6. # Debug or Release
  7. ###########
  8. if (NOT CMAKE_BUILD_TYPE)
  9. ## set default to Debug
  10. set(CMAKE_BUILD_TYPE RelWithDebInfo) # override with -DCMAKE_BUILD_TYPE=Release
  11. message("==> CMAKE_BUILD_TYPE empty. Changing it to Debug.")
  12. else()
  13. message("==> CMAKE_BUILD_TYPE == ${CMAKE_BUILD_TYPE}.")
  14. endif()
  15. ## set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG -DGLIBCXX_FORCE_NEW")
  16. ## https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
  17. ## During Debug, use debug version of libstdc++ (asserts on access to invalid iterators, etc!)
  18. ## set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
  19. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
  20. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  21. ##############
  22. # C++ Standard
  23. ##############
  24. set(CMAKE_CXX_STANDARD 14)
  25. # set(CMAKE_CXX_STANDARD 17)
  26. set(CMAKE_CXX_EXTENSIONS ON)
  27. ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
  28. # add log_setup log
  29. FIND_PACKAGE( Boost 1.60 COMPONENTS program_options log_setup log REQUIRED )
  30. INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
  31. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp)
  32. message("***")
  33. message("*** ERROR/MISSING *** please run: git clone https://github.com/jbeder/yaml-cpp.git --depth 1")
  34. message("***")
  35. endif()
  36. add_subdirectory(yaml-cpp)
  37. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
  38. message("***")
  39. message("*** ERROR/MISSING *** please run: git clone https://github.com/google/googletest.git --depth 1")
  40. message("***")
  41. endif()
  42. add_subdirectory(googletest)
  43. option(gtest_build_samples "Build gtest's sample programs." OFF)
  44. option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
  45. ### TESTS
  46. add_executable(test-galaxy test-galaxy.cpp galaxy.cpp utils.cpp buysell.cpp)
  47. add_dependencies(test-galaxy gtest)
  48. ## target_link_libraries(test-galaxy gtest_main)
  49. target_link_libraries(test-galaxy gtest_main ${Boost_LIBRARIES} yaml-cpp)
  50. enable_testing()
  51. add_test(NAME test-galaxy
  52. COMMAND test-galaxy)
  53. # dispatchers.cpp
  54. ADD_EXECUTABLE( twproxy twproxy.cpp utils.cpp session.cpp boxes.cpp director.cpp galaxy.cpp dispatchers.cpp scripts.cpp buysell.cpp )
  55. TARGET_LINK_LIBRARIES( twproxy ${Boost_LIBRARIES} pthread yaml-cpp)
  56. target_precompile_headers(twproxy PRIVATE pch.hpp)