blob: 807d1bc10b741a8bc362bfb8bf2ccd2b3fcff459 [file] [log] [blame]
Paul Bakkerb06819b2011-01-18 16:18:38 +00001set(libs
Raef Coles995c66f2020-10-13 16:30:41 +01002 ${mbedtls_target}
Paul Bakkerb06819b2011-01-18 16:18:38 +00003)
4
Ronald Cronbfd45f12020-06-05 11:15:31 +02005set(executables_libs
6 selftest
7 udp_proxy
8)
Paul Bakker367dae42009-06-28 21:50:27 +00009
Ronald Cronbfd45f12020-06-05 11:15:31 +020010set(executables_mbedcrypto
11 benchmark
12 query_compile_time_config
13 zeroize
14)
Paul Bakker367dae42009-06-28 21:50:27 +000015
Andrzej Kurek0211c322018-03-15 05:16:24 -040016if(TEST_CPP)
Ronald Cronbfd45f12020-06-05 11:15:31 +020017 list(APPEND executables_mbedcrypto cpp_dummy_build)
Andrzej Kurek0211c322018-03-15 05:16:24 -040018endif()
19
Ronald Cronbfd45f12020-06-05 11:15:31 +020020foreach(exe IN LISTS executables_libs executables_mbedcrypto)
David Browna8e309e2020-11-18 15:07:24 -070021 set(extra_sources "")
22 if(exe STREQUAL "query_compile_time_config")
23 list(APPEND extra_sources
24 ${CMAKE_CURRENT_SOURCE_DIR}/query_config.c)
25 endif()
26 add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>
27 ${extra_sources})
Mateusz Starzyk1aec6462021-02-08 15:34:42 +010028 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
Manuel Pégourié-Gonnardcb4137b2014-09-04 14:55:28 +020029
Ronald Cronbfd45f12020-06-05 11:15:31 +020030 # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3
31 list(FIND executables_libs ${exe} exe_index)
32 if (${exe_index} GREATER -1)
33 target_link_libraries(${exe} ${libs})
34 else()
Raef Coles995c66f2020-10-13 16:30:41 +010035 target_link_libraries(${exe} ${mbedcrypto_target})
Ronald Cronbfd45f12020-06-05 11:15:31 +020036 endif()
37endforeach()
Andres Amaya Garcia5ab74a12017-10-24 21:10:45 +010038
Ronald Cronbfd45f12020-06-05 11:15:31 +020039install(TARGETS ${executables_libs} ${executables_mbedcrypto}
Paul Bakker547f73d2011-01-05 15:07:54 +000040 DESTINATION "bin"
41 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)