On 2021-10-25 "T. Modes" <[email protected]> wrote:
> Andreas Metzler schrieb am Sonntag, 24. Oktober 2021 um 08:47:07 UTC+2:
[...]
> I added all your proposed changes to the patch and added a test if -lm is 
> needed (I still understand why this was not necessary in libpano 13 2.9.20 
> from April.). 

Hello,

I have since realized that libm was broken in the autoconf build script,
too. It is just that everybody had been using the same hotfix for years
and years.

> Could you please test, if this fixes your issues?
[...]
> -set(_common_libs ${TIFF_LIBRARIES} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} 
> ${PNG_LIBRARIES})
> +# check if libm needs additional linker flag
> +include(CheckCSourceCompiles)
> +set(LIBM_TEST_SRC "#include <math.h>\nint main() { float f=exp(2.0); }")
> +check_c_source_compiles("${LIBM_TEST_SRC}" HAVE_EXP)

This check succeeds with gcc because of the gcc-builtin 
https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html
https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#index-fno-builtin
is used but fails later in the real build where the gcc-builtin is not
used. (ansi or or std options set there.) 

Linking against libm if available works for me:
----------------
 set(_common_libs ${TIFF_LIBRARIES} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} 
${PNG_LIBRARIES})

+include(CheckLibraryExists)
+# Does explicit linking against libm work?
+check_library_exists(m exp "" LIBMNEEDED)
+if(LIBMNEEDED)
+    list(APPEND _common_libs "m")
+endif()
+
 # Sparse or dense Levenberg Marquardt
 OPTION(USE_SPARSE_LEVMAR "Use Sparse Levenberg Marquardt algorithm instead of 
dense Levenberg Marquardt algorithm" OFF)
----------------

[...]
>  if(NOT WIN32)
>    # Create and install shared library on non-windows
> -  add_library(pano13 SHARED ${pano13_hdr} ${pano13_res} ${pano13_src})
> +  add_library(pano13 SHARED ${pano13_hdr} ${pano13_src})
     ^^^^^^^^^^^^ This Change ....

[...]
>    set(_pano_target pano13)
>    #create and install static library
>    add_library(pano13a STATIC ${pano13_hdr} ${pano13_res} ${pano13_src})
                                              ^^^^^^^^^^^^^^
                                 ... should be mirrored here

I have attached a updated version of your patch including the two
changes mentioned above.

Regarding my other problem "Tools are not installed to DESTDIR/usr/bin"
it turned out these were disabled for cmake profile "None" which is used
for Debian distribution packages, i.e.:
--------------------------------------------------------------
--- libpano13-2.9.21~rc1+dfsg.orig/tools/CMakeLists.txt
+++ libpano13-2.9.21~rc1+dfsg/tools/CMakeLists.txt
@@ -20,7 +20,8 @@ macro(make_command exe_name source_name)
   list(APPEND extra_commands ${exe_name})
   add_executable(${exe_name} ${source_name})
   target_link_libraries(${exe_name} ${_pano_target} ${_common_libs})
-  install(TARGETS ${exe_name} DESTINATION bin COMPONENT tools CONFIGURATIONS 
Release RelWithDebInfo MinSizeRel)
+  install(TARGETS ${exe_name} DESTINATION bin COMPONENT tools
+         CONFIGURATIONS Release RelWithDebInfo MinSizeRel None)
 endmacro()
--------------------------------------------------------------

OTOH, I wonder why this qualification is there at all, why are the tools
installed for all but one ("Debug") of the 4 predefined CMake
configuration types? I would suggest dropping the whole CONFIGURATIONS
limitation.

TIA, cu Andreas

-- 
`What a good friend you are to him, Dr. Maturin. His other friends are
so grateful to you.'
`I sew his ears on from time to time, sure'

-- 
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- 
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/YXeeXDit5qzi94B0%40argenau.bebt.de.
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -58,23 +58,14 @@ ENDIF(WIN32)
 SET(CMAKE_DEBUG_POSTFIX d)
 
 include(CheckIncludeFiles)
 
 ##  global setup
 project(libpano13)
 
-set(MYLIB "lib")        # default
-if(CMAKE_INSTALL_PREFIX STREQUAL "/usr")
-  get_property(USE_64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
-  if(USE_64)
-    include(GNUInstallDirs)
-    set(MYLIB ${CMAKE_INSTALL_LIBDIR})
-  endif()
-endif()
-
 ##
 #  This must come before FINDs for tiff, jpeg, png, zlib to enable
 #  finding the wxWidgets distributions of those packages on Windows.
 IF(WIN32)
   ADD_DEFINITIONS(-D__Win__)
   OPTION(BUILD_DLL "Build dynamic libpano 13" ON)
   OPTION(BUILD_WINGUI "Build with Windows GUI, otherwise the information is printed to shell/cmd.exe" OFF)
@@ -117,14 +108,21 @@ FIND_PACKAGE(JPEG REQUIRED)
 INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR})
 FIND_PACKAGE(PNG REQUIRED)
 INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
 INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
 
 set(_common_libs ${TIFF_LIBRARIES} ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${PNG_LIBRARIES})
 
