SgGNUSource.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #.rst:
  2. # SgGNUSource
  3. # -----------
  4. #
  5. # `_GNU_SOURCE` checking.
  6. #
  7. # Checks if `_GNU_SOURCE` is available.
  8. #
  9. # ::
  10. #
  11. # _GNU_SOURCE - True if `_GNU_SOURCE` is available. If so, a `-D_GNU_SOURCE` is
  12. # declared too.
  13. # _
  14. # ___ __ _ __ _ _ _(_)
  15. # / __|/ _` |/ _` | | | | |
  16. # \__ \ (_| | (_| | |_| | |
  17. # |___/\__,_|\__, |\__,_|_|
  18. # |___/
  19. #
  20. # Cross-platform library which helps to develop web servers or frameworks.
  21. #
  22. # Copyright (C) 2016-2019 Silvio Clecio <[email protected]>
  23. #
  24. # Sagui library is free software; you can redistribute it and/or
  25. # modify it under the terms of the GNU Lesser General Public
  26. # License as published by the Free Software Foundation; either
  27. # version 2.1 of the License, or (at your option) any later version.
  28. #
  29. # Sagui library is distributed in the hope that it will be useful,
  30. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  31. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  32. # Lesser General Public License for more details.
  33. #
  34. # You should have received a copy of the GNU Lesser General Public
  35. # License along with Sagui library; if not, write to the Free Software
  36. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  37. #
  38. if(__SG_GNU_SOURCE_INCLUDED)
  39. return()
  40. endif()
  41. set(__SG_GNU_SOURCE_INCLUDED ON)
  42. include(CheckSymbolExists)
  43. if(NOT _GNU_SOURCE)
  44. check_symbol_exists(__GNU_LIBRARY__ "features.h" _GNU_SOURCE)
  45. if(NOT _GNU_SOURCE)
  46. unset(_GNU_SOURCE CACHE)
  47. check_symbol_exists(_GNU_SOURCE "features.h" _GNU_SOURCE)
  48. endif()
  49. endif()
  50. if(_GNU_SOURCE)
  51. add_definitions(-D_GNU_SOURCE)
  52. endif()