CMakeLists.txt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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_executable(test-render test-render.cpp render.cpp terminal.cpp utils.cpp)
  62. add_dependencies(test-render gtest)
  63. target_link_libraries(test-render gtest_main)
  64. target_link_libraries(test-render zf_log)
  65. # add_test(NAME test-mangle COMMAND test-mangle)
  66. # add_executable(test-terminal test-terminal.cpp terminal.cpp utils.cpp)
  67. # add_dependencies(test-terminal gtest)
  68. # target_link_libraries(test-terminal gtest_main)
  69. # target_link_libraries(test-terminal zf_log)
  70. add_test(NAME test-terminal COMMAND test-terminal)
  71. add_subdirectory(zf_log)
  72. # Example for how to define a test which uses gtest_gmock
  73. # add_executable(mytest tester.cpp)
  74. # target_link_libraries(mytest gmock_main)
  75. # Here's how to add all *.h and *.cpp files
  76. # to a project:
  77. #
  78. # file(GLOB SOURCES
  79. # header-folder/*.h
  80. # source-folder/*.cpp
  81. # )
  82. # add_executable(yourProj ${SOURCES})
  83. # add_executable(doorman doorman.cpp lastseen.cpp terminal.cpp render.cpp utils.cpp images.h wordplay.cpp charman.cpp logs_utils.cpp)
  84. add_executable(doorman doorman.cpp terminal.cpp utils.cpp logs_utils.cpp)
  85. target_link_libraries(doorman util)
  86. target_link_libraries(doorman zf_log)
  87. # target_compile_definitions(doorman PUBLIC DMVERSION="${GIT_DESCRIBE_VERSION}")
  88. # target_compile_definitions(doorman PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_INFO)
  89. target_compile_definitions(doorman PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_VERBOSE)
  90. # If you want this: ninja try-re or make try-re
  91. # add_executable(try-re EXCLUDE_FROM_ALL try-re.c)
  92. # add_executable(ansi-color EXCLUDE_FROM_ALL ansi-color.c)
  93. # add_executable(images images.cpp utils.cpp images.h)
  94. # target_link_libraries(images zf_log)