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 | e943353 | 2021-11-04 12:45:19 +0100 | [diff] [blame^] | 38 | if(USE_SHARED_MBEDTLS_LIBRARY) |
| 39 | add_executable(dlopen "dlopen.c") |
| 40 | target_include_directories(dlopen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include) |
| 41 | target_link_libraries(dlopen "-ldl") |
| 42 | endif() |
| 43 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 44 | foreach(exe IN LISTS executables_libs executables_mbedcrypto) |
David Brown | a8e309e | 2020-11-18 15:07:24 -0700 | [diff] [blame] | 45 | set(extra_sources "") |
| 46 | if(exe STREQUAL "query_compile_time_config") |
| 47 | list(APPEND extra_sources |
| 48 | ${CMAKE_CURRENT_SOURCE_DIR}/query_config.c) |
| 49 | endif() |
| 50 | add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test> |
| 51 | ${extra_sources}) |
Manuel Pégourié-Gonnard | cb4137b | 2014-09-04 14:55:28 +0200 | [diff] [blame] | 52 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 53 | # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3 |
| 54 | list(FIND executables_libs ${exe} exe_index) |
| 55 | if (${exe_index} GREATER -1) |
| 56 | target_link_libraries(${exe} ${libs}) |
| 57 | else() |
Raef Coles | 995c66f | 2020-10-13 16:30:41 +0100 | [diff] [blame] | 58 | target_link_libraries(${exe} ${mbedcrypto_target}) |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 59 | endif() |
| 60 | endforeach() |
Andres Amaya Garcia | 5ab74a1 | 2017-10-24 21:10:45 +0100 | [diff] [blame] | 61 | |
Ronald Cron | bfd45f1 | 2020-06-05 11:15:31 +0200 | [diff] [blame] | 62 | install(TARGETS ${executables_libs} ${executables_mbedcrypto} |
Paul Bakker | 547f73d | 2011-01-05 15:07:54 +0000 | [diff] [blame] | 63 | DESTINATION "bin" |
| 64 | PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |