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