unity_build.cmake 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Macro utility to clone the Unity submodule.
  2. macro( clone_unity )
  3. find_package( Git REQUIRED )
  4. message( "Cloning submodule Unity." )
  5. execute_process( COMMAND rm -rf ${UNITY_DIR}
  6. COMMAND ${GIT_EXECUTABLE} submodule update --checkout --init --recursive ${UNITY_DIR}
  7. WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  8. RESULT_VARIABLE UNITY_CLONE_RESULT )
  9. if( NOT ${UNITY_CLONE_RESULT} STREQUAL "0" )
  10. message( FATAL_ERROR "Failed to clone Unity submodule." )
  11. endif()
  12. endmacro()
  13. # Macro utility to add library targets for Unity and Unity to build configuration.
  14. macro( add_unity_targets )
  15. # Build Configuration for Unity and Unity libraries.
  16. list( APPEND UNITY_INCLUDE_DIRS
  17. "${UNITY_DIR}/src/"
  18. "${UNITY_DIR}/extras/fixture/src"
  19. "${UNITY_DIR}/extras/memory/src"
  20. )
  21. add_library( unity STATIC
  22. "${UNITY_DIR}/src/unity.c"
  23. "${UNITY_DIR}/extras/fixture/src/unity_fixture.c"
  24. "${UNITY_DIR}/extras/memory/src/unity_memory.c"
  25. )
  26. set_target_properties( unity PROPERTIES
  27. ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
  28. POSITION_INDEPENDENT_CODE ON
  29. )
  30. target_include_directories( unity PUBLIC
  31. ${UNITY_INCLUDE_DIRS}
  32. )
  33. endmacro()