Skip to content

Commit

Permalink
Update src/CMakeLists.txt
Browse files Browse the repository at this point in the history
This is to adopt the CMake improvements in PR avrdudes#1553 even though the PR itself was abondoned.

The author of the change is @Youw.
  • Loading branch information
mcuee authored Nov 14, 2023
1 parent c82fec9 commit 20b6df6
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ endif()
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
add_compile_definitions(CONFIG_DIR=\"${CONFIG_DIR}\")

set(EXTRA_WINDOWS_SOURCES)
set(EXTRA_WINDOWS_INCLUDES)
set(EXTRA_WINDOWS_RESOURCES)
set(EXTRA_WINDOWS_LIBRARIES)

if(WIN32 OR MINGW)
set(EXTRA_WINDOWS_RESOURCES "${PROJECT_BINARY_DIR}/src/windows.rc")
set(EXTRA_WINDOWS_LIBRARIES setupapi hid ws2_32)
list(APPEND EXTRA_WINDOWS_RESOURCES "${PROJECT_BINARY_DIR}/src/windows.rc")
list(APPEND EXTRA_WINDOWS_LIBRARIES setupapi hid ws2_32)
endif()

if(MSVC)
Expand All @@ -66,15 +71,13 @@ if(MSVC)
add_compile_options(/wd4244) # warning C4244: conversion from '...' to '...', possible loss of data
add_compile_options(/wd4267) # warning C4267: conversion from '...' to '...', possible loss of data

set(EXTRA_WINDOWS_SOURCES ${EXTRA_WINDOWS_SOURCES}
list(APPEND EXTRA_WINDOWS_SOURCES
"msvc/getopt.c"
"msvc/gettimeofday.c"
"msvc/usleep.cpp"
"msvc/readline.cpp"
)
set(EXTRA_WINDOWS_INCLUDES ${EXTRA_WINDOWS_INCLUDES}
"msvc"
)
list(APPEND EXTRA_WINDOWS_INCLUDES "msvc")
else()
set(LIB_MATH m)
add_compile_options(-Wall -Wextra -Wno-unused-parameter)
Expand Down Expand Up @@ -260,7 +263,7 @@ add_library(libavrdude
xbee.c
${FLEX_Parser_OUTPUTS}
${BISON_Parser_OUTPUTS}
"${EXTRA_WINDOWS_SOURCES}"
${EXTRA_WINDOWS_SOURCES}
)

set_target_properties(libavrdude PROPERTIES
Expand All @@ -274,8 +277,9 @@ target_include_directories(libavrdude
PUBLIC
"${PROJECT_SOURCE_DIR}"
"${PROJECT_BINARY_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${LIBUSB_COMPAT_DIR}"
"${EXTRA_WINDOWS_INCLUDES}"
${EXTRA_WINDOWS_INCLUDES}
)

target_link_libraries(libavrdude
Expand All @@ -302,7 +306,7 @@ add_executable(avrdude
developer_opts_private.h
whereami.c
whereami.h
"${EXTRA_WINDOWS_RESOURCES}"
${EXTRA_WINDOWS_RESOURCES}
)

target_link_libraries(avrdude PUBLIC libavrdude)
Expand Down

0 comments on commit 20b6df6

Please sign in to comment.