CMakeLists.txt 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. cmake_minimum_required(VERSION 3.10)
  2. project(pico-tcp)
  3. set(CMAKE_CXX_STANDARD 17)
  4. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  5. # Add all source files from current directory
  6. set(SOURCES
  7. main.cpp
  8. picofunctions.cpp
  9. pugixml.cpp
  10. )
  11. # Add all source files from src directory
  12. file(GLOB SRC_SOURCES "src/*.cpp")
  13. list(APPEND SOURCES ${SRC_SOURCES})
  14. # Create executable
  15. add_executable(pico-tcp ${SOURCES})
  16. # Include directories
  17. target_include_directories(pico-tcp PRIVATE
  18. ${CMAKE_CURRENT_SOURCE_DIR}
  19. ${CMAKE_CURRENT_SOURCE_DIR}/inc
  20. "C:\\Program Files\\Pico Technology\\SDK\\inc"
  21. ${CMAKE_CURRENT_SOURCE_DIR}/libmsgpack11
  22. ${CMAKE_CURRENT_SOURCE_DIR}/src
  23. )
  24. # Locate ps4000a library (expected to be provided by the PicoScope SDK)
  25. find_library(PS4000A_LIB
  26. NAMES ps4000a ps4000a.lib
  27. PATHS "C:\\Program Files\\Pico Technology\\SDK\\lib"
  28. ENV PATH
  29. NO_DEFAULT_PATH
  30. )
  31. if(NOT PS4000A_LIB)
  32. message(FATAL_ERROR "ps4000a library not found.\n"
  33. "Download the PicoScope 4000 series SDK and copy the ".
  34. "appropriate ps4000a.lib into ${CMAKE_CURRENT_SOURCE_DIR}/libps4000a or ".
  35. "set the PS4000A_LIB environment variable to the full path.")
  36. endif()
  37. # Link against the located library
  38. # The variable may already contain the full filename, so don't append .lib
  39. # also pull in WinSock for networking helpers used by SimpleSocket
  40. if(MSVC)
  41. # WinSock functions live in ws2_32.lib
  42. add_compile_options(/utf-8)
  43. target_link_libraries(pico-tcp PRIVATE ${PS4000A_LIB} ws2_32)
  44. elseif(MINGW)
  45. target_link_libraries(pico-tcp PRIVATE ${PS4000A_LIB} ws2_32)
  46. endif()
  47. # Check for obvious architecture mismatch in the chosen library
  48. if(PS4000A_LIB)
  49. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  50. string(FIND "${PS4000A_LIB}" "Win32" _libIs32)
  51. if(NOT _libIs32 EQUAL -1)
  52. message(WARNING "ps4000a library appears to be 32‑bit while the target "
  53. "architecture is x64; this will lead to unresolved symbols. "
  54. "Use the 64‑bit version of ps4000a.lib or set PS4000A_LIB to the "
  55. "correct path.")
  56. endif()
  57. endif()
  58. endif()
  59. # Set output directories for DLLs
  60. set_target_properties(pico-tcp PROPERTIES
  61. VS_DEBUGGER_WORKING_DIRECTORY "$<CONFIG>"
  62. )