1find_package(Threads) 2 3set(libs 4 ${mbedtls_target} 5) 6 7set(executables 8 dtls_client 9 dtls_server 10 mini_client 11 ssl_client1 12 ssl_client2 13 ssl_context_info 14 ssl_fork_server 15 ssl_mail_client 16 ssl_server 17 ssl_server2 18) 19 20if(GEN_FILES) 21 # Inform CMake that 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 across the tree, for now it's only visible 25 # 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() 30 31foreach(exe IN LISTS executables) 32 set(extra_sources "") 33 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2") 34 list(APPEND extra_sources 35 ssl_test_lib.c 36 ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.h 37 ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c) 38 endif() 39 add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test> 40 ${extra_sources}) 41 target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT}) 42 target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) 43 if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2") 44 if(GEN_FILES) 45 add_dependencies(${exe} generate_query_config_c) 46 endif() 47 target_include_directories(${exe} 48 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../test) 49 endif() 50endforeach() 51 52if(THREADS_FOUND) 53 add_executable(ssl_pthread_server ssl_pthread_server.c $<TARGET_OBJECTS:mbedtls_test>) 54 target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) 55 target_link_libraries(ssl_pthread_server ${libs} ${CMAKE_THREAD_LIBS_INIT}) 56 list(APPEND executables ssl_pthread_server) 57endif(THREADS_FOUND) 58 59install(TARGETS ${executables} 60 DESTINATION "bin" 61 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) 62