CMakeLists.txt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. set(libs
  2. ${mbedtls_target}
  3. )
  4. if(USE_PKCS11_HELPER_LIBRARY)
  5. set(libs ${libs} pkcs11-helper)
  6. endif(USE_PKCS11_HELPER_LIBRARY)
  7. if(ENABLE_ZLIB_SUPPORT)
  8. set(libs ${libs} ${ZLIB_LIBRARIES})
  9. endif(ENABLE_ZLIB_SUPPORT)
  10. set(executables_libs
  11. selftest
  12. udp_proxy
  13. )
  14. set(executables_mbedcrypto
  15. benchmark
  16. query_compile_time_config
  17. zeroize
  18. )
  19. if(TEST_CPP)
  20. set(cpp_dummy_build_cpp "${CMAKE_CURRENT_BINARY_DIR}/cpp_dummy_build.cpp")
  21. set(generate_cpp_dummy_build "${CMAKE_CURRENT_SOURCE_DIR}/generate_cpp_dummy_build.sh")
  22. add_custom_command(
  23. OUTPUT "${cpp_dummy_build_cpp}"
  24. COMMAND "${generate_cpp_dummy_build}" "${cpp_dummy_build_cpp}"
  25. DEPENDS "${generate_cpp_dummy_build}"
  26. WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
  27. )
  28. add_executable(cpp_dummy_build "${cpp_dummy_build_cpp}")
  29. target_include_directories(cpp_dummy_build PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
  30. target_link_libraries(cpp_dummy_build ${mbedcrypto_target})
  31. endif()
  32. if(USE_SHARED_MBEDTLS_LIBRARY AND
  33. NOT ${CMAKE_SYSTEM_NAME} MATCHES "[Ww][Ii][Nn]")
  34. add_executable(dlopen "dlopen.c")
  35. target_include_directories(dlopen PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../include)
  36. target_link_libraries(dlopen ${CMAKE_DL_LIBS})
  37. endif()
  38. foreach(exe IN LISTS executables_libs executables_mbedcrypto)
  39. set(extra_sources "")
  40. if(exe STREQUAL "query_compile_time_config")
  41. list(APPEND extra_sources
  42. ${CMAKE_CURRENT_SOURCE_DIR}/query_config.c)
  43. endif()
  44. add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:mbedtls_test>
  45. ${extra_sources})
  46. # This emulates "if ( ... IN_LIST ... )" which becomes available in CMake 3.3
  47. list(FIND executables_libs ${exe} exe_index)
  48. if (${exe_index} GREATER -1)
  49. target_link_libraries(${exe} ${libs})
  50. else()
  51. target_link_libraries(${exe} ${mbedcrypto_target})
  52. endif()
  53. endforeach()
  54. install(TARGETS ${executables_libs} ${executables_mbedcrypto}
  55. DESTINATION "bin"
  56. PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)