imaNNeo / fl_chart

FL Chart is a highly customizable Flutter chart library that supports Line Chart, Bar Chart, Pie Chart, Scatter Chart, and Radar Chart.
https://flchart.dev
MIT License
6.86k stars 1.78k forks source link

fix: example app build for Linux (Issue #1667) #1668

Closed Neer-Pathak closed 2 months ago

Neer-Pathak commented 6 months ago

Summary

This pull request addresses the issue where the example app in the fl_chart repository fails to build on Linux due to invalid target names in the CMake configuration.

Issue Description

The build process for the Linux platform fails with the following errors:

CMake Error at CMakeLists.txt:63 (add_executable):
  The target name "FL Chart App" is reserved or not valid for certain CMake
  features, such as generator expressions, and may result in undefined
  behavior.

CMake Error at CMakeLists.txt:43 (target_compile_features):
  Cannot specify compile features for target "FL Chart App" which is not
  built by this project.
Call Stack (most recent call first):
  CMakeLists.txt:71 (apply_standard_settings)

CMake Error at CMakeLists.txt:74 (target_link_libraries):
  Cannot specify link libraries for target "FL Chart App" which is not built
  by this project.

Steps to Reproduce

  1. Clone the repository and checkout the main branch.
  2. Run flutter run for the Linux platform.
  3. Observe the build failure with the aforementioned error messages.

Root Cause

The target name "FL Chart App" used in the CMake configuration is invalid for certain CMake features and can lead to undefined behavior. CMake target names should not contain spaces or special characters and should adhere to simple alphanumeric naming conventions.

Solution

The solution involves renaming the target in the CMakeLists.txt file to a valid name. The target name was changed from "FL Chart App" to "fLChartApp".

Changes Made In CMakeLists.txt:

# Old target name
# set(BINARY_NAME "FL Chart App")

# New valid target name
set(BINARY_NAME "fLChartApp")

Testing

After making this change, the example app successfully builds and runs on Linux. The new target name adheres to CMake naming conventions and resolves the build issues.

Run flutter clean to clear old build and flutter run again.

fl_chart_linux_app