blob: cfa9a0f924b1a4c734ab9cbc0d1b503d86181770 [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
Simon Butcher33425de2018-03-14 16:44:22 +00008if(WIN32)
Kevin Kane0ec1e682016-12-15 09:27:16 -08009 set(libs ${libs} bcrypt)
Simon Butcher33425de2018-03-14 16:44:22 +000010endif(WIN32)
Kevin Kane0ec1e682016-12-15 09:27:16 -080011
Ronald Cronbfd45f12020-06-05 11:15:31 +020012set(executables
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020013 dtls_client
14 dtls_server
Manuel Pégourié-Gonnard6f830252020-04-03 11:56:06 +020015 mini_client
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020016 ssl_client1
17 ssl_client2
Ronald Cron27731132020-06-05 11:51:28 +020018 ssl_context_info
Manuel Pégourié-Gonnard216a1832015-06-25 09:20:03 +020019 ssl_fork_server
20 ssl_mail_client
Manuel Pégourié-Gonnard6f830252020-04-03 11:56:06 +020021 ssl_server
Ronald Cron27731132020-06-05 11:51:28 +020022 ssl_server2
Paul Bakkerf9c49532013-12-19 15:40:58 +010023)
24
David Horstmanna8d14062021-10-20 17:14:23 +010025if(GEN_FILES)
David Horstmannd64f4b22021-10-20 12:29:47 +010026 # Inform CMake that the following file will be generated as part of the build
Manuel Pégourié-Gonnarde90e4052021-09-08 13:27:09 +020027 # process, so it doesn't complain that it doesn't exist yet. Starting from
28 # CMake 3.20, this will no longer be necessary as CMake will automatically
David Horstmannd64f4b22021-10-20 12:29:47 +010029 # propagate this information across the tree, for now it's only visible
Manuel Pégourié-Gonnarde90e4052021-09-08 13:27:09 +020030 # inside the same directory, so we need to propagate manually.
31 set_source_files_properties(
32 ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c
33 PROPERTIES GENERATED TRUE)
34endif()
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020035
Ronald Cronbfd45f12020-06-05 11:15:31 +020036foreach(exe IN LISTS executables)
David Browna8e309e2020-11-18 15:07:24 -070037 set(extra_sources "")
38 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
39 list(APPEND extra_sources
Manuel Pégourié-Gonnardaedca0c2021-05-11 13:45:54 +020040 ssl_test_lib.c
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020041 ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.h
42 ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c)
David Browna8e309e2020-11-18 15:07:24 -070043 endif()
44 add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>
45 ${extra_sources})
Ronald Cronbfd45f12020-06-05 11:15:31 +020046 target_link_libraries(${exe} ${libs})
Ronald Cron8dc0af22020-06-05 16:00:22 +020047 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020048 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
David Horstmanna8d14062021-10-20 17:14:23 +010049 if(GEN_FILES)
Manuel Pégourié-Gonnarde90e4052021-09-08 13:27:09 +020050 add_dependencies(${exe} generate_query_config_c)
51 endif()
Manuel Pégourié-Gonnard86cfa6c2021-05-14 10:07:33 +020052 target_include_directories(${exe}
53 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../test)
54 endif()
Ronald Cronbfd45f12020-06-05 11:15:31 +020055endforeach()
Paul Bakkerb06819b2011-01-18 16:18:38 +000056
Paul Bakkerf9c49532013-12-19 15:40:58 +010057if(THREADS_FOUND)
Ronald Cron8dc0af22020-06-05 16:00:22 +020058 add_executable(ssl_pthread_server ssl_pthread_server.c $<TARGET_OBJECTS:mbedtls_test>)
Mateusz Starzyk1aec6462021-02-08 15:34:42 +010059 target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
Paul Bakker3e72f6e2013-12-30 15:25:08 +010060 target_link_libraries(ssl_pthread_server ${libs} ${CMAKE_THREAD_LIBS_INIT})
Ronald Cronbfd45f12020-06-05 11:15:31 +020061 list(APPEND executables ssl_pthread_server)
Paul Bakkerf9c49532013-12-19 15:40:58 +010062endif(THREADS_FOUND)
63
Ronald Cronbfd45f12020-06-05 11:15:31 +020064install(TARGETS ${executables}
Paul Bakker547f73d2011-01-05 15:07:54 +000065 DESTINATION "bin"
66 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)