| 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 | |
| Kevin Kane | 0ec1e68 | 2016-12-15 09:27:16 -0800 | [diff] [blame] | 5 | if(MSVC) |
| 6 | set(libs ${libs} bcrypt) |
| 7 | endif() |
| 8 | |
| Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 9 | set(executables_libs |
| Gilles Peskine | df6e84a | 2023-02-22 22:09:51 +0100 | [diff] [blame] | 10 | query_included_headers |
| Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 11 | selftest |
| 12 | udp_proxy |
| 13 | ) |
| Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 14 | |
| Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 15 | set(executables_mbedcrypto |
| 16 | benchmark |
| 17 | query_compile_time_config |
| 18 | zeroize |
| 19 | ) |
| Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 20 | |
| Andrzej Kurek | 0211c32 | 2018-03-15 05:16:24 -0400 | [diff] [blame] | 21 | if(TEST_CPP) |
| Gilles Peskine | 03ab544 | 2021-07-09 15:19:28 +0200 | [diff] [blame] | 22 | set(cpp_dummy_build_cpp "${CMAKE_CURRENT_BINARY_DIR}/cpp_dummy_build.cpp") |
| 23 | set(generate_cpp_dummy_build "${CMAKE_CURRENT_SOURCE_DIR}/generate_cpp_dummy_build.sh") |
| 24 | add_custom_command( |
| 25 | OUTPUT "${cpp_dummy_build_cpp}" |
| 26 | COMMAND "${generate_cpp_dummy_build}" "${cpp_dummy_build_cpp}" |
| 27 | DEPENDS "${generate_cpp_dummy_build}" |
| 28 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 29 | ) |
| 30 | add_executable(cpp_dummy_build "${cpp_dummy_build_cpp}") |
| 31 | target_include_directories(cpp_dummy_build PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) |
| 32 | target_link_libraries(cpp_dummy_build ${mbedcrypto_target}) |
| Andrzej Kurek | 0211c32 | 2018-03-15 05:16:24 -0400 | [diff] [blame] | 33 | endif() |
| 34 | |
| Gilles Peskine | f80a029 | 2021-11-04 15:18:00 +0100 | [diff] [blame] | 35 | if(USE_SHARED_MBEDTLS_LIBRARY AND |
| 36 | NOT ${CMAKE_SYSTEM_NAME} MATCHES "[Ww][Ii][Nn]") |
| Gilles Peskine | a7c247e | 2021-11-04 12:45:19 +0100 | [diff] [blame] | 37 | add_executable(dlopen "dlopen.c") |
| 38 | target_include_directories(dlopen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) |
| Gilles Peskine | 88e3e70 | 2021-11-10 19:10:27 +0100 | [diff] [blame] | 39 | target_link_libraries(dlopen ${CMAKE_DL_LIBS}) |
| Gilles Peskine | a7c247e | 2021-11-04 12:45:19 +0100 | [diff] [blame] | 40 | endif() |
| 41 | |
| David Horstmann | a8d1406 | 2021-10-20 17:14:23 +0100 | [diff] [blame] | 42 | if(GEN_FILES) |
| Manuel Pégourié-Gonnard | e90e405 | 2021-09-08 13:27:09 +0200 | [diff] [blame] | 43 | find_package(Perl REQUIRED) |
| Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 44 | |
| Manuel Pégourié-Gonnard | e90e405 | 2021-09-08 13:27:09 +0200 | [diff] [blame] | 45 | add_custom_command( |
| 46 | OUTPUT |
| 47 | ${CMAKE_CURRENT_BINARY_DIR}/query_config.c |
| 48 | COMMAND |
| 49 | ${PERL} |
| 50 | ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl |
| 51 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h |
| Ronald Cron | eab2055 | 2023-08-30 17:36:25 +0200 | [diff] [blame] | 52 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h |
| Manuel Pégourié-Gonnard | e90e405 | 2021-09-08 13:27:09 +0200 | [diff] [blame] | 53 | ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt |
| 54 | ${CMAKE_CURRENT_BINARY_DIR}/query_config.c |
| 55 | DEPENDS |
| Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 56 | ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/generate_query_config.pl |
| 57 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include/mbedtls/mbedtls_config.h |
| Ronald Cron | eab2055 | 2023-08-30 17:36:25 +0200 | [diff] [blame] | 58 | ${CMAKE_CURRENT_SOURCE_DIR}/../../include/psa/crypto_config.h |
| Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 59 | ${CMAKE_CURRENT_SOURCE_DIR}/../../scripts/data_files/query_config.fmt |
| Manuel Pégourié-Gonnard | e90e405 | 2021-09-08 13:27:09 +0200 | [diff] [blame] | 60 | ) |
| David Horstmann | d64f4b2 | 2021-10-20 12:29:47 +0100 | [diff] [blame] | 61 | # 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] | 62 | # https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#how-can-i-add-a-dependency-to-a-source-file-which-is-generated-in-a-subdirectory |
| 63 | add_custom_target(generate_query_config_c |
| 64 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) |
| 65 | else() |
| 66 | link_to_source(query_config.c) |
| 67 | endif() |
| Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 68 | |
| Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 69 | foreach(exe IN LISTS executables_libs executables_mbedcrypto) |
| David Brown | a8e309e | 2020-11-18 15:07:24 -0700 | [diff] [blame] | 70 | set(extra_sources "") |
| 71 | if(exe STREQUAL "query_compile_time_config") |
| 72 | list(APPEND extra_sources |
| Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 73 | ${CMAKE_CURRENT_SOURCE_DIR}/query_config.h |
| 74 | ${CMAKE_CURRENT_BINARY_DIR}/query_config.c) |
| David Brown | a8e309e | 2020-11-18 15:07:24 -0700 | [diff] [blame] | 75 | endif() |
| 76 | add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test> |
| 77 | ${extra_sources}) |
| Mateusz Starzyk | 1aec646 | 2021-02-08 15:34:42 +0100 | [diff] [blame] | 78 | target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) |
| Manuel Pégourié-Gonnard | 86cfa6c | 2021-05-14 10:07:33 +0200 | [diff] [blame] | 79 | if(exe STREQUAL "query_compile_time_config") |
| 80 | target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) |
| 81 | endif() |
| Manuel Pégourié-Gonnard | cb4137b | 2014-09-04 14:55:28 +0200 | [diff] [blame] | 82 | |
| Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 83 | # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3 |
| 84 | list(FIND executables_libs ${exe} exe_index) |
| 85 | if (${exe_index} GREATER -1) |
| 86 | target_link_libraries(${exe} ${libs}) |
| 87 | else() |
| Raef Coles | 995c66f | 2020-10-13 16:30:41 +0100 | [diff] [blame] | 88 | target_link_libraries(${exe} ${mbedcrypto_target}) |
| Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 89 | endif() |
| 90 | endforeach() |
| Andres Amaya Garcia | 5ab74a1 | 2017-10-24 21:10:45 +0100 | [diff] [blame] | 91 | |
| Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 92 | install(TARGETS ${executables_libs} ${executables_mbedcrypto} |
| Paul Bakker | 547f73d | 2011-01-05 15:07:54 +0000 | [diff] [blame] | 93 | DESTINATION "bin" |
| 94 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |