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