123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- cmake_minimum_required(VERSION 3.5)
- project(horrible-harry
- VERSION 0.1
- LANGUAGES CXX C)
- if (NOT CMAKE_BUILD_TYPE)
-
- set(CMAKE_BUILD_TYPE Debug)
- 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})
-
- ENDIF(GIT_FOUND)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG -fsanitize=address -fsanitize=leak -fsanitize=undefined -fsanitize=shift-base -fsanitize=unreachable -fsanitize=null -fsanitize=return -fsanitize=bounds-strict -fsanitize=object-size")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
- set(CMAKE_CXX_STANDARD 14)
- set(CMAKE_CXX_EXTENSIONS ON)
- set(DISABLE_BUFFER_DEBUG ON CACHE BOOL "Turn off buffer debugging" FORCE)
- 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()
- if(DISABLE_BUFFER_DEBUG)
- message("BUFFER DEBUG DISABLED (Good!)")
- else()
- message("WARNING: Big logs ahead! BUFFER DEBUG is ENABLED")
- endif()
- add_subdirectory(googletest)
- 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)
- add_subdirectory(zf_log)
- 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()
- file(GLOB IMAGES
- ansi/*.ans
- )
- add_custom_command(
- OUTPUT images.h
- COMMAND ./build_images.sh ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}
- 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}")
- if((CMAKE_BUILD_TYPE STREQUAL Release) OR (CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo))
- target_compile_definitions(hharry PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_WARN)
- else()
- target_compile_definitions(hharry PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_VERBOSE)
- endif()
- if(DISABLE_BUFFER_DEBUG)
- target_compile_definitions(hharry PUBLIC NO_BUFFER_DEBUG=1)
- endif()
- 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()
|