You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

89 lines
2.6 KiB

  1. project(cmocka C)
  2. # Required cmake version
  3. cmake_minimum_required(VERSION 2.6.0)
  4. # global needed variables
  5. set(APPLICATION_NAME ${PROJECT_NAME})
  6. set(APPLICATION_VERSION_MAJOR "1")
  7. set(APPLICATION_VERSION_MINOR "1")
  8. set(APPLICATION_VERSION_PATCH "1")
  9. set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
  10. # SOVERSION scheme: CURRENT.AGE.REVISION
  11. # If there was an incompatible interface change:
  12. # Increment CURRENT. Set AGE and REVISION to 0
  13. # If there was a compatible interface change:
  14. # Increment AGE. Set REVISION to 0
  15. # If the source code was changed, but there were no interface changes:
  16. # Increment REVISION.
  17. set(LIBRARY_VERSION "0.4.1")
  18. set(LIBRARY_SOVERSION "0")
  19. # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
  20. set(CMAKE_MODULE_PATH
  21. ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules
  22. )
  23. # add definitions
  24. include(DefineCMakeDefaults)
  25. include(DefinePlatformDefaults)
  26. include(DefineCompilerFlags)
  27. include(DefineInstallationPaths)
  28. include(DefineOptions.cmake)
  29. include(CPackConfig.cmake)
  30. include(CheckSymbolExists)
  31. # disallow in-source build
  32. include(MacroEnsureOutOfSourceBuild)
  33. macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
  34. # config.h checks
  35. include(ConfigureChecks.cmake)
  36. configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  37. # MinGW DLL Naming Workaround
  38. if (MINGW)
  39. set(CMAKE_SHARED_LIBRARY_PREFIX "")
  40. endif (MINGW)
  41. # check subdirectories
  42. add_subdirectory(doc)
  43. add_subdirectory(include)
  44. add_subdirectory(src)
  45. if (UNIT_TESTING)
  46. include(AddCMockaTest)
  47. add_subdirectory(tests)
  48. endif (UNIT_TESTING)
  49. add_subdirectory(example)
  50. # pkg-config file
  51. configure_file(cmocka.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmocka.pc)
  52. install(
  53. FILES
  54. ${CMAKE_CURRENT_BINARY_DIR}/cmocka.pc
  55. DESTINATION
  56. ${LIB_INSTALL_DIR}/pkgconfig
  57. COMPONENT
  58. pkgconfig
  59. )
  60. # cmake config files
  61. set(CMOCKA_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
  62. configure_file(${PROJECT_NAME}-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake @ONLY)
  63. configure_file(${PROJECT_NAME}-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake @ONLY)
  64. install(
  65. FILES
  66. ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
  67. ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
  68. DESTINATION
  69. ${CMAKE_INSTALL_DIR}/${PROJECT_NAME}
  70. COMPONENT
  71. devel
  72. )