blob: ec2c86fb4adc6f9582ea9b12ed90c51f6a9fffee [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)
19
David Horstmanna8d14062021-10-20 17:14:23 +010020if(GEN_FILES)
David Horstmannd64f4b22021-10-20 12:29:47 +010021 # Inform CMake that the following file will be generated as part of the build
Manuel Pégourié-Gonnarde90e4052021-09-08 13:27:09 +020022 # process, so it doesn't complain that it doesn't exist yet. Starting from
23 # CMake 3.20, this will no longer be necessary as CMake will automatically
David Horstmannd64f4b22021-10-20 12:29:47 +010024 # propagate this information across the tree, for now it's only visible
Manuel Pégourié-Gonnarde90e4052021-09-08 13:27:09 +020025 # inside the same directory, so we need to propagate manually.
26 set_source_files_properties(
27 ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c
28 PROPERTIES GENERATED TRUE)
29endif()
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020030
Ronald Cronbfd45f12020-06-05 11:15:31 +020031foreach(exe IN LISTS executables)
David Browna8e309e2020-11-18 15:07:24 -070032 set(extra_sources "")
33 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
34 list(APPEND extra_sources
Manuel Pégourié-Gonnardaedca0c2021-05-11 13:45:54 +020035 ssl_test_lib.c
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020036 ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.h
37 ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c)
David Browna8e309e2020-11-18 15:07:24 -070038 endif()
39 add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>
40 ${extra_sources})
Paul Elliott4068c7e2023-12-15 17:14:34 +000041 target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT})
Ronald Cron8dc0af22020-06-05 16:00:22 +020042 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020043 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
David Horstmanna8d14062021-10-20 17:14:23 +010044 if(GEN_FILES)
Manuel Pégourié-Gonnarde90e4052021-09-08 13:27:09 +020045 add_dependencies(${exe} generate_query_config_c)
46 endif()
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020047 target_include_directories(${exe}
48 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../test)
49 endif()
Ronald Cronbfd45f12020-06-05 11:15:31 +020050endforeach()
Paul Bakkerb06819b2011-01-18 16:18:38 +000051
Paul Bakkerf9c49532013-12-19 15:40:58 +010052if(THREADS_FOUND)
Ronald Cron8dc0af22020-06-05 16:00:22 +020053 add_executable(ssl_pthread_server ssl_pthread_server.c $<TARGET_OBJECTS:mbedtls_test>)
Mateusz Starzyk1aec6462021-02-08 15:34:42 +010054 target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
Paul Bakker3e72f6e2013-12-30 15:25:08 +010055 target_link_libraries(ssl_pthread_server ${libs} ${CMAKE_THREAD_LIBS_INIT})
Ronald Cronbfd45f12020-06-05 11:15:31 +020056 list(APPEND executables ssl_pthread_server)
Paul Bakkerf9c49532013-12-19 15:40:58 +010057endif(THREADS_FOUND)
58
Ronald Cronbfd45f12020-06-05 11:15:31 +020059install(TARGETS ${executables}
Paul Bakker547f73d2011-01-05 15:07:54 +000060 DESTINATION "bin"
61 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)