blob: a14e264666bc1bf87dc367d78af93229b46cef91 [file] [log] [blame]
Paul Bakker3e72f6e2013-12-30 15:25:08 +01001set(THREADS_USE_PTHREADS_WIN32 true)
Paul Bakkerf9c49532013-12-19 15:40:58 +01002find_package(Threads)
3
Paul Bakkerb06819b2011-01-18 16:18:38 +00004set(libs
Raef Coles995c66f2020-10-13 16:30:41 +01005 ${mbedtls_target}
Paul Bakkerb06819b2011-01-18 16:18:38 +00006)
7
Ronald Cronbfd45f12020-06-05 11:15:31 +02008set(executables
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +02009 dtls_client
10 dtls_server
Manuel Pégourié-Gonnard6f830252020-04-03 11:56:06 +020011 mini_client
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020012 ssl_client1
13 ssl_client2
Ronald Cron27731132020-06-05 11:51:28 +020014 ssl_context_info
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020015 ssl_fork_server
16 ssl_mail_client
Manuel Pégourié-Gonnard6f830252020-04-03 11:56:06 +020017 ssl_server
Ronald Cron27731132020-06-05 11:51:28 +020018 ssl_server2
Paul Bakkerf9c49532013-12-19 15:40:58 +010019)
20
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020021# Inform CMake the the following file will be generated as part of the build
22# 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
24# propagate this information accross the tree, for now it's only visible
25# inside the same directory, so we need to propagate manually.
26set_source_files_properties(
27 ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c
28 PROPERTIES GENERATED TRUE)
29
Ronald Cronbfd45f12020-06-05 11:15:31 +020030foreach(exe IN LISTS executables)
David Browna8e309e2020-11-18 15:07:24 -070031 set(extra_sources "")
32 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
33 list(APPEND extra_sources
Manuel Pégourié-Gonnardaedca0c2021-05-11 13:45:54 +020034 ssl_test_lib.c
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020035 ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.h
36 ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c)
David Browna8e309e2020-11-18 15:07:24 -070037 endif()
38 add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>
39 ${extra_sources})
Ronald Cronbfd45f12020-06-05 11:15:31 +020040 target_link_libraries(${exe} ${libs})
Ronald Cron8dc0af22020-06-05 16:00:22 +020041 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020042 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
43 add_dependencies(${exe} generate_query_config_c)
44 target_include_directories(${exe}
45 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../test)
46 endif()
Ronald Cronbfd45f12020-06-05 11:15:31 +020047endforeach()
Paul Bakkerb06819b2011-01-18 16:18:38 +000048
Paul Bakkerf9c49532013-12-19 15:40:58 +010049if(THREADS_FOUND)
Ronald Cron8dc0af22020-06-05 16:00:22 +020050 add_executable(ssl_pthread_server ssl_pthread_server.c $<TARGET_OBJECTS:mbedtls_test>)
Mateusz Starzyk1aec6462021-02-08 15:34:42 +010051 target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
Paul Bakker3e72f6e2013-12-30 15:25:08 +010052 target_link_libraries(ssl_pthread_server ${libs} ${CMAKE_THREAD_LIBS_INIT})
Ronald Cronbfd45f12020-06-05 11:15:31 +020053 list(APPEND executables ssl_pthread_server)
Paul Bakkerf9c49532013-12-19 15:40:58 +010054endif(THREADS_FOUND)
55
Ronald Cronbfd45f12020-06-05 11:15:31 +020056install(TARGETS ${executables}
Paul Bakker547f73d2011-01-05 15:07:54 +000057 DESTINATION "bin"
58 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)