CMakeLists.txt 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. cmake_minimum_required(VERSION 3.10)
  2. project(horrible-harry)
  3. ###########
  4. # Debug or Release
  5. ###########
  6. if (NOT CMAKE_BUILD_TYPE)
  7. ## set default to Debug
  8. set(CMAKE_BUILD_TYPE Debug) # override with -DCMAKE_BUILD_TYPE=Release
  9. message("==> CMAKE_BUILD_TYPE empty. Changing it to Debug.")
  10. else()
  11. message("==> CMAKE_BUILD_TYPE == ${CMAKE_BUILD_TYPE}.")
  12. endif()
  13. ## https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
  14. ## During Debug, use debug version of libstdc++ (asserts on access to invalid iterators, etc!)
  15. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
  16. ###########
  17. # Suppress certain warnings
  18. ###########
  19. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
  20. # rm CMakeCache.txt and cmake . if you change any of the C++ Standards.
  21. ##############
  22. # C++ Standard
  23. ##############
  24. ## set(CMAKE_CXX_STANDARD 14)
  25. set(CMAKE_CXX_STANDARD 17)
  26. set(CMAKE_CXX_EXTENSIONS ON)
  27. # Enable testing
  28. # set(BUILD_TESTING ON)
  29. # include(CTest)
  30. ### ADD gtest
  31. add_subdirectory(googletest)
  32. ### TESTS
  33. add_executable(test-lastseen test-lastseen.cpp lastseen.cpp)
  34. add_dependencies(test-lastseen gtest)
  35. target_link_libraries(test-lastseen gtest_main)
  36. enable_testing()
  37. add_test(NAME test-lastseen
  38. COMMAND test-lastseen)
  39. add_executable(test-utils test-utils.cpp utils.cpp)
  40. add_dependencies(test-utils gtest)
  41. target_link_libraries(test-utils gtest_main)
  42. add_test(NAME test-utils
  43. COMMAND test-utils)
  44. add_executable(test-render test-render.cpp render.cpp terminal.cpp utils.cpp)
  45. add_dependencies(test-render gtest)
  46. target_link_libraries(test-render gtest_main)
  47. target_link_libraries(test-render zf_log)
  48. add_executable(test-mangle test-mangle.cpp wordplay.cpp render.cpp terminal.cpp charman.cpp lastseen.cpp logs_utils.cpp)
  49. add_dependencies(test-mangle gtest)
  50. target_link_libraries(test-mangle gtest_main)
  51. target_link_libraries(test-mangle zf_log)
  52. add_test(NAME test-render
  53. COMMAND test-render)
  54. add_test(NAME test-mangle COMMAND test-mangle)
  55. # include(FetchContent)
  56. #
  57. # FetchContent_Populate(
  58. # zf_log
  59. # GIT_REPOSITORY https://github.com/wonder-mice/zf_log.git
  60. # SOURCE_DIR zf_log
  61. # )
  62. # add_subdirectory(${zf_log_SOURCE_DIR}/src zf_log)
  63. # This works, if zf_log is pulled in.
  64. add_subdirectory(zf_log)
  65. # Example for how to define a test which uses gtest_gmock
  66. # add_executable(mytest tester.cpp)
  67. # target_link_libraries(mytest gmock_main)
  68. # Here's how to add all *.h and *.cpp files
  69. # to a project:
  70. #
  71. # file(GLOB SOURCES
  72. # header-folder/*.h
  73. # source-folder/*.cpp
  74. # )
  75. # add_executable(yourProj ${SOURCES})
  76. add_custom_command(
  77. OUTPUT images.h
  78. COMMAND ./build_images.sh
  79. DEPENDS ansi-to-src ghost.ans ghead.ans wolf.ans panther.ans bat.ans skull.ans skull-blink.ans icu.ans
  80. COMMENT "Generating images.h"
  81. WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  82. )
  83. add_executable(hharry hharry.cpp lastseen.cpp terminal.cpp render.cpp utils.cpp images.h wordplay.cpp charman.cpp logs_utils.cpp)
  84. target_link_libraries(hharry util)
  85. target_link_libraries(hharry zf_log)
  86. # target_compile_definitions(hharry PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_INFO)
  87. target_compile_definitions(hharry PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_VERBOSE)
  88. target_compile_definitions(hharry PUBLIC NO_BUFFER_DEBUG=1)
  89. add_executable(try-re try-re.c)
  90. add_executable(ansi-color ansi-color.c)
  91. add_executable(ansi-to-src ansi-to-src.cpp utils.cpp)
  92. add_executable(images images.cpp utils.cpp images.h)
  93. target_link_libraries(images zf_log)