123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- cmake_minimum_required(VERSION 3.5)
- project(horrible-harry
- VERSION 0.1
- LANGUAGES CXX C)
- ###########
- # Debug or Release
- ###########
- if (NOT CMAKE_BUILD_TYPE)
- ## set default to Debug
- set(CMAKE_BUILD_TYPE Debug) # override with -DCMAKE_BUILD_TYPE=Release
- message("==> CMAKE_BUILD_TYPE empty. Changing it to Debug.")
- else()
- message("==> CMAKE_BUILD_TYPE == ${CMAKE_BUILD_TYPE}.")
- endif()
- FIND_PACKAGE(Git)
- IF(GIT_FOUND)
- message("Ask git for version information")
- EXECUTE_PROCESS(
- COMMAND ${GIT_EXECUTABLE} describe --abbrev=12 --long --tags --dirty --always --match v[0-9]*
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- OUTPUT_VARIABLE GIT_DESCRIBE_VERSION
- RESULT_VARIABLE GIT_DESCRIBE_RESULT
- ERROR_VARIABLE GIT_DESCRIBE_ERROR
- OUTPUT_STRIP_TRAILING_WHITESPACE
- )
- message("Version: " ${GIT_DESCRIBE_VERSION})
- # message("Result: " ${GIT_DESCRIBE_RESULT})
- ENDIF(GIT_FOUND)
- ## https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
- ## During Debug, use debug version of libstdc++ (asserts on access to invalid iterators, etc!)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
- ###########
- # Suppress certain warnings
- ###########
- # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
- # rm CMakeCache.txt and cmake . if you change any of the C++ Standards.
- ##############
- # C++ Standard
- ##############
- set(CMAKE_CXX_STANDARD 14)
- ## set(CMAKE_CXX_STANDARD 17)
- set(CMAKE_CXX_EXTENSIONS ON)
- # Are you debugging a buffer issue? If so, turn this to OFF.
- # This creates HUGE log files. Not for production!
- set(DISABLE_BUFFER_DEBUG ON CACHE BOOL "Turn off buffer debugging" FORCE)
- # set(DISABLE_BUFFER_DEBUG OFF CACHE BOOL "Turn off buffer debugging" FORCE)
- # Always disable in Release build.
- if((CMAKE_BUILD_TYPE STREQUAL Release) OR (CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo))
- message("Release build -- disable BUFFER DEBUG.")
- set(DISABLE_BUFFER_DEBUG ON CACHE BOOL "Turn off buffer debugging" FORCE)
- endif()
- # Display at configuration time what settings we're using.
- if(DISABLE_BUFFER_DEBUG)
- message("BUFFER DEBUG DISABLED (Good!)")
- else()
- message("WARNING: Big logs ahead! BUFFER DEBUG is ENABLED")
- endif()
- # Enable testing
- # set(BUILD_TESTING ON)
- # include(CTest)
- ### ADD gtest
- add_subdirectory(googletest)
- ### TESTS
- add_executable(test-lastseen test-lastseen.cpp lastseen.cpp)
- add_dependencies(test-lastseen gtest)
- target_link_libraries(test-lastseen gtest_main)
- enable_testing()
- add_test(NAME test-lastseen
- COMMAND test-lastseen)
- add_executable(test-utils test-utils.cpp utils.cpp)
- add_dependencies(test-utils gtest)
- target_link_libraries(test-utils gtest_main)
- if(DISABLE_BUFFER_DEBUG)
- target_compile_definitions(test-utils PUBLIC NO_BUFFER_DEBUG=1)
- endif()
- add_test(NAME test-utils
- COMMAND test-utils)
- add_executable(test-render test-render.cpp render.cpp terminal.cpp utils.cpp)
- add_dependencies(test-render gtest)
- target_link_libraries(test-render gtest_main)
- target_link_libraries(test-render zf_log)
- if(DISABLE_BUFFER_DEBUG)
- target_compile_definitions(test-render PUBLIC NO_BUFFER_DEBUG=1)
- endif()
- add_test(NAME test-render
- COMMAND test-render)
- add_executable(test-mangle test-mangle.cpp wordplay.cpp render.cpp terminal.cpp charman.cpp lastseen.cpp logs_utils.cpp images.h)
- add_dependencies(test-mangle gtest)
- target_link_libraries(test-mangle gtest_main)
- target_link_libraries(test-mangle zf_log)
- if(DISABLE_BUFFER_DEBUG)
- target_compile_definitions(test-mangle PUBLIC NO_BUFFER_DEBUG=1)
- endif()
- add_test(NAME test-mangle COMMAND test-mangle)
- add_executable(test-terminal test-terminal.cpp terminal.cpp utils.cpp)
- add_dependencies(test-terminal gtest)
- target_link_libraries(test-terminal gtest_main)
- target_link_libraries(test-terminal zf_log)
- if(DISABLE_BUFFER_DEBUG)
- target_compile_definitions(test-terminal PUBLIC NO_BUFFER_DEBUG=1)
- endif()
- add_test(NAME test-terminal COMMAND test-terminal)
- # include(FetchContent)
- #
- # FetchContent_Populate(
- # zf_log
- # GIT_REPOSITORY https://github.com/wonder-mice/zf_log.git
- # SOURCE_DIR zf_log
- # )
- # add_subdirectory(${zf_log_SOURCE_DIR}/src zf_log)
- # This works, if zf_log is pulled in.
- add_subdirectory(zf_log)
- # Example for how to define a test which uses gtest_gmock
- # add_executable(mytest tester.cpp)
- # target_link_libraries(mytest gmock_main)
- # Here's how to add all *.h and *.cpp files
- # to a project:
- #
- # file(GLOB SOURCES
- # header-folder/*.h
- # source-folder/*.cpp
- # )
- # add_executable(yourProj ${SOURCES})
- add_executable(ansi-to-src ansi-to-src.cpp utils.cpp)
- if(DISABLE_BUFFER_DEBUG)
- target_compile_definitions(ansi-to-src PUBLIC NO_BUFFER_DEBUG=1)
- endif()
- # Everything in the ansi directory is a dependency for images.h
- file(GLOB IMAGES
- ansi/*.ans
- )
- add_custom_command(
- OUTPUT images.h
- COMMAND ./build_images.sh
- DEPENDS ansi-to-src ${IMAGES}
- COMMENT "Generating images.h"
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
- )
- add_executable(hharry hharry.cpp lastseen.cpp terminal.cpp render.cpp utils.cpp images.h wordplay.cpp charman.cpp logs_utils.cpp)
- target_link_libraries(hharry util)
- target_link_libraries(hharry zf_log)
- target_compile_definitions(hharry PUBLIC HHVERSION="${GIT_DESCRIBE_VERSION}")
- # target_compile_definitions(hharry PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_INFO)
- target_compile_definitions(hharry PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_VERBOSE)
- if(DISABLE_BUFFER_DEBUG)
- target_compile_definitions(hharry PUBLIC NO_BUFFER_DEBUG=1)
- endif()
- # If you want this: ninja try-re or make try-re
- add_executable(try-re EXCLUDE_FROM_ALL try-re.c)
- add_executable(ansi-color EXCLUDE_FROM_ALL ansi-color.c)
- add_executable(images images.cpp utils.cpp images.h)
- target_link_libraries(images zf_log)
- if(DISABLE_BUFFER_DEBUG)
- target_compile_definitions(images PUBLIC NO_BUFFER_DEBUG=1)
- endif()
|