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