CMakeLists.txt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. cmake_minimum_required(VERSION 3.2)
  2. # zf_log target (required)
  3. set(HEADERS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
  4. set(HEADERS door.h)
  5. set(SOURCES door.cpp ansicolor.cpp lines.cpp panel.cpp anyoption.cpp)
  6. # add_subdirectory(opendoors)
  7. ###########
  8. # Debug or Release
  9. ###########
  10. if (NOT CMAKE_BUILD_TYPE)
  11. ## set default to Debug
  12. set(CMAKE_BUILD_TYPE Debug) # override with -DCMAKE_BUILD_TYPE=Release
  13. message("==> CMAKE_BUILD_TYPE empty. Changing it to Debug.")
  14. else()
  15. message("==> CMAKE_BUILD_TYPE == ${CMAKE_BUILD_TYPE}.")
  16. endif()
  17. ## https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_macros.html
  18. ## During Debug, use debug version of libstdc++ (asserts on access to invalid iterators, etc!)
  19. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG")
  20. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
  21. ##############
  22. # C++ Standard
  23. ##############
  24. set(CMAKE_CXX_STANDARD 14)
  25. # set(CMAKE_CXX_STANDARD 17)
  26. set(CMAKE_CXX_EXTENSIONS ON)
  27. set(CMAKE_C_STANDARD 99)
  28. set(CMAKE_C_STANDARD_REQUIRED ON)
  29. set(CMAKE_C_EXTENSIONS OFF)
  30. if(MSVC)
  31. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4 /WX")
  32. else()
  33. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -pedantic-errors")
  34. endif()
  35. add_library(door++ ${HEADERS} ${SOURCES})
  36. # target_link_libraries(door++ pthread)
  37. target_include_directories(door++ PUBLIC $<BUILD_INTERFACE:${HEADERS_DIR}>)
  38. if(ZF_LOG_LIBRARY_PREFIX)
  39. target_compile_definitions(door++ PRIVATE "ZF_LOG_LIBRARY_PREFIX=${ZF_LOG_LIBRARY_PREFIX}")
  40. endif()