CMakeLists.txt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. # C++17 gives me transform
  26. set(CMAKE_CXX_STANDARD 17)
  27. set(CMAKE_CXX_EXTENSIONS ON)
  28. ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
  29. # add log_setup log
  30. FIND_PACKAGE( Boost 1.60 COMPONENTS program_options log_setup log REQUIRED )
  31. INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
  32. # We only need the one header file.
  33. # if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/json)
  34. # message("***")
  35. # message("*** ERROR/MISSING *** please run: git clone https://github.com/nlohmann/json.git --depth 1")
  36. # message("***")
  37. # endif()
  38. # add_subdirectory(json)
  39. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
  40. message("***")
  41. message("*** ERROR/MISSING *** please run: git clone https://github.com/google/googletest.git --depth 1")
  42. message("***")
  43. endif()
  44. add_subdirectory(googletest)
  45. option(gtest_build_samples "Build gtest's sample programs." OFF)
  46. option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
  47. ### TESTS
  48. add_executable(test-galaxy test-galaxy.cpp galaxy.cpp config.cpp utils.cpp buysell.cpp)
  49. add_dependencies(test-galaxy gtest)
  50. target_link_libraries(test-galaxy gtest_main ${Boost_LIBRARIES})
  51. add_executable(test-director test-director.cpp galaxy.cpp utils.cpp buysell.cpp director.cpp dispatchers.cpp boxes.cpp scripts.cpp config.cpp ansicolor.cpp)
  52. add_dependencies(test-director gtest)
  53. target_link_libraries(test-director gtest_main ${Boost_LIBRARIES})
  54. enable_testing()
  55. add_test(NAME test-galaxy
  56. COMMAND test-galaxy)
  57. add_test(NAME test-director
  58. COMMAND test-director)
  59. # dispatchers.cpp
  60. ADD_EXECUTABLE( twproxy twproxy.cpp utils.cpp session.cpp boxes.cpp director.cpp galaxy.cpp dispatchers.cpp scripts.cpp buysell.cpp config.cpp ansicolor.cpp)
  61. TARGET_LINK_LIBRARIES( twproxy ${Boost_LIBRARIES} pthread)
  62. target_precompile_headers(twproxy PRIVATE pch.hpp)