Skip to content

Commit

Permalink
Update the installation prefix in the pkgConfig file
Browse files Browse the repository at this point in the history
  • Loading branch information
dr8co committed Apr 30, 2024
1 parent c7625a1 commit 7040d43
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions ConfigurePkgConfig.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
var
AppPath: string;

procedure ReplacePlaceholderInPkgConfig;
var
PkgConfigFile: TStringList;
Index: Integer;
ModifiedAppPath: string;
begin
// Read the contents of the liblite-string.pc file
PkgConfigFile := TStringList.Create;
try
PkgConfigFile.LoadFromFile(ExpandConstant('{app}\lib\pkgconfig\liblite-string.pc'));

// Modify the installation prefix to match the chosen installation destination
if PkgConfigFile.Count > 0 then
begin
// Replace backslashes with forward slashes
ModifiedAppPath := '';
for Index := 1 to Length(AppPath) do
begin
if AppPath[Index] = '\' then
ModifiedAppPath := ModifiedAppPath + '/'
else
ModifiedAppPath := ModifiedAppPath + AppPath[Index];
end;
// Update the prefix
PkgConfigFile[0] := 'prefix = "' + ModifiedAppPath + '"';
end;

// Write the modified contents back to the file
PkgConfigFile.SaveToFile(ExpandConstant('{app}\lib\pkgconfig\liblite-string.pc'));
finally
PkgConfigFile.Free;
end;
end;

// Run after the installation has completed
procedure DeinitializeSetup();
begin
AppPath := ExpandConstant('{app}');
ReplacePlaceholderInPkgConfig;
end;
1 change: 1 addition & 0 deletions cmake/Packing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,6 @@ set(CPACK_INNOSETUP_SETUP_DisableWelcomePage OFF)
set(CPACK_INNOSETUP_SETUP_AppCopyright "Copyright (C) 2024 Ian Duncan")
set(CPACK_INNOSETUP_SETUP_AppComments "For more information, visit https://github.com/dr8co/LiteString")
set(CPACK_INNOSETUP_SETUP_VersionInfoVersion "${CPACK_PACKAGE_VERSION}")
set(CPACK_INNOSETUP_CODE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/ConfigurePkgConfig.pas")

include(CPack)

0 comments on commit 7040d43

Please sign in to comment.