Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 13, 2025

  • Analyzed the current CMakeLists.txt in power_grid_model_c/power_grid_model_c/ directory
  • Confirmed that BUILD_SHARED_LIBS is not currently used anywhere in the repository
  • Identified the target file that needs modification: power_grid_model_c/power_grid_model_c/CMakeLists.txt
  • Found the line that needs changing: add_library(power_grid_model_c SHARED on line 6
  • Implement the DEFAULT_SHARED variable logic to control library type
  • Test the implementation with both BUILD_SHARED_LIBS defined and undefined scenarios
  • Verify the changes work for both standalone and submodule usage patterns
  • Validate that no existing functionality is broken

Summary: Need to refactor the CMakeLists.txt to use a DEFAULT_SHARED variable that checks if BUILD_SHARED_LIBS is defined by parent/user, defaulting to SHARED if not set. The current hardcoded SHARED specification needs to be made conditional while maintaining compatibility.

Original prompt

Refactor the CMakeLists.txt in the power_grid_model_c directory to support default shared library builds unless BUILD_SHARED_LIBS is set by the parent or user. Use a DEFAULT_SHARED variable to concisely control the add_library type, avoiding code duplication. This ensures maximum compatibility for both standalone and submodule usage, while minimizing changes to the repository's structure or logic. The implementation should check if BUILD_SHARED_LIBS is defined; if so, add_library uses the default (user/parent controlled); otherwise, add_library uses SHARED for the power_grid_model_c target. Do not set or overwrite BUILD_SHARED_LIBS anywhere in the repo. Apply only the necessary minimal changes for this logic.

This pull request was created as a result of the following prompt from Copilot chat.

Refactor the CMakeLists.txt in the power_grid_model_c directory to support default shared library builds unless BUILD_SHARED_LIBS is set by the parent or user. Use a DEFAULT_SHARED variable to concisely control the add_library type, avoiding code duplication. This ensures maximum compatibility for both standalone and submodule usage, while minimizing changes to the repository's structure or logic. The implementation should check if BUILD_SHARED_LIBS is defined; if so, add_library uses the default (user/parent controlled); otherwise, add_library uses SHARED for the power_grid_model_c target. Do not set or overwrite BUILD_SHARED_LIBS anywhere in the repo. Apply only the necessary minimal changes for this logic.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@TonyXiang8787 TonyXiang8787 deleted the copilot/refactor-cmakelists-for-shared-libs branch October 13, 2025 07:44
@Copilot Copilot AI requested a review from TonyXiang8787 October 13, 2025 07:44
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.

2 participants