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