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 | |
| 5 | if(USE_PKCS11_HELPER_LIBRARY) |
| 6 | set(libs ${libs} pkcs11-helper) |
| 7 | endif(USE_PKCS11_HELPER_LIBRARY) |
| 8 | |
Paul Bakker | 92eeea4 | 2012-07-03 15:10:33 +0000 | [diff] [blame] | 9 | if(ENABLE_ZLIB_SUPPORT) |
| 10 | set(libs ${libs} ${ZLIB_LIBRARIES}) |
| 11 | endif(ENABLE_ZLIB_SUPPORT) |
| 12 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 13 | set(executables_libs |
| 14 | selftest |
| 15 | udp_proxy |
| 16 | ) |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 17 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 18 | set(executables_mbedcrypto |
| 19 | benchmark |
| 20 | query_compile_time_config |
| 21 | zeroize |
| 22 | ) |
Paul Bakker | 367dae4 | 2009-06-28 21:50:27 +0000 | [diff] [blame] | 23 | |
Andrzej Kurek | 0211c32 | 2018-03-15 05:16:24 -0400 | [diff] [blame] | 24 | if(TEST_CPP) |
Gilles Peskine | 9b35640 | 2021-07-09 15:19:28 +0200 | [diff] [blame] | 25 | set(cpp_dummy_build_cpp "${CMAKE_CURRENT_BINARY_DIR}/cpp_dummy_build.cpp") |
| 26 | set(generate_cpp_dummy_build "${CMAKE_CURRENT_SOURCE_DIR}/generate_cpp_dummy_build.sh") |
| 27 | add_custom_command( |
| 28 | OUTPUT "${cpp_dummy_build_cpp}" |
| 29 | COMMAND "${generate_cpp_dummy_build}" "${cpp_dummy_build_cpp}" |
| 30 | DEPENDS "${generate_cpp_dummy_build}" |
| 31 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 32 | ) |
| 33 | add_executable(cpp_dummy_build "${cpp_dummy_build_cpp}") |
| 34 | target_include_directories(cpp_dummy_build PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) |
| 35 | target_link_libraries(cpp_dummy_build ${mbedcrypto_target}) |
Andrzej Kurek | 0211c32 | 2018-03-15 05:16:24 -0400 | [diff] [blame] | 36 | endif() |
| 37 | |
Gilles Peskine | 507c787 | 2021-11-04 15:18:00 +0100 | [diff] [blame] | 38 | if(USE_SHARED_MBEDTLS_LIBRARY AND |
| 39 | NOT ${CMAKE_SYSTEM_NAME} MATCHES "[Ww][Ii][Nn]") |
Gilles Peskine | e943353 | 2021-11-04 12:45:19 +0100 | [diff] [blame] | 40 | add_executable(dlopen "dlopen.c") |
| 41 | target_include_directories(dlopen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) |
Gilles Peskine | 99d8486 | 2021-11-10 19:10:27 +0100 | [diff] [blame] | 42 | target_link_libraries(dlopen ${CMAKE_DL_LIBS}) |
Gilles Peskine | e943353 | 2021-11-04 12:45:19 +0100 | [diff] [blame] | 43 | endif() |
| 44 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 45 | foreach(exe IN LISTS executables_libs executables_mbedcrypto) |
David Brown | a8e309e | 2020-11-18 15:07:24 -0700 | [diff] [blame] | 46 | set(extra_sources "") |
| 47 | if(exe STREQUAL "query_compile_time_config") |
| 48 | list(APPEND extra_sources |
| 49 | ${CMAKE_CURRENT_SOURCE_DIR}/query_config.c) |
| 50 | endif() |
| 51 | add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test> |
| 52 | ${extra_sources}) |
Manuel Pégourié-Gonnard | cb4137b | 2014-09-04 14:55:28 +0200 | [diff] [blame] | 53 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 54 | # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3 |
| 55 | list(FIND executables_libs ${exe} exe_index) |
| 56 | if (${exe_index} GREATER -1) |
| 57 | target_link_libraries(${exe} ${libs}) |
| 58 | else() |
Raef Coles | 995c66f | 2020-10-13 16:30:41 +0100 | [diff] [blame] | 59 | target_link_libraries(${exe} ${mbedcrypto_target}) |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 60 | endif() |
| 61 | endforeach() |
Andres Amaya Garcia | 5ab74a1 | 2017-10-24 21:10:45 +0100 | [diff] [blame] | 62 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 63 | install(TARGETS ${executables_libs} ${executables_mbedcrypto} |
Paul Bakker | 547f73d | 2011-01-05 15:07:54 +0000 | [diff] [blame] | 64 | DESTINATION "bin" |
| 65 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |