Update CMakeLists.txt
This commit is contained in:
parent
6b75145cec
commit
de4b77dde6
1 changed files with 27 additions and 14 deletions
|
@ -1,11 +1,19 @@
|
|||
cmake_minimum_required(VERSION 3.6)
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||
|
||||
project(
|
||||
nmrpflash
|
||||
VERSION 0.9.25
|
||||
LANGUAGES C
|
||||
)
|
||||
project(nmrpflash VERSION 0.0.0 LANGUAGES C)
|
||||
|
||||
find_package(Git)
|
||||
|
||||
if(GIT_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} describe --always
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_VERSION_STRING
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string(SUBSTRING ${GIT_VERSION_STRING} 1 -1 nmrpflash_VERSION)
|
||||
endif()
|
||||
|
||||
set(PROJECT_SOURCE_DIR ${CMAKE_SOURCE_DIR})
|
||||
add_executable(nmrpflash main.c nmrp.c tftp.c util.c ethsock.c)
|
||||
|
@ -14,17 +22,22 @@ target_compile_definitions(nmrpflash PUBLIC -DNMRPFLASH_VERSION=\"${nmrpflash_VE
|
|||
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
target_link_libraries(nmrpflash -lpcap "-framework CoreFoundation")
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
target_sources(nmrpflash PRIVATE nmrpflash.rc)
|
||||
target_compile_definitions(nmrpflash PUBLIC -D_WIN32_WINNT=0x0600 -DWIN32_LEAN_AND_MEAN -D__USE_MINGW_ANSI_STDIO)
|
||||
target_link_libraries(nmrpflash -lwpcap -lPacket -liphlpapi -lws2_32 -ladvapi32)
|
||||
target_include_directories(nmrpflash ./Npcap/Include/)
|
||||
if (CMAKE_SIZE_OF_VOID_P EQUAL 4)
|
||||
target_link_directories(nmrpflash ./Npcap/Lib/)
|
||||
target_include_directories(nmrpflash PUBLIC ./Npcap/Include)
|
||||
if (CMAKE_SIZE_OF_VOID_P EQUAL 8)
|
||||
target_link_directories(nmrpflash PUBLIC ./Npcap/Lib/x64)
|
||||
else()
|
||||
target_link_directories(nmrpflash ./Npcap/Lib/x64)
|
||||
target_link_directories(nmrpflash PUBLIC ./Npcap/Lib)
|
||||
endif()
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(NLROUTE REQUIRED IMPORTED_TARGET libnl-route-3.0)
|
||||
target_link_libraries(nmrpflash PkgConfig::NLROUTE})
|
||||
else()
|
||||
set(nmrpflash_LIBS -lpcap)
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(PCAP REQUIRED IMPORTED_TARGET libpcap)
|
||||
target_link_libraries(nmrpflash PkgConfig::PCAP)
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
pkg_check_modules(NLROUTE REQUIRED IMPORTED_TARGET libnl-route-3.0)
|
||||
target_link_libraries(nmrpflash PkgConfig::NLROUTE)
|
||||
endif()
|
||||
endif()
|
||||
|
|
Loading…
Add table
Reference in a new issue