Paul Bakker | b06819b | 2011-01-18 16:18:38 +0000 | [diff] [blame] | 1 | set(libs |
Raef Coles | 995c66f | 2020-10-13 16:30:41 +0100 | [diff] [blame] | 2 | ${mbedtls_target} |
Paul Bakker | b06819b | 2011-01-18 16:18:38 +0000 | [diff] [blame] | 3 | ) |
| 4 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 5 | set(executables_libs |
Gilles Peskine | 33406b6 | 2023-11-02 18:48:39 +0100 | [diff] [blame] | 6 | metatest |
Gilles Peskine | df6e84a | 2023-02-22 22:09:51 +0100 | [diff] [blame] | 7 | query_included_headers |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 8 | selftest |
| 9 | udp_proxy |
| 10 | ) |
Gilles Peskine | bb47c73 | 2024-09-14 12:13:16 +0200 | [diff] [blame] | 11 | add_dependencies(${programs_target} ${executables_libs}) |
Gilles Peskine | 7215b1e | 2024-09-14 12:18:00 +0200 | [diff] [blame] | 12 | add_dependencies(${ssl_opt_target} udp_proxy) |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 13 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 14 | set(executables_mbedcrypto |
| 15 | benchmark |
| 16 | query_compile_time_config |
| 17 | zeroize |
| 18 | ) |
Gilles Peskine | bb47c73 | 2024-09-14 12:13:16 +0200 | [diff] [blame] | 19 | add_dependencies(${programs_target} ${executables_mbedcrypto}) |
Gilles Peskine | 7215b1e | 2024-09-14 12:18:00 +0200 | [diff] [blame] | 20 | add_dependencies(${ssl_opt_target} query_compile_time_config) |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 21 | |
Andrzej Kurek | 0211c32 | 2018-03-15 05:16:24 -0400 | [diff] [blame] | 22 | if(TEST_CPP) |
Gilles Peskine | 03ab544 | 2021-07-09 15:19:28 +0200 | [diff] [blame] | 23 | set(cpp_dummy_build_cpp "${CMAKE_CURRENT_BINARY_DIR}/cpp_dummy_build.cpp") |
| 24 | set(generate_cpp_dummy_build "${CMAKE_CURRENT_SOURCE_DIR}/generate_cpp_dummy_build.sh") |
| 25 | add_custom_command( |
| 26 | OUTPUT "${cpp_dummy_build_cpp}" |
| 27 | COMMAND "${generate_cpp_dummy_build}" "${cpp_dummy_build_cpp}" |
| 28 | DEPENDS "${generate_cpp_dummy_build}" |
| 29 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 30 | ) |
| 31 | add_executable(cpp_dummy_build "${cpp_dummy_build_cpp}") |
| 32 | target_include_directories(cpp_dummy_build PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) |
Paul Elliott | 4068c7e | 2023-12-15 17:14:34 +0000 | [diff] [blame] | 33 | target_link_libraries(cpp_dummy_build ${mbedcrypto_target} ${CMAKE_THREAD_LIBS_INIT}) |
Andrzej Kurek | 0211c32 | 2018-03-15 05:16:24 -0400 | [diff] [blame] | 34 | endif() |
| 35 | |
Gilles Peskine | f80a029 | 2021-11-04 15:18:00 +0100 | [diff] [blame] | 36 | if(USE_SHARED_MBEDTLS_LIBRARY AND |
| 37 | NOT ${CMAKE_SYSTEM_NAME} MATCHES "[Ww][Ii][Nn]") |
Gilles Peskine | a7c247e | 2021-11-04 12:45:19 +0100 | [diff] [blame] | 38 | add_executable(dlopen "dlopen.c") |
| 39 | target_include_directories(dlopen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) |
Gilles Peskine | 88e3e70 | 2021-11-10 19:10:27 +0100 | [diff] [blame] | 40 | target_link_libraries(dlopen ${CMAKE_DL_LIBS}) |
Gilles Peskine | a7c247e | 2021-11-04 12:45:19 +0100 | [diff] [blame] | 41 | endif() |
| 42 | |
David Horstmann | a8d1406 | 2021-10-20 17:14:23 +0100 | [diff] [blame] | 43 | if(GEN_FILES) |
Manuel Pégourié-Gonnard | e90e405 | 2021-09-08 13:27:09 +0200 | [diff] [blame] | 44 | find_package(Perl REQUIRED) |
Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 45 | |
Manuel Pégourié-Gonnard | e90e405 | 2021-09-08 13:27:09 +0200 | [diff] [blame] | 46 | add_custom_command( |
| 47 | OUTPUT |
| 48 | ${CMAKE_CURRENT_BINARY_DIR}/query_config.c |
| 49 | COMMAND |
| 50 | ${PERL} |
| 51 | ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl |
| 52 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h |
Ronald Cron | eab2055 | 2023-08-30 17:36:25 +0200 | [diff] [blame] | 53 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h |
Manuel Pégourié-Gonnard | e90e405 | 2021-09-08 13:27:09 +0200 | [diff] [blame] | 54 | ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt |
| 55 | ${CMAKE_CURRENT_BINARY_DIR}/query_config.c |
| 56 | DEPENDS |
Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 57 | ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl |
| 58 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h |
Ronald Cron | eab2055 | 2023-08-30 17:36:25 +0200 | [diff] [blame] | 59 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h |
Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 60 | ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt |
Manuel Pégourié-Gonnard | e90e405 | 2021-09-08 13:27:09 +0200 | [diff] [blame] | 61 | ) |
David Horstmann | d64f4b2 | 2021-10-20 12:29:47 +0100 | [diff] [blame] | 62 | # this file will also be used in another directory, so create a target, see |
Manuel Pégourié-Gonnard | e90e405 | 2021-09-08 13:27:09 +0200 | [diff] [blame] | 63 | # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory |
| 64 | add_custom_target(generate_query_config_c |
| 65 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) |
| 66 | else() |
| 67 | link_to_source(query_config.c) |
| 68 | endif() |
Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 69 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 70 | foreach(exe IN LISTS executables_libs executables_mbedcrypto) |
Harry Ramsey | 061e0f5 | 2025-02-17 11:59:45 +0000 | [diff] [blame] | 71 | set(source ${exe}.c) |
David Brown | a8e309e | 2020-11-18 15:07:24 -0700 | [diff] [blame] | 72 | set(extra_sources "") |
Harry Ramsey | 061e0f5 | 2025-02-17 11:59:45 +0000 | [diff] [blame] | 73 | if(NOT EXISTS ${source} AND |
| 74 | EXISTS ${MBEDTLS_FRAMEWORK_DIR}/tests/programs/${source}) |
| 75 | set(source ${MBEDTLS_FRAMEWORK_DIR}/tests/programs/${source}) |
| 76 | endif() |
| 77 | |
David Brown | a8e309e | 2020-11-18 15:07:24 -0700 | [diff] [blame] | 78 | if(exe STREQUAL "query_compile_time_config") |
| 79 | list(APPEND extra_sources |
Harry Ramsey | 061e0f5 | 2025-02-17 11:59:45 +0000 | [diff] [blame] | 80 | ${MBEDTLS_FRAMEWORK_DIR}/tests/programs/query_config.h |
Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 81 | ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) |
David Brown | a8e309e | 2020-11-18 15:07:24 -0700 | [diff] [blame] | 82 | endif() |
Harry Ramsey | 061e0f5 | 2025-02-17 11:59:45 +0000 | [diff] [blame] | 83 | add_executable(${exe} ${source} $<TARGET_OBJECTS:mbedtls_test> |
David Brown | a8e309e | 2020-11-18 15:07:24 -0700 | [diff] [blame] | 84 | ${extra_sources}) |
Harry Ramsey | 061e0f5 | 2025-02-17 11:59:45 +0000 | [diff] [blame] | 85 | target_include_directories(${exe} PRIVATE ${MBEDTLS_FRAMEWORK_DIR}/tests/include) |
| 86 | target_include_directories(${exe} PRIVATE ${MBEDTLS_FRAMEWORK_DIR}/tests/programs) |
Gilles Peskine | a1023e2 | 2023-11-03 19:16:56 +0100 | [diff] [blame] | 87 | target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../library) |
Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 88 | if(exe STREQUAL "query_compile_time_config") |
| 89 | target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) |
| 90 | endif() |
Manuel Pégourié-Gonnard | cb4137b | 2014-09-04 14:55:28 +0200 | [diff] [blame] | 91 | |
David Horstmann | c2ab398 | 2024-01-17 12:25:19 +0000 | [diff] [blame] | 92 | # Request C11, required for memory poisoning |
| 93 | set_target_properties(${exe} PROPERTIES C_STANDARD 11) |
| 94 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 95 | # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3 |
| 96 | list(FIND executables_libs ${exe} exe_index) |
| 97 | if (${exe_index} GREATER -1) |
Paul Elliott | 4068c7e | 2023-12-15 17:14:34 +0000 | [diff] [blame] | 98 | target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT}) |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 99 | else() |
Paul Elliott | 4068c7e | 2023-12-15 17:14:34 +0000 | [diff] [blame] | 100 | target_link_libraries(${exe} ${mbedcrypto_target} ${CMAKE_THREAD_LIBS_INIT}) |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 101 | endif() |
| 102 | endforeach() |
Andres Amaya Garcia | 5ab74a1 | 2017-10-24 21:10:45 +0100 | [diff] [blame] | 103 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 104 | install(TARGETS ${executables_libs} ${executables_mbedcrypto} |
Paul Bakker | 547f73d | 2011-01-05 15:07:54 +0000 | [diff] [blame] | 105 | DESTINATION "bin" |
| 106 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |