CMakeLists.txt 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. ${CMAKE_CURRENT_SOURCE_DIR}/libps4000a
  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 ${CMAKE_CURRENT_SOURCE_DIR}/libps4000a
  28. ${CMAKE_CURRENT_SOURCE_DIR}/libps4000a/x64
  29. ${CMAKE_CURRENT_SOURCE_DIR}/libps4000a/Win32
  30. ENV PATH
  31. NO_DEFAULT_PATH
  32. )
  33. if(NOT PS4000A_LIB)
  34. message(FATAL_ERROR "ps4000a library not found.\n"
  35. "Download the PicoScope 4000 series SDK and copy the ".
  36. "appropriate ps4000a.lib into ${CMAKE_CURRENT_SOURCE_DIR}/libps4000a or ".
  37. "set the PS4000A_LIB environment variable to the full path.")
  38. endif()
  39. # Link against the located library
  40. # The variable may already contain the full filename, so don't append .lib
  41. # also pull in WinSock for networking helpers used by SimpleSocket
  42. if(MSVC)
  43. # WinSock functions live in ws2_32.lib
  44. add_compile_options(/utf-8)
  45. target_link_libraries(pico-tcp PRIVATE ${PS4000A_LIB} ws2_32)
  46. elseif(MINGW)
  47. target_link_libraries(pico-tcp PRIVATE ${PS4000A_LIB} ws2_32)
  48. endif()
  49. # Check for obvious architecture mismatch in the chosen library
  50. if(PS4000A_LIB)
  51. if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  52. string(FIND "${PS4000A_LIB}" "Win32" _libIs32)
  53. if(NOT _libIs32 EQUAL -1)
  54. message(WARNING "ps4000a library appears to be 32‑bit while the target "
  55. "architecture is x64; this will lead to unresolved symbols. "
  56. "Use the 64‑bit version of ps4000a.lib or set PS4000A_LIB to the "
  57. "correct path.")
  58. endif()
  59. endif()
  60. endif()
  61. # Set output directories for DLLs
  62. set_target_properties(pico-tcp PROPERTIES
  63. VS_DEBUGGER_WORKING_DIRECTORY "$<CONFIG>"
  64. )