liblightmodbus-esp/CMakeLists.txt
2021-08-31 00:19:56 +02:00

28 lines
912 B
CMake

# This CMakeLists.txt is only a ESP-IDF component declaration
include(FetchContent)
set(LIBLIGHTMODBUS_REPO_DIR "${CMAKE_CURRENT_LIST_DIR}/repo")
# Fetch liblightmodbus source code from GitHub
FetchContent_Populate(liblightmodbus-src
GIT_REPOSITORY "https://github.com/jacajack/liblightmodbus.git"
GIT_TAG "master"
SOURCE_DIR "${LIBLIGHTMODBUS_REPO_DIR}"
)
# Copy config file to liblightmodbus include directory
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/src/esp.config.h"
"${LIBLIGHTMODBUS_REPO_DIR}/include/lightmodbus/esp.config.h"
COPYONLY
)
# Register component
idf_component_register(
SRCS "src/impl.c"
INCLUDE_DIRS "${LIBLIGHTMODBUS_REPO_DIR}/include"
)
# Inform liblightmodbus to use ESP config header
idf_build_set_property(COMPILE_DEFINITIONS "-DLIGHTMODBUS_USE_CONFIG_FILE" APPEND)
idf_build_set_property(COMPILE_DEFINITIONS "-DLIGHTMODBUS_CONFIG_FILE=\"esp.config.h\"" APPEND)