+include(CheckLibraryExists)
+# Does explicit linking against libm work?
+check_library_exists(m exp "" LIBMNEEDED)
+if(LIBMNEEDED)
+    list(APPEND _common_libs "m")
+endif()
+
 # Sparse or dense Levenberg Marquardt
 OPTION(USE_SPARSE_LEVMAR "Use Sparse Levenberg Marquardt algorithm instead of dense Levenberg Marquardt algorithm" OFF)
 IF(USE_SPARSE_LEVMAR)
   FIND_PACKAGE(SUITESPARSE REQUIRED)
   LIST(APPEND _common_libs ${SUITESPARSE_LIBRARIES})
 ENDIF()
 
@@ -280,38 +278,38 @@ IF(USE_SPARSE_LEVMAR)
   INCLUDE_DIRECTORIES(${SUITESPARSE_INCLUDE_DIRS})
 ELSE()
   LIST(APPEND pano13_src lmdif.c)
 ENDIF()
 
 if(NOT WIN32)
   # Create and install shared library on non-windows
-  add_library(pano13 SHARED ${pano13_hdr} ${pano13_res} ${pano13_src})
+  add_library(pano13 SHARED ${pano13_hdr} ${pano13_src})
   target_link_libraries(pano13 ${_common_libs})
   set_target_properties(pano13 PROPERTIES VERSION "3.0.0" SOVERSION "3")
-  install(TARGETS pano13 LIBRARY DESTINATION ${MYLIB} COMPONENT libraries)
+  install(TARGETS pano13 LIBRARY COMPONENT libraries)
   set(_pano_target pano13)
   #create and install static library
-  add_library(pano13a STATIC ${pano13_hdr} ${pano13_res} ${pano13_src})
+  add_library(pano13a STATIC ${pano13_hdr} ${pano13_src})
   set_target_properties(pano13a PROPERTIES OUTPUT_NAME pano13)
-  install(TARGETS pano13a ARCHIVE DESTINATION ${MYLIB} COMPONENT libraries)
+  install(TARGETS pano13a ARCHIVE COMPONENT libraries)
 else()
   IF(BUILD_DLL)
     # Create and install shared library
     ADD_DEFINITIONS(-DPANO13_DLL)
     add_library(pano13 SHARED ${pano13_hdr} ${pano13_res} ${pano13_src})
     target_link_libraries(pano13 ${_common_libs})
     set_target_properties(pano13 PROPERTIES VERSION "3.0.0" SOVERSION "3")
     IF(MINGW)
       set_target_properties(pano13 PROPERTIES PREFIX "")
     ENDIF()
-    install(TARGETS pano13 RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib COMPONENT libraries)
+    install(TARGETS pano13 COMPONENT libraries)
   ELSE(BUILD_DLL)
     #create and install static library
     add_library(pano13 STATIC ${pano13_hdr} ${pano13_res} ${pano13_src})
-    install(TARGETS pano13 ARCHIVE DESTINATION ${MYLIB} COMPONENT libraries)
+    install(TARGETS pano13 COMPONENT libraries)
   ENDIF(BUILD_DLL)
   set(_pano_target pano13)
 endif()
 
 IF( CMAKE_SIZEOF_VOID_P EQUAL 8 AND MSVC )
 	# Error detected with generator Visual Studio 10 Win64
 	# > LINK : warning LNK4068: /MACHINE not specified; defaulting to X86
@@ -397,15 +395,15 @@ set(exec_prefix ${CMAKE_INSTALL_PREFIX})
 set(includedir ${CMAKE_INSTALL_PREFIX}/include)
 set(LIB_JPEG ${JPEG_LIBRARY})
 set(LIB_TIFF ${TIFF_LIBRARY})
 set(LIB_ZLIB ${ZLIB_LIBRARY})
 set(LIB_PNG ${PNG_LIBRARY})
 set(VERSION ${PACKAGE_VERSION})
 configure_file("${TOP_SRC_DIR}/libpano13.pc.in" "${CMAKE_BINARY_DIR}/libpano13.pc" @ONLY)
-install(FILES "${CMAKE_BINARY_DIR}/libpano13.pc" DESTINATION "${MYLIB}/pkgconfig" COMPONENT libraries)
+install(FILES "${CMAKE_BINARY_DIR}/libpano13.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT libraries)
 
 set(CPACK_PACKAGE_VERSION_MAJOR "${PANO_MAJOR_VERSION}")
 set(CPACK_PACKAGE_VERSION_MINOR "${PANO_MINOR_VERSION}")
 set(CPACK_PACKAGE_VERSION_PATCH "${PANO_PATCH_VERSION}")
 set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
 
 set(CPACK_SOURCE_IGNORE_FILES
@@ -583,15 +581,15 @@ if(CPACK_BINARY_DEB)
   # use, i.e. don't skip the full RPATH for the build tree
   SET(CMAKE_SKIP_BUILD_RPATH  FALSE)
 
   # when building, don't use the install RPATH already
   # (but later on when installing)
   SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
 
-  SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${MYLIB}")
+  SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
   SET(CPACK_DEBIAN_PACKAGE_DEBUG ON)
 
   # add the automatically determined parts of the RPATH
   # which point to directories outside the build tree to the install RPATH
   SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
 
   #this environment will be used by dpkg-shlibdebs to find local created libs

Reply via email to