2
0

cmake_package.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Simple program to test that Mbed TLS builds correctly as a CMake package.
  3. *
  4. * Copyright The Mbed TLS Contributors
  5. * SPDX-License-Identifier: Apache-2.0
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. #include "mbedtls/build_info.h"
  20. #if defined(MBEDTLS_PLATFORM_C)
  21. #include "mbedtls/platform.h"
  22. #else
  23. #include <stdio.h>
  24. #include <stdlib.h>
  25. #define mbedtls_fprintf fprintf
  26. #define mbedtls_printf printf
  27. #define mbedtls_exit exit
  28. #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
  29. #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
  30. #endif /* MBEDTLS_PLATFORM_C */
  31. #include "mbedtls/version.h"
  32. /* The main reason to build this is for testing the CMake build, so the program
  33. * doesn't need to do very much. It calls a single library function to ensure
  34. * linkage works, but that is all. */
  35. int main()
  36. {
  37. /* This version string is 18 bytes long, as advised by version.h. */
  38. char version[18];
  39. mbedtls_version_get_string_full( version );
  40. mbedtls_printf( "Built against %s\n", version );
  41. return( 0 );
  42. }