Skip to content

Modernize CMakeLists.txt for inifile-cpp#48

Open
abin-z wants to merge 8 commits intoRookfighter:mainfrom
abin-z:main
Open

Modernize CMakeLists.txt for inifile-cpp#48
abin-z wants to merge 8 commits intoRookfighter:mainfrom
abin-z:main

Conversation

@abin-z
Copy link

@abin-z abin-z commented Mar 3, 2026

Modernize CMakeLists.txt for inifile-cpp

This PR updates the CMakeLists.txt to a more modern, target-oriented CMake style while keeping the previous functionality intact.

Main changes

  1. Modern CMake targets

    • inicpp is now an INTERFACE library with proper target_compile_features.
    • Compiler options and include paths are applied per target instead of globally.
  2. C++ standard

    • Explicit cxx_std_11 declared via target_compile_features.
    • Removes global CMake variables (CMAKE_CXX_STANDARD) for cleaner builds.
  3. Option naming

    • All options prefixed with INIFILE_CPP_ to avoid global conflicts:
      • INIFILE_CPP_GENERATE_COVERAGE
      • INIFILE_CPP_BUILD_TESTS
      • INIFILE_CPP_BUILD_EXAMPLES
  4. Coverage

    • Enabled only for master project and GCC/Clang.
    • Message displayed when coverage is enabled.
    • Avoids polluting downstream targets when the library is used via add_subdirectory.
  5. Tests and examples

    • Conditional inclusion only when master project.
    • Clear build messages to inform user.
  6. Install

    • Uses GNUInstallDirs for portable installation paths.
    • Installs all header files in include/ directory rather than a single file.

Benefits

  • Fully Modern CMake and target-oriented
  • Cleaner and safer build system
  • Better separation between library, tests, and examples
  • Easier to maintain and extend for future development

Modern CMake: https://cliutils.gitlab.io/modern-cmake/README.html

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.40%. Comparing base (7e49789) to head (27e0df2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #48      +/-   ##
==========================================
- Coverage   93.84%   93.40%   -0.44%     
==========================================
  Files           1        1              
  Lines         341      288      -53     
==========================================
- Hits          320      269      -51     
+ Misses         21       19       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant