Inital commit
This commit is contained in:
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
# ==============================================================================
|
||||
# Find CMock
|
||||
# ==============================================================================
|
||||
# This module fetches the CMock mocking framework (depends on Unity).
|
||||
#
|
||||
# Targets provided:
|
||||
# CMock::CMock - The CMock library target
|
||||
#
|
||||
# Variables set:
|
||||
# CMock_FOUND - TRUE if CMock is available
|
||||
# CMock_LIBRARIES - The CMock library target (CMock::CMock)
|
||||
# CMock_INCLUDE_DIR - Include directories for CMock
|
||||
# CMock_VERSION - Version of CMock (if available)
|
||||
#
|
||||
# Generator variables (set when Ruby is found):
|
||||
# CMOCK_SCRIPT - Path to lib/cmock.rb
|
||||
# RUBY_EXECUTABLE - Path to ruby interpreter
|
||||
# ==============================================================================
|
||||
|
||||
if (DEFINED _FINDCMOCK_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(_FINDCMOCK_INCLUDED TRUE)
|
||||
|
||||
find_package(Unity REQUIRED)
|
||||
|
||||
if (DEFINED CMock_FIND_VERSION AND NOT CMock_FIND_VERSION STREQUAL "")
|
||||
set(CMOCK_VERSION "${CMock_FIND_VERSION}")
|
||||
else()
|
||||
set(CMOCK_VERSION "2.6.0")
|
||||
endif()
|
||||
|
||||
message(STATUS "Fetching CMock ${CMOCK_VERSION}")
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
cmock
|
||||
URL https://github.com/ThrowTheSwitch/CMock/archive/refs/tags/v${CMOCK_VERSION}.zip
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
||||
)
|
||||
|
||||
# CMock uses Meson — bypass its build system and compile src/cmock.c directly.
|
||||
# FetchContent_MakeAvailable cannot be used here (no CMakeLists.txt in CMock),
|
||||
# so we call FetchContent_Populate directly and opt into the old policy.
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0169 OLD)
|
||||
FetchContent_GetProperties(cmock)
|
||||
if (NOT cmock_POPULATED)
|
||||
FetchContent_Populate(cmock)
|
||||
endif()
|
||||
cmake_policy(POP)
|
||||
|
||||
# The Ruby generator expects vendor/unity/auto/type_sanitizer.rb — populate
|
||||
# it from the Unity source we already have rather than needing a git submodule
|
||||
set(_cmock_vendor_auto "${cmock_SOURCE_DIR}/vendor/unity/auto")
|
||||
if (NOT EXISTS "${_cmock_vendor_auto}/type_sanitizer.rb")
|
||||
file(MAKE_DIRECTORY "${_cmock_vendor_auto}")
|
||||
file(COPY "${unity_SOURCE_DIR}/auto/" DESTINATION "${_cmock_vendor_auto}")
|
||||
endif()
|
||||
|
||||
if (NOT TARGET cmock)
|
||||
add_library(cmock STATIC "${cmock_SOURCE_DIR}/src/cmock.c")
|
||||
target_include_directories(cmock PUBLIC
|
||||
"${cmock_SOURCE_DIR}/src"
|
||||
"${unity_SOURCE_DIR}/src"
|
||||
)
|
||||
target_link_libraries(cmock PUBLIC unity)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET CMock::CMock)
|
||||
add_library(CMock::CMock ALIAS cmock)
|
||||
endif()
|
||||
|
||||
set(CMock_FOUND TRUE)
|
||||
set(CMock_LIBRARIES CMock::CMock)
|
||||
set(CMock_VERSION "${CMOCK_VERSION}")
|
||||
set(CMock_INCLUDE_DIR "${cmock_SOURCE_DIR}/src")
|
||||
set(CMOCK_SCRIPT "${cmock_SOURCE_DIR}/lib/cmock.rb" CACHE FILEPATH "Path to CMock Ruby generator")
|
||||
|
||||
if (CMock_INCLUDE_DIR AND TARGET cmock)
|
||||
set_target_properties(cmock PROPERTIES
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${CMock_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
find_program(RUBY_EXECUTABLE ruby)
|
||||
if (NOT RUBY_EXECUTABLE)
|
||||
message(WARNING "Ruby not found — CMock code generation unavailable")
|
||||
endif()
|
||||
|
||||
set(CMOCK_LICENSE_FILE "${cmock_SOURCE_DIR}/LICENSE.txt" CACHE FILEPATH "Path to CMock license file")
|
||||
Vendored
+58
@@ -0,0 +1,58 @@
|
||||
# ==============================================================================
|
||||
# Find Unity
|
||||
# ==============================================================================
|
||||
# This module fetches the Unity unit testing framework.
|
||||
#
|
||||
# Targets provided:
|
||||
# Unity::Unity - The Unity library target
|
||||
#
|
||||
# Variables set:
|
||||
# Unity_FOUND - TRUE if Unity is available
|
||||
# Unity_LIBRARIES - The Unity library target (Unity::Unity)
|
||||
# Unity_INCLUDE_DIR - Include directories for Unity
|
||||
# Unity_VERSION - Version of Unity (if available)
|
||||
# ==============================================================================
|
||||
|
||||
if (DEFINED _FINDUNITY_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(_FINDUNITY_INCLUDED TRUE)
|
||||
|
||||
if (DEFINED Unity_FIND_VERSION AND NOT Unity_FIND_VERSION STREQUAL "")
|
||||
set(UNITY_VERSION "${Unity_FIND_VERSION}")
|
||||
else()
|
||||
set(UNITY_VERSION "2.6.1")
|
||||
endif()
|
||||
|
||||
message(STATUS "Fetching Unity ${UNITY_VERSION}")
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(
|
||||
unity
|
||||
URL https://github.com/ThrowTheSwitch/Unity/archive/refs/tags/v${UNITY_VERSION}.zip
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
||||
)
|
||||
|
||||
FetchContent_MakeAvailable(unity)
|
||||
|
||||
if (NOT TARGET Unity::Unity)
|
||||
if (TARGET unity)
|
||||
add_library(Unity::Unity ALIAS unity)
|
||||
else()
|
||||
message(FATAL_ERROR "Could not fetch Unity; no target unity or Unity::Unity available")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(Unity_FOUND TRUE)
|
||||
set(Unity_LIBRARIES Unity::Unity)
|
||||
set(Unity_VERSION "${UNITY_VERSION}")
|
||||
set(Unity_INCLUDE_DIR "${unity_SOURCE_DIR}/src")
|
||||
|
||||
if (Unity_INCLUDE_DIR AND TARGET unity)
|
||||
set_target_properties(unity PROPERTIES
|
||||
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${Unity_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(UNITY_LICENSE_FILE "${unity_SOURCE_DIR}/LICENSE.txt" CACHE FILEPATH "Path to Unity license file")
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
# ==============================================================================
|
||||
# Compiler Flags
|
||||
# ==============================================================================
|
||||
# Sets BASE_OPTIONS (warning flags) and BASE_DEFINITIONS.
|
||||
# Apply per-target via target_compile_options / target_compile_definitions
|
||||
# to avoid polluting fetched dependencies.
|
||||
#
|
||||
# Requires: Platform.cmake (for IS_CLANG_OR_GCC / IS_MSVC)
|
||||
# ==============================================================================
|
||||
|
||||
set(BASE_DEFINITIONS "")
|
||||
set(BASE_LIBRARIES "")
|
||||
|
||||
set(BASE_OPTIONS "")
|
||||
if (IS_CLANG_OR_GCC)
|
||||
set(BASE_OPTIONS
|
||||
"-Wall"
|
||||
"-Wextra"
|
||||
"-Werror"
|
||||
)
|
||||
elseif (IS_MSVC)
|
||||
set(BASE_OPTIONS
|
||||
"/W4"
|
||||
"/WX"
|
||||
"/utf-8"
|
||||
)
|
||||
endif()
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
# ==============================================================================
|
||||
# IDE Integration
|
||||
# ==============================================================================
|
||||
# Groups dependency targets into folders for Visual Studio / Xcode.
|
||||
# Has no effect on the build.
|
||||
# ==============================================================================
|
||||
|
||||
function(set_target_folder target folder)
|
||||
if (TARGET ${target})
|
||||
set_target_properties(${target} PROPERTIES FOLDER ${folder})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if (CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR MATCHES "Xcode")
|
||||
set_target_folder(unity deps)
|
||||
set_target_folder(cmock deps)
|
||||
endif()
|
||||
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
# ==============================================================================
|
||||
# Platform Detection
|
||||
# ==============================================================================
|
||||
# This module detects the current platform and compiler, setting IS_* variables
|
||||
# that can be used throughout the build system for conditional logic.
|
||||
#
|
||||
# Compiler flags set:
|
||||
# IS_CLANG_OR_GCC - TRUE if using Clang or GCC compiler
|
||||
# IS_MSVC - TRUE if using Microsoft Visual C++ compiler
|
||||
#
|
||||
# Platform flags set:
|
||||
# IS_WINDOWS - TRUE if building for Windows
|
||||
# IS_LINUX - TRUE if building for Linux
|
||||
# IS_MACOS - TRUE if building for macOS
|
||||
# IS_IOS - TRUE if building for iOS
|
||||
# IS_ANDROID - TRUE if building for Android
|
||||
# IS_EMSCRIPTEN - TRUE if building for WebAssembly via Emscripten
|
||||
# ==============================================================================
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Compiler Detection
|
||||
# ------------------------------------------------------------------------------
|
||||
set(IS_CLANG_OR_GCC FALSE)
|
||||
set(IS_MSVC FALSE)
|
||||
|
||||
if(MSVC)
|
||||
set(IS_MSVC TRUE)
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
|
||||
set(IS_CLANG_OR_GCC TRUE)
|
||||
endif()
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Platform Detection
|
||||
# ------------------------------------------------------------------------------
|
||||
set(IS_WINDOWS FALSE)
|
||||
set(IS_LINUX FALSE)
|
||||
set(IS_MACOS FALSE)
|
||||
set(IS_IOS FALSE)
|
||||
set(IS_ANDROID FALSE)
|
||||
set(IS_EMSCRIPTEN FALSE)
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
message(STATUS "Platform: Emscripten")
|
||||
set(IS_EMSCRIPTEN TRUE)
|
||||
elseif(ANDROID)
|
||||
message(STATUS "Platform: Android")
|
||||
set(IS_ANDROID TRUE)
|
||||
elseif(APPLE)
|
||||
if(IOS)
|
||||
message(STATUS "Platform: iOS")
|
||||
set(IS_IOS TRUE)
|
||||
else()
|
||||
message(STATUS "Platform: macOS")
|
||||
set(IS_MACOS TRUE)
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
message(STATUS "Platform: Windows")
|
||||
set(IS_WINDOWS TRUE)
|
||||
elseif(UNIX)
|
||||
message(STATUS "Platform: Linux")
|
||||
set(IS_LINUX TRUE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown platform!")
|
||||
endif()
|
||||
Reference in New Issue
Block a user