Merge pull request #783 from mariusgreuel/pr-improve-cmake

Improve CMake project
This commit is contained in:
Jörg Wunsch 2021-12-28 14:47:58 +01:00 committed by GitHub
commit f531af70db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 5 deletions

View File

@ -48,15 +48,19 @@ set(AVRDUDE_EXTERNAL_PATH "${PROJECT_SOURCE_DIR}/external")
find_package(FLEX)
if(FLEX_FOUND)
FLEX_TARGET(Parser lexer.l "${PROJECT_BINARY_DIR}/lexer.c")
if (FLEX_VERSION VERSION_GREATER_EQUAL 2.5.9)
set(HAVE_YYLEX_DESTROY 1)
endif()
else()
message(SEND_ERROR "This CMake project requires flex, which is not installed on your system." )
message(SEND_ERROR "This CMake project requires 'flex', which is not installed on your system." )
endif()
find_package(BISON)
if(BISON_FOUND)
BISON_TARGET(Parser config_gram.y "${PROJECT_BINARY_DIR}/config_gram.c" DEFINES_FILE "${PROJECT_BINARY_DIR}/config_gram.h")
else()
message(SEND_ERROR "This CMake project requires bison, which is not installed on your system." )
message(SEND_ERROR "This CMake project requires 'bison', which is not installed on your system." )
endif()
# =====================================
@ -121,6 +125,11 @@ if(HAVE_LIBUSB_1_0)
set(LIB_LIBUSB_1_0 ${HAVE_LIBUSB_1_0})
endif()
# FreeBSD's library 'libusb' supports both the libusb-0.1 and libusb-1.0 API.
if (HAVE_LIBUSB AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(HAVE_LIBUSB_1_0 ${HAVE_LIBUSB})
endif()
find_library(HAVE_LIBUSB_WIN32 NAMES libusb0.a usb0)
if(HAVE_LIBUSB OR HAVE_LIBUSB_1_0 OR HAVE_LIBUSB_WIN32)
@ -182,6 +191,8 @@ endif()
# Setup target specific options
# =====================================
add_compile_definitions(CONFIG_DIR=\"${CONFIG_DIR}\")
if(WIN32)
set(HAVE_LIBWS2_32 1)
set(EXTRA_WINDOWS_SOURCES "${PROJECT_BINARY_DIR}/windows.rc")
@ -318,8 +329,22 @@ message(STATUS "----------------------")
# Configure files
# =====================================
macro(configure_option option)
if(${${option}})
string(REGEX REPLACE "(.*)@${option}_BEGIN@(.*)@${option}_END@(.*)" "\\1\\2\\3" conf_file "${conf_file}")
else()
string(REGEX REPLACE "(.*)@${option}_BEGIN@(.*)@${option}_END@(.*)" "\\1\\3" conf_file "${conf_file}")
endif()
endmacro()
file(READ avrdude.conf.in conf_file)
configure_option(HAVE_PARPORT)
configure_option(HAVE_LINUXGPIO)
configure_option(HAVE_LINUXSPI)
file(WRITE "${PROJECT_BINARY_DIR}/avrdude.conf.in" "${conf_file}")
configure_file(cmake_config.h.in ac_cfg.h)
configure_file(avrdude.conf.in avrdude.conf)
configure_file("${PROJECT_BINARY_DIR}/avrdude.conf.in" avrdude.conf)
configure_file(avrdude.spec.in avrdude.spec)
if(WIN32)
configure_file(windows.rc.in windows.rc)

View File

@ -22,8 +22,6 @@
#define VERSION "@PROJECT_VERSION@"
#define CONFIG_DIR "${CONFIG_DIR}"
/* Options */
/* Linux sysfs GPIO support enabled */