Tasmota/CMakeLists.txt
Mike Geppert 0cd3447355
Some checks failed
Tasmota CI / os-check-win (tasmota32-webcam) (pull_request) Has been cancelled
Tasmota CI / os-check-mac (tasmota32solo1-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota-4M) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota-display) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota-ir) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota-knx) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota-lite) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota-minimal) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota-sensors) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota-zbbridge) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota-zigbee) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32-bluetooth) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32-display) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32-ir) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32-lvgl) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32-nspanel) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32-zbbrdgpro) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32c2) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32c2-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32c3) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32c3-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32c5) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32c5-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32c6) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32c6-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32p4) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32p4-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32s2) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32s2-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32s2cdc) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32s2cdc-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32s3) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32s3-safeboot) (pull_request) Has been cancelled
Tasmota CI / base-images (tasmota32solo1) (pull_request) Has been cancelled
Tasmota CI / language-images (AD, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (AF, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (BG, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (BR, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (CN, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (CZ, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (DE, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (ES, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (FR, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (FY, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (GR, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (HE, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (HU, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (IT, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (KO, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (LT, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (NL, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (PL, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (PT, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (RO, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (RU, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (SE, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (SK, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (TR, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (TW, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (UK, tasmota) (pull_request) Has been cancelled
Tasmota CI / language-images (VN, tasmota) (pull_request) Has been cancelled
Add CMake wrapper for native CLion integration with PlatformIO
- Create CMakeLists.txt that wraps PlatformIO commands as CMake targets
- Remove CMakeLists.txt from .gitignore to track the wrapper
- Update CLION_BUILD.md with UI-based build instructions
- Provides build targets: pio_build, pio_clean, pio_upload, pio_monitor
- Adds per-environment targets: build_tasmota, build_tasmota32, etc.
- Includes source indexing for CLion code intelligence

Now you can build directly from CLion's UI using the build dropdown
and hammer icon instead of terminal commands.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 21:08:32 -06:00

108 lines
3.3 KiB
CMake

cmake_minimum_required(VERSION 3.16)
project(Tasmota)
# Find PlatformIO executable
find_program(PLATFORMIO_CMD NAMES pio platformio)
if(NOT PLATFORMIO_CMD)
message(FATAL_ERROR "PlatformIO not found. Please install PlatformIO CLI.")
endif()
message(STATUS "Found PlatformIO: ${PLATFORMIO_CMD}")
# Set default environment
set(PIO_ENV "tasmota" CACHE STRING "PlatformIO environment to build")
# Create a dummy target for CLion to parse
add_custom_target(tasmota_dummy ALL
COMMAND ${CMAKE_COMMAND} -E echo "Use PlatformIO targets to build"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
# PlatformIO build target
add_custom_target(pio_build
COMMAND ${PLATFORMIO_CMD} run -e ${PIO_ENV}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building PlatformIO environment: ${PIO_ENV}"
)
# PlatformIO clean target
add_custom_target(pio_clean
COMMAND ${PLATFORMIO_CMD} run -e ${PIO_ENV} -t clean
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Cleaning PlatformIO environment: ${PIO_ENV}"
)
# PlatformIO upload target
add_custom_target(pio_upload
COMMAND ${PLATFORMIO_CMD} run -e ${PIO_ENV} -t upload
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Uploading PlatformIO environment: ${PIO_ENV}"
)
# PlatformIO monitor target
add_custom_target(pio_monitor
COMMAND ${PLATFORMIO_CMD} device monitor
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Starting PlatformIO serial monitor"
)
# Common Tasmota environments as separate targets
set(TASMOTA_ENVS
tasmota
tasmota32
tasmota-minimal
tasmota-sensors
tasmota-display
tasmota-ir
)
foreach(env ${TASMOTA_ENVS})
add_custom_target(build_${env}
COMMAND ${PLATFORMIO_CMD} run -e ${env}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Building ${env}"
)
endforeach()
# Generate compile_commands.json for code intelligence
add_custom_target(generate_compile_commands
COMMAND ${PLATFORMIO_CMD} run -t compiledb -e ${PIO_ENV}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating compile_commands.json"
)
# Parse source files for CLion indexing (using tasmota directory)
file(GLOB_RECURSE TASMOTA_SOURCES
"${CMAKE_SOURCE_DIR}/tasmota/*.ino"
"${CMAKE_SOURCE_DIR}/tasmota/*.cpp"
"${CMAKE_SOURCE_DIR}/tasmota/*.c"
"${CMAKE_SOURCE_DIR}/tasmota/*.h"
)
# Create a library target for indexing (won't actually build)
if(TASMOTA_SOURCES)
add_library(tasmota_indexing EXCLUDE_FROM_ALL ${TASMOTA_SOURCES})
set_target_properties(tasmota_indexing PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(tasmota_indexing PRIVATE
${CMAKE_SOURCE_DIR}/tasmota
${CMAKE_SOURCE_DIR}/tasmota/include
)
# Set some basic defines for indexing
target_compile_definitions(tasmota_indexing PRIVATE
ARDUINO=10816
ARDUINO_ARCH_ESP8266
ESP8266
TASMOTA
)
endif()
message(STATUS "CMake wrapper for PlatformIO configured")
message(STATUS "Available targets:")
message(STATUS " - pio_build: Build default environment (${PIO_ENV})")
message(STATUS " - pio_clean: Clean build files")
message(STATUS " - pio_upload: Upload firmware to device")
message(STATUS " - pio_monitor: Serial monitor")
message(STATUS " - build_<env>: Build specific environment")
message(STATUS " - generate_compile_commands: Update code intelligence")