ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.17k stars 387 forks source link

`CMAKE_CURRENT_SOURCE_DIR` causes build to fail when including CMakeLists.txt (ESP-IDF) #944

Closed Maxxus220 closed 1 month ago

Maxxus220 commented 1 month ago

Problem

Anywhere where CMAKE_CURRENT_SOURCE_DIR is used, causes build errors when doing include(etl/CMakeLists.txt) since CMAKE_CURRENT_SOURCE_DIR will continue to use the value of the CMake file that called include(etl/CMakeLists.txt). Normally this shouldn't be a problem as you would typically use add_subdirectory anyways. However, ESP-IDF for ESP32 chips has their own build system that for some reason adds dependencies using include instead of add_subdirectory.

Proposed Solution

Regardless of the fact that add_subdirectory should typically be used, it seems that CMAKE_CURRENT_LIST_DIR more closely fits the intention behind the places that use CMAKE_CURRENT_SOURCE_DIR. I'm suggesting replacing all instances of CMAKE_CURRENT_SOURCE_DIR with CMAKE_CURRENT_LIST_DIR.

3 Files (10 instances including comments)