BUILDING 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. Building lwIP
  2. =============
  3. lwIP uses a CMake based build system.
  4. The CMake files in this project are designed to
  5. be included into your own CMake files. They are
  6. mainly variable definitions containing a list of
  7. source files and predefined static libraries to
  8. be linked against application code.
  9. 1) lwIP sources:
  10. src/Filelists.cmake provides file lists containing
  11. the lwIP core library.
  12. The file also contains two static libraries, lwipcore
  13. and lwipallapps, where you can link your app against.
  14. This is the file that is useful to all lwIP users.
  15. 2) Example applications:
  16. contrib/Filelists.cmake provides several file lists
  17. containing the example applications.
  18. The file also contains several static libraries
  19. for these example apps.
  20. This file is only useful for you, if you can use one
  21. of the examples in your application, which is normally
  22. not the case.
  23. 3) OS/platform port:
  24. Usually the OS port needs to be provided by the user.
  25. If a port to Linux, Windows or MacOS is useful for
  26. you, you can use
  27. contrib/ports/{win32, unix}/Filelists.cmake
  28. that contains file lists and libraries for
  29. these operating systems.
  30. VARIABLES
  31. =========
  32. In all cases, you need to provide two variables.
  33. "LWIP_DIR" pointing to the lwIP directory
  34. Example:
  35. set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/externals/lwip)
  36. "LWIP_INCLUDE_DIRS" that contains the include base paths
  37. - for lwIP itself (${LWIP_DIR}/src/include)
  38. - for lwIP contrib if you use it (${LWIP_DIR}/contrib)
  39. - to a directory containing an OS port
  40. - to a directory containing lwipopts.h
  41. Example:
  42. set (LWIP_INCLUDE_DIRS
  43. "${LWIP_DIR}/src/include"
  44. "${LWIP_DIR}/contrib"
  45. "${LWIP_DIR}/contrib/ports/unix/port/include"
  46. "${LWIP_DIR}/contrib/examples/example_app"
  47. )
  48. Putting it all together
  49. =======================
  50. To get a working application, your CMake system
  51. needs to provide the variables described above, e.g.
  52. set (LWIP_DIR <path to lwip sources>)
  53. set (LWIP_INCLUDE_DIRS
  54. "${LWIP_DIR}/src/include"
  55. "${LWIP_DIR}/contrib"
  56. "<path to my port>/include"
  57. "<path to lwipopts.h>"
  58. )
  59. You may add some defines:
  60. set (LWIP_DEFINITIONS LWIP_DEBUG=1)
  61. Then include the filelists you need:
  62. include(${LWIP_DIR}/src/Filelists.cmake)
  63. include(${LWIP_DIR}/contrib/Filelists.cmake)
  64. Then, declare you executable:
  65. add_executable(my_app <my source files> <my lwip port files>)
  66. Add lwIP include dirs to your app:
  67. target_include_directories(my_app PRIVATE ${LWIP_INCLUDE_DIRS})
  68. Link your app against the lwIP libs from the filelists you need:
  69. target_link_libraries(my_app lwipcontribapps lwipallapps lwipcore)
  70. Working example
  71. ===============
  72. Working build examples can be found in the
  73. contrib/ports/{win32, unix}/example_app
  74. subdirectory.
  75. To use them, create a build directory and call cmake with
  76. the lwIP root dir:
  77. - mkdir build
  78. - cd build
  79. - cmake ..
  80. - cmake --build .
  81. The CMakeLists.txt will autoselect the correct port
  82. for your system (supported: Linux, Windows, Darwin).
  83. Makefile based build system
  84. ===========================
  85. lwIP also maintains file lists for Makefile-based
  86. build systems. Look for Filelists.mk files
  87. in the source tree. We try to maintain them,
  88. but lwIP's mainly focused build system is CMake.