Hi Ole,

Thanks for looking into this. I did some analysis and found that Radler was in fact still build as static library in wsclean version 3.4. This was corrected only in:
- https://git.astron.nl/RD/radler/-/merge_requests/123
and
- https://gitlab.com/aroffringa/wsclean/-/merge_requests/591
These were merged only after releasing v3.4. My bug report was therefore not accurate in assuming that this was caused by a Debian setting.

To make WSClean 3.4 work, either those commits would have to be applied to the code base to link radler statically, or the libradler.so library needs to be shipped along with wsclean. The first option I have tested with the script provided below in a wsclean v3.4 git cloned directory, and that works. I guess you're not checking out the git repositories in the Debian build so I've also made a patch that can be applied with "patch -s -p1 < link-radler-statically.patch" from the wsclean v3.4 dir. It's attached to this mail. I hope this patch suffices for the Debian build, otherwise let me know if I can do something else to help.

When we release a newer wsclean version, the patch is no longer necessary. However, the release of wsclean v3.5 will probably take some time, and does have quite some changes, so a 3.4 build would be nice.

Another thing: would it be possible to run 'wsclean --version' in the build just to see if it succeeds? That should at least catch any linking issues like here. There's also a much bigger wsclean test-suite, but that might be a bit overkill for Debian, as it takes a considerable amount of time and resources to run, and getting the tests correctly through all debian platforms will be a bit challenging I think (not unlike Casacore, whose tests are actually somewhat less demanding).

Thanks for your help, Ole!

Regards,
André

# Building WSClean 3.4 with Radler as static library
<in wsclean v3.4 directory>

# Make sure submodules are present and at the right commit
# (not sure this is necessary in the Debian build)
mkdir build
cd build
cmake .. <OTHER OPTIONS>
cd ..

# Merge https://gitlab.com/aroffringa/wsclean/-/merge_requests/591
git cherry-pick 45c51219c0ea2deafb5de9edf2dddfda509f779b

# Merge https://git.astron.nl/RD/radler/-/merge_requests/123
cd external/radler
git cherry-pick 7fec4c029d62dcb664d894eae6909fa4ca92b642

cd ../../build
make -j`nproc`
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f3f9b3d5..46b4501e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -235,7 +235,7 @@ add_definitions(-DHAVE_GSL)
 # Radler
 set(RADLER_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/external/radler)
 set(RADLER_LIB
-    ${RADLER_INSTALL_PREFIX}/lib/libradler${CMAKE_SHARED_LIBRARY_SUFFIX})
+    ${RADLER_INSTALL_PREFIX}/lib/libradler${CMAKE_STATIC_LIBRARY_SUFFIX})
 ExternalProject_Add(
   radler-module
   SOURCE_DIR ${CMAKE_SOURCE_DIR}/external/radler
@@ -409,16 +409,17 @@ set(ALL_LIBRARIES
 include("${CMAKE_CURRENT_LIST_DIR}/external/aocommon/CMake/CheckBLAS.cmake")
 check_blas(LIBRARIES ${ALL_LIBRARIES})
 # Radler lib cannot be checked on BLAS consistenty as it doesn't exist
-# at cmake time.
-list(APPEND ALL_LIBRARIES ${RADLER_LIB})
+# at cmake time. It needs to be first in the link order because Radler
+# itself also depends on some of the libraries in the ALL_LIBRARIES list.
+list(PREPEND ALL_LIBRARIES ${RADLER_LIB})
 
 add_library(wsclean-lib STATIC ${WSCLEANFILES})
-target_link_libraries(wsclean-lib PRIVATE pybind11::embed ${ALL_LIBRARIES})
+target_link_libraries(wsclean-lib PRIVATE ${ALL_LIBRARIES} pybind11::embed)
 set_target_properties(wsclean-lib PROPERTIES OUTPUT_NAME wsclean)
 set_target_properties(wsclean-lib PROPERTIES SOVERSION ${WSCLEAN_VERSION_SO})
 
 add_library(wsclean-shared SHARED ${WSCLEANFILES})
-target_link_libraries(wsclean-shared PRIVATE pybind11::embed ${ALL_LIBRARIES})
+target_link_libraries(wsclean-shared PRIVATE ${ALL_LIBRARIES} pybind11::embed)
 set_target_properties(wsclean-shared PROPERTIES SOVERSION ${WSCLEAN_VERSION_SO})
 
 add_executable(wsclean main/main.cpp)
@@ -445,9 +446,6 @@ install(TARGETS wsclean DESTINATION bin)
 install(TARGETS wsclean-lib DESTINATION lib)
 install(TARGETS chgcentre DESTINATION bin)
 install(FILES interface/wscleaninterface.h DESTINATION include)
-# Installing the radler library to ${CMAKE_INSTALL_FULL_LIBDIR}
-# ensures that users do not manually have to set the LD_LIBRARY_PATH
-install(FILES ${RADLER_LIB} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
 
 if(MPI_FOUND)
   install(TARGETS wsclean-mp DESTINATION bin)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 6d9e036e..9997ab6a 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -89,7 +89,7 @@ ExternalProject_Add(
   BUILD_COMMAND ""
   INSTALL_COMMAND "")
 
-set(TEST_LIBRARIES pybind11::embed ${ALL_LIBRARIES}
+set(TEST_LIBRARIES ${ALL_LIBRARIES} pybind11::embed
                    ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
 
 target_link_libraries(unittest PRIVATE ${TEST_LIBRARIES})
diff --git a/external/radler/cpp/CMakeLists.txt b/external/radler/cpp/CMakeLists.txt
index 3d39b31..acdd28a 100644
--- a/external/radler/cpp/CMakeLists.txt
+++ b/external/radler/cpp/CMakeLists.txt
@@ -9,7 +9,8 @@ function(install_headers_with_directory HEADER_LIST)
   endforeach(HEADER)
 endfunction(install_headers_with_directory)
 
-add_library(${PROJECT_NAME} SHARED "")
+add_library(radler STATIC "")
+set_target_properties(radler PROPERTIES POSITION_INDEPENDENT_CODE True)
 
 set(RADLER_FILES
     radler.cc
@@ -56,16 +57,15 @@ set_source_files_properties(
 set_source_files_properties(algorithms/python_deconvolution.cpp
                             PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
 
-target_sources(${PROJECT_NAME} PRIVATE ${RADLER_FILES})
-target_link_libraries(${PROJECT_NAME} ${RADLER_TARGET_LIBS})
-target_include_directories(${PROJECT_NAME} SYSTEM
-                           PUBLIC ${RADLER_TARGET_INCLUDE_DIRS})
+target_sources(radler PRIVATE ${RADLER_FILES})
+target_link_libraries(radler ${RADLER_TARGET_LIBS})
+target_include_directories(radler SYSTEM PUBLIC ${RADLER_TARGET_INCLUDE_DIRS})
 
 # Allows including the paths relative to base algorithm, in line with Google
 # style
 # https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
 target_include_directories(
-  ${PROJECT_NAME} PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+  radler PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
 
 target_compile_options(radler PRIVATE -O3 -Wall -Wzero-as-null-pointer-constant)
 
@@ -85,11 +85,9 @@ endif()
 
 if(NOT COMPILE_AS_EXTERNAL_PROJECT)
   include(GNUInstallDirs)
-  install(TARGETS ${PROJECT_NAME}
-          LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
+  install(TARGETS radler ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
 else()
-  install(TARGETS ${PROJECT_NAME}
-          LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
+  install(TARGETS radler ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
 endif()
 
 set(PUBLIC_HEADERS

Reply via email to