cmake: fix building on windows with mingw64

- wpcap/packet libraries were wrong (.a, not .lib; not the x64 ones)
- link order resulted in undefined references

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
Simon Goldschmidt 2022-03-22 22:38:28 +01:00
parent 215dec653b
commit 7807402899
2 changed files with 15 additions and 3 deletions

View File

@ -24,8 +24,20 @@ if(NOT DEFINED WPDPACK_DIR)
set(WPDPACK_DIR ${LWIP_DIR}/../WpdPack) set(WPDPACK_DIR ${LWIP_DIR}/../WpdPack)
message(STATUS "WPDPACK_DIR not set - using default location ${WPDPACK_DIR}") message(STATUS "WPDPACK_DIR not set - using default location ${WPDPACK_DIR}")
endif() endif()
find_library(WPCAP wpcap HINTS ${WPDPACK_DIR}/lib) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
find_library(PACKET packet HINTS ${WPDPACK_DIR}/lib) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(WPDPACK_LIB_DIR ${WPDPACK_DIR}/lib/x64)
else()
set(WPDPACK_LIB_DIR ${WPDPACK_DIR}/lib)
endif()
set(WPCAP ${WPDPACK_DIR}/lib/x64/wpcap.lib)
set(PACKET ${WPDPACK_DIR}/lib/x64/packet.lib)
else()
find_library(WPCAP wpcap HINTS ${WPDPACK_DIR}/lib/x64)
find_library(PACKET packet HINTS ${WPDPACK_DIR}/lib/x64)
endif()
message(STATUS "WPCAP library: ${WPCAP}")
message(STATUS "PACKET library: ${PACKET}")
add_library(lwipcontribportwindows EXCLUDE_FROM_ALL ${lwipcontribportwindows_SRCS}) add_library(lwipcontribportwindows EXCLUDE_FROM_ALL ${lwipcontribportwindows_SRCS})
target_include_directories(lwipcontribportwindows PRIVATE ${LWIP_INCLUDE_DIRS} "${WPDPACK_DIR}/include" ${LWIP_MBEDTLS_INCLUDE_DIRS}) target_include_directories(lwipcontribportwindows PRIVATE ${LWIP_INCLUDE_DIRS} "${WPDPACK_DIR}/include" ${LWIP_MBEDTLS_INCLUDE_DIRS})

View File

@ -15,7 +15,7 @@ add_executable(example_app ${LWIP_DIR}/contrib/examples/example_app/test.c defau
target_include_directories(example_app PRIVATE ${LWIP_INCLUDE_DIRS}) target_include_directories(example_app PRIVATE ${LWIP_INCLUDE_DIRS})
target_compile_options(example_app PRIVATE ${LWIP_COMPILER_FLAGS}) target_compile_options(example_app PRIVATE ${LWIP_COMPILER_FLAGS})
target_compile_definitions(example_app PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS}) target_compile_definitions(example_app PRIVATE ${LWIP_DEFINITIONS} ${LWIP_MBEDTLS_DEFINITIONS})
target_link_libraries(example_app ${LWIP_SANITIZER_LIBS} lwipcontribexamples lwipcontribapps lwipcontribaddons lwipallapps lwipcore lwipcontribportwindows lwipmbedtls) target_link_libraries(example_app ${LWIP_SANITIZER_LIBS} lwipallapps lwipcontribexamples lwipcontribapps lwipcontribaddons lwipcontribportwindows lwipcore lwipmbedtls)
add_executable(makefsdata ${lwipmakefsdata_SRCS}) add_executable(makefsdata ${lwipmakefsdata_SRCS})
target_compile_options(makefsdata PRIVATE ${LWIP_COMPILER_FLAGS}) target_compile_options(makefsdata PRIVATE ${LWIP_COMPILER_FLAGS})