blob: 4e954f07efe551b120bb962eab2be2db9dcd908a [file] [log] [blame]
Paul Bakkerf9c49532013-12-19 15:40:58 +01001find_package(Threads)
2
Paul Bakkerb06819b2011-01-18 16:18:38 +00003set(libs
Raef Coles995c66f2020-10-13 16:30:41 +01004 ${mbedtls_target}
Paul Bakkerb06819b2011-01-18 16:18:38 +00005)
6
Ronald Cronbfd45f12020-06-05 11:15:31 +02007set(executables
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +02008 dtls_client
9 dtls_server
Manuel Pégourié-Gonnard6f830252020-04-03 11:56:06 +020010 mini_client
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020011 ssl_client1
12 ssl_client2
Ronald Cron27731132020-06-05 11:51:28 +020013 ssl_context_info
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020014 ssl_fork_server
15 ssl_mail_client
Manuel Pégourié-Gonnard6f830252020-04-03 11:56:06 +020016 ssl_server
Ronald Cron27731132020-06-05 11:51:28 +020017 ssl_server2
Paul Bakkerf9c49532013-12-19 15:40:58 +010018)
Gilles Peskinebb47c732024-09-14 12:13:16 +020019add_dependencies(${programs_target} ${executables})
Gilles Peskine7215b1e2024-09-14 12:18:00 +020020add_dependencies(${ssl_opt_target} ${executables})
Paul Bakkerf9c49532013-12-19 15:40:58 +010021
David Horstmanna8d14062021-10-20 17:14:23 +010022if(GEN_FILES)
David Horstmannd64f4b22021-10-20 12:29:47 +010023 # Inform CMake that the following file will be generated as part of the build
Manuel Pégourié-Gonnarde90e4052021-09-08 13:27:09 +020024 # process, so it doesn't complain that it doesn't exist yet. Starting from
25 # CMake 3.20, this will no longer be necessary as CMake will automatically
David Horstmannd64f4b22021-10-20 12:29:47 +010026 # propagate this information across the tree, for now it's only visible
Manuel Pégourié-Gonnarde90e4052021-09-08 13:27:09 +020027 # inside the same directory, so we need to propagate manually.
28 set_source_files_properties(
29 ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c
30 PROPERTIES GENERATED TRUE)
31endif()
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020032
Ronald Cronbfd45f12020-06-05 11:15:31 +020033foreach(exe IN LISTS executables)
David Browna8e309e2020-11-18 15:07:24 -070034 set(extra_sources "")
35 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
36 list(APPEND extra_sources
Manuel Pégourié-Gonnardaedca0c2021-05-11 13:45:54 +020037 ssl_test_lib.c
Harry Ramsey061e0f52025-02-17 11:59:45 +000038 ${MBEDTLS_FRAMEWORK_DIR}/tests/programs/query_config.h
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020039 ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c)
David Browna8e309e2020-11-18 15:07:24 -070040 endif()
41 add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>
42 ${extra_sources})
Paul Elliott4068c7e2023-12-15 17:14:34 +000043 target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT})
Harry Ramsey061e0f52025-02-17 11:59:45 +000044 target_include_directories(${exe} PRIVATE ${MBEDTLS_FRAMEWORK_DIR}/tests/programs
45 ${MBEDTLS_FRAMEWORK_DIR}/tests/include
David Horstmann1d9b0332024-11-04 14:18:27 +000046 ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020047 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
David Horstmanna8d14062021-10-20 17:14:23 +010048 if(GEN_FILES)
Manuel Pégourié-Gonnarde90e4052021-09-08 13:27:09 +020049 add_dependencies(${exe} generate_query_config_c)
50 endif()
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020051 endif()
Ronald Cronbfd45f12020-06-05 11:15:31 +020052endforeach()
Paul Bakkerb06819b2011-01-18 16:18:38 +000053
Paul Bakkerf9c49532013-12-19 15:40:58 +010054if(THREADS_FOUND)
Ronald Cron8dc0af22020-06-05 16:00:22 +020055 add_executable(ssl_pthread_server ssl_pthread_server.c $<TARGET_OBJECTS:mbedtls_test>)
David Horstmann1d9b0332024-11-04 14:18:27 +000056 target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include
57 ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
Paul Bakker3e72f6e2013-12-30 15:25:08 +010058 target_link_libraries(ssl_pthread_server ${libs} ${CMAKE_THREAD_LIBS_INIT})
Ronald Cronbfd45f12020-06-05 11:15:31 +020059 list(APPEND executables ssl_pthread_server)
Paul Bakkerf9c49532013-12-19 15:40:58 +010060endif(THREADS_FOUND)
61
Ronald Cronbfd45f12020-06-05 11:15:31 +020062install(TARGETS ${executables}
Paul Bakker547f73d2011-01-05 15:07:54 +000063 DESTINATION "bin"
64 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)