CMakeLists.txt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. cmake_minimum_required(VERSION 3.5)
  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. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  17. ###########
  18. # Suppress certain warnings
  19. ###########
  20. # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
  21. # rm CMakeCache.txt and cmake . if you change any of the C++ Standards.
  22. ##############
  23. # C++ Standard
  24. ##############
  25. set(CMAKE_CXX_STANDARD 14)
  26. ## set(CMAKE_CXX_STANDARD 17)
  27. set(CMAKE_CXX_EXTENSIONS ON)
  28. # Enable testing
  29. # set(BUILD_TESTING ON)
  30. # include(CTest)
  31. ### ADD gtest
  32. add_subdirectory(googletest)
  33. ### TESTS
  34. add_executable(test-lastseen test-lastseen.cpp lastseen.cpp)
  35. add_dependencies(test-lastseen gtest)
  36. target_link_libraries(test-lastseen gtest_main)
  37. enable_testing()
  38. add_test(NAME test-lastseen
  39. COMMAND test-lastseen)
  40. add_executable(test-utils test-utils.cpp utils.cpp)
  41. add_dependencies(test-utils gtest)
  42. target_link_libraries(test-utils gtest_main)
  43. add_test(NAME test-utils
  44. COMMAND test-utils)
  45. add_executable(test-render test-render.cpp render.cpp terminal.cpp utils.cpp)
  46. add_dependencies(test-render gtest)
  47. target_link_libraries(test-render gtest_main)
  48. target_link_libraries(test-render zf_log)
  49. add_executable(test-mangle test-mangle.cpp wordplay.cpp render.cpp terminal.cpp charman.cpp lastseen.cpp logs_utils.cpp)
  50. add_dependencies(test-mangle gtest)
  51. target_link_libraries(test-mangle gtest_main)
  52. target_link_libraries(test-mangle zf_log)
  53. add_test(NAME test-render
  54. COMMAND test-render)
  55. add_test(NAME test-mangle COMMAND test-mangle)
  56. # include(FetchContent)
  57. #
  58. # FetchContent_Populate(
  59. # zf_log
  60. # GIT_REPOSITORY https://github.com/wonder-mice/zf_log.git
  61. # SOURCE_DIR zf_log
  62. # )
  63. # add_subdirectory(${zf_log_SOURCE_DIR}/src zf_log)
  64. # This works, if zf_log is pulled in.
  65. add_subdirectory(zf_log)
  66. # Example for how to define a test which uses gtest_gmock
  67. # add_executable(mytest tester.cpp)
  68. # target_link_libraries(mytest gmock_main)
  69. # Here's how to add all *.h and *.cpp files
  70. # to a project:
  71. #
  72. # file(GLOB SOURCES
  73. # header-folder/*.h
  74. # source-folder/*.cpp
  75. # )
  76. # add_executable(yourProj ${SOURCES})
  77. add_custom_command(
  78. OUTPUT images.h
  79. COMMAND ./build_images.sh
  80. DEPENDS ansi-to-src ghost.ans ghead.ans wolf.ans panther.ans bat.ans skull.ans skull-blink.ans icu.ans
  81. COMMENT "Generating images.h"
  82. WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  83. )
  84. add_executable(hharry hharry.cpp lastseen.cpp terminal.cpp render.cpp utils.cpp images.h wordplay.cpp charman.cpp logs_utils.cpp)
  85. target_link_libraries(hharry util)
  86. target_link_libraries(hharry zf_log)
  87. # target_compile_definitions(hharry PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_INFO)
  88. target_compile_definitions(hharry PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_VERBOSE)
  89. target_compile_definitions(hharry PUBLIC NO_BUFFER_DEBUG=1)
  90. add_executable(try-re try-re.c)
  91. add_executable(ansi-color ansi-color.c)
  92. add_executable(ansi-to-src ansi-to-src.cpp utils.cpp)
  93. target_compile_definitions(ansi-to-src PUBLIC NO_BUFFER_DEBUG=1)
  94. add_executable(images images.cpp utils.cpp images.h)
  95. target_link_libraries(images zf_log)
  96. target_compile_definitions(images PUBLIC NO_BUFFER_DEBUG=1)