cc.cmake 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. # -*- coding: utf-8; mode: cmake -*-
  2. # Common cmake section for subdirs
  3. # (c) Daniel Llorens - 2018-2024
  4. # This library is free software; you can redistribute it and/or modify it under
  5. # the terms of the GNU Lesser General Public License as published by the Free
  6. # Software Foundation; either version 3 of the License, or (at your option) any
  7. # later version.
  8. set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/config/")
  9. set (SANITIZE 1
  10. CACHE BOOL "Build with sanitizers.")
  11. set (BASE_CXXFLAGS "-std=c++2b -Wall -Werror -fdiagnostics-color=always -Wno-unknown-pragmas \
  12. -finput-charset=UTF-8 -fextended-identifiers -Wno-error=strict-overflow \
  13. -Werror=zero-as-null-pointer-constant")
  14. if (SANITIZE)
  15. set (BASE_CXXFLAGS "${BASE_CXXFLAGS} -fsanitize=address,leak,undefined")
  16. endif()
  17. set (CMAKE_CXX_FLAGS "${BASE_CXXFLAGS} $ENV{CXXFLAGS}")
  18. foreach (target ${TARGETS})
  19. add_executable (${target} "${target}.cc")
  20. add_test (${target} ${target})
  21. endforeach ()
  22. enable_testing ()
  23. message ("* C++ compiler is: ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_VERSION}")
  24. message ("* C++ flags are: ${CMAKE_CXX_FLAGS}")