CMakeLists.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Copyright (c) 2017, Branden Archer
  2. # All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions are met:
  6. # * Redistributions of source code must retain the above copyright
  7. # notice, this list of conditions and the following disclaimer.
  8. # * Redistributions in binary form must reproduce the above copyright
  9. # notice, this list of conditions and the following disclaimer in the
  10. # documentation and/or other materials provided with the distribution.
  11. # * Neither the name of this project nor the names of its contributors may
  12. # be used to endorse or promote products derived from this software without
  13. # specific prior written permission.
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  16. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. # DISCLAIMED. IN NO EVENT SHALL Branden Archer BE LIABLE FOR ANY
  19. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. project(money C)
  26. cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
  27. set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
  28. ###############################################################################
  29. # Set build features
  30. set(CMAKE_BUILD_TYPE Debug)
  31. ###############################################################################
  32. include(CheckCSourceCompiles)
  33. include(CheckCSourceRuns)
  34. include(CheckFunctionExists)
  35. include(CheckIncludeFile)
  36. include(CheckIncludeFiles)
  37. include(CheckLibraryExists)
  38. include(CheckSymbolExists)
  39. include(CheckTypeSize)
  40. ###############################################################################
  41. # Check headers
  42. set(INCLUDES "")
  43. macro(ck_check_include_file header var)
  44. check_include_files("${INCLUDES};${header}" ${var})
  45. if(${var})
  46. set(INCLUDES ${INCLUDES} ${header})
  47. endif(${var})
  48. endmacro(ck_check_include_file)
  49. ck_check_include_file("stdlib.h" HAVE_STDLIB_H)
  50. ###############################################################################
  51. # Check functions
  52. # (Nothing to check for the money example)
  53. ###############################################################################
  54. # Check defines
  55. # (Nothing to check for the money example)
  56. ###############################################################################
  57. # Check struct members
  58. # (Nothing to check for the money example)
  59. ###############################################################################
  60. # Check for integer types
  61. # (The following are used in check.h. Regardless if they are used in
  62. # the project, they will need to be checked in order to use Check).
  63. check_type_size(intmax_t INTMAX_T)
  64. check_type_size(uintmax_t UINTMAX_T)
  65. check_type_size(pid_t PID_T)
  66. if(NOT HAVE_PID_T)
  67. if(WIN32)
  68. set(pid_t "int")
  69. else(WIN32)
  70. MESSAGE(FATAL_ERROR "pid_t doesn't exist on this platform?")
  71. endif(WIN32)
  72. endif(NOT HAVE_PID_T)
  73. ###############################################################################
  74. # Check libraries
  75. ###############################################################################
  76. # Generate "config.h" from "cmake/config.h.cmake"
  77. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in
  78. ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  79. include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
  80. add_definitions(-DHAVE_CONFIG_H)
  81. set(CONFIG_HEADER ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  82. ###############################################################################
  83. # Subdirectories
  84. add_subdirectory(src)
  85. add_subdirectory(tests)
  86. ###############################################################################
  87. # Unit tests
  88. enable_testing()
  89. add_test(NAME check_money COMMAND check_money)