Commit 1110699 for zlib
commit 1110699c0fcb6c4d8e040bbc65035afbb1c17a25
Author: Vollstrecker <werner@vollstreckernet.de>
Date: Sat Feb 28 11:16:18 2026 +0100
CMake: Enable Ada to compile in different directories.
diff --git a/contrib/ada/cmake/Modules/CMakeADAInformation.cmake b/contrib/ada/cmake/Modules/CMakeADAInformation.cmake
index 923788f..d0bcf4f 100644
--- a/contrib/ada/cmake/Modules/CMakeADAInformation.cmake
+++ b/contrib/ada/cmake/Modules/CMakeADAInformation.cmake
@@ -90,6 +90,7 @@ function(ada_add_executable)
set_target_properties(${ARGV0}
PROPERTIES
ADDITIONAL_CLEAN_FILES "${CLEAN_FILES}")
+ target_link_options(${ARGV0} PRIVATE "-aOCMakeFiles/${ARGV0}.dir/")
endif(ARGC GREATER 1)
endfunction(ada_add_executable)
@@ -113,6 +114,7 @@ function(ada_add_library)
PROPERTIES
ADDITIONAL_CLEAN_FILES "${CLEAN_FILES};dummylib.adb;dummylib.ali;dummylib.o"
ALI_FLAG "-aO${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${ARGV0}.dir/")
+ target_link_options(${ARGV0} PRIVATE "-aOCMakeFiles/${ARGV0}.dir/")
endif(ARGC GREATER 2)
endfunction(ada_add_library)
diff --git a/contrib/ada/cmake/binder_helper.cmake b/contrib/ada/cmake/binder_helper.cmake
index 87b3202..b4e11c4 100644
--- a/contrib/ada/cmake/binder_helper.cmake
+++ b/contrib/ada/cmake/binder_helper.cmake
@@ -8,7 +8,8 @@ if(NOT CMAKE_ARGV3)
message(FATAL_ERROR "binder not set")
endif(NOT CMAKE_ARGV3)
-string(REPLACE ".o" ".ali" ALI ${CMAKE_ARGV4})
+string(REPLACE ".o" ".ali" ALIPATH ${CMAKE_ARGV4})
+cmake_path(GET ALIPATH FILENAME ALI)
set (REACHED_FLAGS FALSE)
#iterate over additional objects, only the main one is needed
diff --git a/contrib/ada/cmake/exe_link_helper.cmake b/contrib/ada/cmake/exe_link_helper.cmake
index 7937890..65ecfe2 100644
--- a/contrib/ada/cmake/exe_link_helper.cmake
+++ b/contrib/ada/cmake/exe_link_helper.cmake
@@ -33,7 +33,9 @@ foreach(arg RANGE 5 ${CMAKE_ARGC})
if(REACHED_LIBS)
list(APPEND LIBS "${CMAKE_ARGV${arg}}")
elseif(REACHED_OBJ AND NOT ALI)
- string(REPLACE ".o" ".ali" ALI "${CMAKE_ARGV${arg}}")
+ string(REPLACE ".o" ".ali" ALIPATH "${CMAKE_ARGV${arg}}")
+ # Remove every __/ as gnat doesn't produce output in different path
+ string(REPLACE "__\/" "" ALI "${ALIPATH}")
else(REACHED_LIBS)
string(SUBSTRING "${CMAKE_ARGV${arg}}" 0 3 start)