CMakeLists.conan 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. # Conan Setup
  22. add_definitions("-std=c++11")
  23. set(Boost_USE_STATIC_LIBS ON)
  24. include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
  25. conan_basic_setup()
  26. ##############
  27. # C++ Standard
  28. ##############
  29. # set(CMAKE_CXX_STANDARD 14)
  30. # C++17 gives me transform
  31. set(CMAKE_CXX_STANDARD 17)
  32. set(CMAKE_CXX_EXTENSIONS ON)
  33. # ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
  34. # We only need the one header file.
  35. # if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/json)
  36. # message("***")
  37. # message("*** ERROR/MISSING *** please run: git clone https://github.com/nlohmann/json.git --depth 1")
  38. # message("***")
  39. # endif()
  40. # add_subdirectory(json)
  41. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
  42. message("***")
  43. message("*** ERROR/MISSING *** please run: git clone https://github.com/google/googletest.git --depth 1")
  44. message("***")
  45. endif()
  46. add_subdirectory(googletest)
  47. option(gtest_build_samples "Build gtest's sample programs." OFF)
  48. option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
  49. ### TESTS
  50. add_executable(test-galaxy test-galaxy.cpp galaxy.cpp config.cpp utils.cpp buysell.cpp)
  51. add_dependencies(test-galaxy gtest)
  52. target_link_libraries(test-galaxy gtest_main ${CONAN_LIBS})
  53. 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)
  54. add_dependencies(test-director gtest)
  55. target_link_libraries(test-director gtest_main ${CONAN_LIBS})
  56. enable_testing()
  57. add_test(NAME test-galaxy
  58. COMMAND test-galaxy)
  59. add_test(NAME test-director
  60. COMMAND test-director)
  61. # dispatchers.cpp
  62. 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)
  63. TARGET_LINK_LIBRARIES( twproxy ${CONAN_LIBS} pthread)
  64. # Remove precompile headers, that also doesn't work.
  65. # target_precompile_headers(twproxy PRIVATE pch.hpp)