CMakeLists.txt 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. add_definitions("-std=c++11")
  22. set(Boost_USE_STATIC_LIBS ON)
  23. include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
  24. conan_basic_setup()
  25. ##############
  26. # C++ Standard
  27. ##############
  28. # set(CMAKE_CXX_STANDARD 14)
  29. # C++17 gives me transform
  30. set(CMAKE_CXX_STANDARD 17)
  31. set(CMAKE_CXX_EXTENSIONS ON)
  32. #ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
  33. # add log_setup log
  34. #FIND_PACKAGE( Boost 1.60 COMPONENTS program_options log_setup log REQUIRED )
  35. #INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
  36. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp)
  37. message("***")
  38. message("*** ERROR/MISSING *** please run: git clone https://github.com/jbeder/yaml-cpp.git --depth 1")
  39. message("***")
  40. endif()
  41. add_subdirectory(yaml-cpp)
  42. if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/googletest)
  43. message("***")
  44. message("*** ERROR/MISSING *** please run: git clone https://github.com/google/googletest.git --depth 1")
  45. message("***")
  46. endif()
  47. add_subdirectory(googletest)
  48. option(gtest_build_samples "Build gtest's sample programs." OFF)
  49. option(gtest_disable_pthreads "Disable uses of pthreads in gtest." OFF)
  50. ### TESTS
  51. add_executable(test-galaxy test-galaxy.cpp galaxy.cpp config.cpp utils.cpp buysell.cpp)
  52. add_dependencies(test-galaxy gtest)
  53. #target_link_libraries(test-galaxy gtest_main ${Boost_LIBRARIES} yaml-cpp)
  54. target_link_libraries(test-galaxy gtest_main ${CONAN_LIBS} yaml-cpp)
  55. 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)
  56. add_dependencies(test-director gtest)
  57. #target_link_libraries(test-director gtest_main ${Boost_LIBRARIES} yaml-cpp)
  58. target_link_libraries(test-director gtest_main ${CONAN_LIBS} yaml-cpp)
  59. enable_testing()
  60. add_test(NAME test-galaxy
  61. COMMAND test-galaxy)
  62. add_test(NAME test-director
  63. COMMAND test-director)
  64. # dispatchers.cpp
  65. 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)
  66. #TARGET_LINK_LIBRARIES( twproxy ${Boost_LIBRARIES} pthread yaml-cpp)
  67. TARGET_LINK_LIBRARIES( twproxy ${CONAN_LIBS} pthread yaml-cpp)
  68. # target_precompile_headers(twproxy PRIVATE pch.hpp)