CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. cmake_minimum_required(VERSION 3.5)
  2. project(doorman
  3. VERSION 0.1
  4. LANGUAGES CXX C)
  5. ###########
  6. # Debug or Release
  7. ###########
  8. if (NOT CMAKE_BUILD_TYPE)
  9. ## set default to Debug
  10. set(CMAKE_BUILD_TYPE Debug) # 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. FIND_PACKAGE(Git)
  16. IF(GIT_FOUND)
  17. message("Ask git for version information")
  18. EXECUTE_PROCESS(
  19. COMMAND ${GIT_EXECUTABLE} describe --abbrev=12 --long --tags --dirty --always --match v[0-9]*
  20. WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  21. OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
  22. RESULT_VARIABLE GIT_DESCRIBE_RESULT
  23. ERROR_VARIABLE GIT_DESCRIBE_ERROR
  24. OUTPUT_STRIP_TRAILING_WHITESPACE
  25. )
  26. message("Version: " ${GIT_DESCRIBE_VERSION})
  27. # message("Result: " ${GIT_DESCRIBE_RESULT})
  28. ENDIF(GIT_FOUND)
  29. ## https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
  30. ## During Debug, use debug version of libstdc++ (asserts on access to invalid iterators, etc!)
  31. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
  32. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  33. ###########
  34. # Suppress certain warnings
  35. ###########
  36. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
  37. # rm CMakeCache.txt and cmake . if you change any of the C++ Standards.
  38. ##############
  39. # C++ Standard
  40. ##############
  41. set(CMAKE_CXX_STANDARD 14)
  42. ## set(CMAKE_CXX_STANDARD 17)
  43. set(CMAKE_CXX_EXTENSIONS ON)
  44. # Enable testing
  45. set(BUILD_TESTING ON)
  46. include(CTest)
  47. ### ADD gtest
  48. add_subdirectory(googletest)
  49. ### TESTS
  50. # add_executable(test-lastseen test-lastseen.cpp lastseen.cpp)
  51. # add_dependencies(test-lastseen gtest)
  52. # target_link_libraries(test-lastseen gtest_main)
  53. # enable_testing()
  54. # add_test(NAME test-lastseen
  55. # COMMAND test-lastseen)
  56. # add_executable(test-utils test-utils.cpp utils.cpp)
  57. # add_dependencies(test-utils gtest)
  58. # target_link_libraries(test-utils gtest_main)
  59. # add_test(NAME test-utils
  60. # COMMAND test-utils)
  61. add_subdirectory(zf_log)
  62. # Example for how to define a test which uses gtest_gmock
  63. # add_executable(mytest tester.cpp)
  64. # target_link_libraries(mytest gmock_main)
  65. # Here's how to add all *.h and *.cpp files
  66. # to a project:
  67. #
  68. # file(GLOB SOURCES
  69. # header-folder/*.h
  70. # source-folder/*.cpp
  71. # )
  72. # add_executable(yourProj ${SOURCES})
  73. # add_executable(doorman doorman.cpp lastseen.cpp terminal.cpp render.cpp utils.cpp images.h wordplay.cpp charman.cpp logs_utils.cpp)
  74. add_executable(doorman doorman.cpp terminal.cpp utils.cpp logs_utils.cpp)
  75. target_link_libraries(doorman util)
  76. target_link_libraries(doorman zf_log)
  77. # target_compile_definitions(doorman PUBLIC DMVERSION="${GIT_DESCRIBE_VERSION}")
  78. # target_compile_definitions(doorman PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_INFO)
  79. target_compile_definitions(doorman PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_VERBOSE)
  80. # If you want this: ninja try-re or make try-re
  81. # add_executable(try-re EXCLUDE_FROM_ALL try-re.c)
  82. # add_executable(ansi-color EXCLUDE_FROM_ALL ansi-color.c)
  83. # add_executable(images images.cpp utils.cpp images.h)
  84. # target_link_libraries(images zf_log)