CMakeLists.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. set(THREADS_USE_PTHREADS_WIN32 true)
  2. find_package(Threads)
  3. set(libs
  4. ${mbedtls_target}
  5. )
  6. set(executables
  7. dtls_client
  8. dtls_server
  9. mini_client
  10. ssl_client1
  11. ssl_client2
  12. ssl_context_info
  13. ssl_fork_server
  14. ssl_mail_client
  15. ssl_server
  16. ssl_server2
  17. )
  18. if(GEN_FILES)
  19. # Inform CMake that the following file will be generated as part of the build
  20. # process, so it doesn't complain that it doesn't exist yet. Starting from
  21. # CMake 3.20, this will no longer be necessary as CMake will automatically
  22. # propagate this information across the tree, for now it's only visible
  23. # inside the same directory, so we need to propagate manually.
  24. set_source_files_properties(
  25. ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c
  26. PROPERTIES GENERATED TRUE)
  27. endif()
  28. foreach(exe IN LISTS executables)
  29. set(extra_sources "")
  30. if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
  31. list(APPEND extra_sources
  32. ssl_test_lib.c
  33. ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.h
  34. ${CMAKE_CURRENT_BINARY_DIR}/../test/query_config.c)
  35. endif()
  36. add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>
  37. ${extra_sources})
  38. target_link_libraries(${exe} ${libs})
  39. target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
  40. if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
  41. if(GEN_FILES)
  42. add_dependencies(${exe} generate_query_config_c)
  43. endif()
  44. target_include_directories(${exe}
  45. PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../test)
  46. endif()
  47. endforeach()
  48. if(THREADS_FOUND)
  49. add_executable(ssl_pthread_server ssl_pthread_server.c $<TARGET_OBJECTS:mbedtls_test>)
  50. target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
  51. target_link_libraries(ssl_pthread_server ${libs} ${CMAKE_THREAD_LIBS_INIT})
  52. list(APPEND executables ssl_pthread_server)
  53. endif(THREADS_FOUND)
  54. install(TARGETS ${executables}
  55. DESTINATION "bin"
  56. PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)