Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make cmake based installation identical to that from autotools #23

Closed
badshah400 opened this issue Jul 3, 2024 · 2 comments
Closed

Comments

@badshah400
Copy link

badshah400 commented Jul 3, 2024

For openSUSE RPM packages, we are trying to prefer cmake based builds over autotools ones where possible and I tried to switch our cfitsio (version 4.4.0) to build using cmake as well. Unfortunately, the current cmake scripts have some shortcomings in comparison to builds using ./configure that seemed not too difficult to fix. So, I wrote the following patches to make, for example, the pkgconfig destination dir conform to standard libdir, use lower-case names for the executable utilities like changing Funcpack (in cmake) to funcpack (as in the autotools installation and as referred to in the user guides), etc. Here are these patches, in the hope that they may be incorporated upstream (I could a PR if that is the more preferred way of incorporating these).

Thanks in advance.

Patches to make cmake builds identical to autotools-based

Pkgconfig and cmake scripts installation dir

---
 CMakeLists.txt |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: cfitsio-4.4.0/CMakeLists.txt
===================================================================
--- cfitsio-4.4.0.orig/CMakeLists.txt
+++ cfitsio-4.4.0/CMakeLists.txt
@@ -358,7 +358,7 @@ ENDIF(UTILS)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cfitsio.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/cfitsio.pc @ONLY)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cfitsio-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cfitsio-config.cmake @ONLY)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cfitsio-config-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/cfitsio-config-version.cmake @ONLY)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cfitsio.pc DESTINATION lib/pkgconfig/)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cfitsio.pc DESTINATION ${LIB_DESTINATION}/pkgconfig/)
 install(FILES ${CFITSIO_BINARY_DIR}/cfitsio-config.cmake
               ${CFITSIO_BINARY_DIR}/cfitsio-config-version.cmake
-              DESTINATION lib/cfitsio-${CFITSIO_VERSION})
+              DESTINATION ${LIB_DESTINATION}/cfitsio-${CFITSIO_VERSION})

Lower-case utility names

---
 CMakeLists.txt |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Index: cfitsio-4.4.0/CMakeLists.txt
===================================================================
--- cfitsio-4.4.0.orig/CMakeLists.txt
+++ cfitsio-4.4.0/CMakeLists.txt
@@ -326,29 +326,29 @@ ENDIF(TESTS)
 #==============================================================================
 IF (UTILS)
 
-    ADD_EXECUTABLE(FPack utilities/fpack.c utilities/fpackutil.c)
-    TARGET_LINK_LIBRARIES(FPack ${LIB_NAME})
+    ADD_EXECUTABLE(fpack utilities/fpack.c utilities/fpackutil.c)
+    TARGET_LINK_LIBRARIES(fpack ${LIB_NAME})
 
-    ADD_EXECUTABLE(Funpack utilities/funpack.c utilities/fpackutil.c)
-    TARGET_LINK_LIBRARIES(Funpack ${LIB_NAME})
+    ADD_EXECUTABLE(funpack utilities/funpack.c utilities/fpackutil.c)
+    TARGET_LINK_LIBRARIES(funpack ${LIB_NAME})
 
-    ADD_EXECUTABLE(Fitscopy utilities/fitscopy.c)
-    TARGET_LINK_LIBRARIES(Fitscopy ${LIB_NAME})
+    ADD_EXECUTABLE(fitscopy utilities/fitscopy.c)
+    TARGET_LINK_LIBRARIES(fitscopy ${LIB_NAME})
 
-    ADD_EXECUTABLE(Fitsverify
+    ADD_EXECUTABLE(fitsverify
                   utilities/ftverify.c utilities/fvrf_data.c
                   utilities/fvrf_file.c utilities/fvrf_head.c
                   utilities/fvrf_key.c utilities/fvrf_misc.c)
-    TARGET_COMPILE_DEFINITIONS(Fitsverify PRIVATE -DSTANDALONE)
-    TARGET_LINK_LIBRARIES(Fitsverify ${LIB_NAME})
+    TARGET_COMPILE_DEFINITIONS(fitsverify PRIVATE -DSTANDALONE)
+    TARGET_LINK_LIBRARIES(fitsverify ${LIB_NAME})
 
     # To expand the command line arguments in Windows, see:
     # http://msdn.microsoft.com/en-us/library/8bch7bkk.aspx
     if(MSVC AND NOT CMAKE_SYSTEM_NAME MATCHES "WindowsStore")
-      set_target_properties(FPack Funpack PROPERTIES LINK_FLAGS "setargv.obj")
+      set_target_properties(fpack funpack PROPERTIES LINK_FLAGS "setargv.obj")
     endif(MSVC)
 
-    install(TARGETS FPack Funpack Fitscopy Fitsverify RUNTIME DESTINATION bin)
+    install(TARGETS fpack funpack fitscopy fitsverify RUNTIME DESTINATION bin)
 
 ENDIF(UTILS)

Allow user specific incdir

---
 CMakeLists.txt |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: cfitsio-4.4.0/CMakeLists.txt
===================================================================
--- cfitsio-4.4.0.orig/CMakeLists.txt
+++ cfitsio-4.4.0/CMakeLists.txt
@@ -219,7 +219,7 @@ ENDIF()
 
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
 set (LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
-set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/")
+set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/" CACHE PATH "Install dir for header files")
 set (BIN_DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
 
 SET(H_FILES fitsio.h fitsio2.h longnam.h)
@bryanirby
Copy link
Collaborator

Thanks for the comments, we'll look into incorporating your suggestions as soon as possible.

bryanirby added a commit that referenced this issue Jul 8, 2024
#23 (#23)

Changes the case of the cmake-built utilities (e.g., FPack -> fpack) and pkgconfig destination dir to conform with standard libdir
@bryanirby
Copy link
Collaborator

@badshah400 : I've checked this update onto the 'develop' branch.

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

No branches or pull requests

2 participants