cmake_subproject.c 1.6 KB

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