cmake_minimum_required(VERSION 3.5) project(doorman 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) # 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) # add_test(NAME test-utils # COMMAND test-utils) 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(doorman doorman.cpp lastseen.cpp terminal.cpp render.cpp utils.cpp images.h wordplay.cpp charman.cpp logs_utils.cpp) add_executable(doorman doorman.cpp terminal.cpp utils.cpp logs_utils.cpp) target_link_libraries(doorman util) target_link_libraries(doorman zf_log) # target_compile_definitions(doorman PUBLIC DMVERSION="${GIT_DESCRIBE_VERSION}") # target_compile_definitions(doorman PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_INFO) target_compile_definitions(doorman PUBLIC ZF_LOG_DEF_LEVEL=ZF_LOG_VERBOSE) # 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)