diff -Naur cfitsio-3.48.orig/cfitsio.pc.in cfitsio-3.48/cfitsio.pc.in
--- cfitsio-3.48.orig/cfitsio.pc.in	2020-08-20 14:15:09.062978500 -0400
+++ cfitsio-3.48/cfitsio.pc.in	2020-08-20 14:16:14.543075400 -0400
@@ -1,12 +1,11 @@
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-libdir=@libdir@
-includedir=@includedir@
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=${prefix}/@PC_LIB_DIR@
+includedir=${prefix}/@PC_INCLUDE_DIR@
 
 Name: cfitsio
 Description: FITS File Subroutine Library
 URL: https://heasarc.gsfc.nasa.gov/fitsio/
 Version: @CFITSIO_MAJOR@.@CFITSIO_MINOR@
 Libs: -L${libdir} -lcfitsio
-Libs.private: -lm @LIBS@
+Libs.private: -lm -lz @LIBS@
 Cflags: -I${includedir}
diff -Naur cfitsio-3.48.orig/CMakeLists.txt cfitsio-3.48/CMakeLists.txt
--- cfitsio-3.48.orig/CMakeLists.txt	2020-08-20 14:15:08.982900500 -0400
+++ cfitsio-3.48/CMakeLists.txt	2020-08-20 14:23:04.812703800 -0400
@@ -21,12 +21,13 @@
 
 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/cfitsio")
 
 # Define project version
 SET(${PROJECT_NAME}_MAJOR_VERSION 3)
 SET(${PROJECT_NAME}_MINOR_VERSION 48)
 SET(${PROJECT_NAME}_VERSION ${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION})
+SET(${PROJECT_NAME}_SOVERSION ${${PROJECT_NAME}_MAJOR_VERSION})
 SET(LIB_NAME cfitsio)
 
 # Microsoft Visual Studio:
@@ -132,15 +133,24 @@
 ENDIF()
 
 ADD_LIBRARY(${LIB_NAME} ${LIB_TYPE} ${H_FILES} ${SRC_FILES})
-TARGET_LINK_LIBRARIES(${LIB_NAME} ${PTHREADS_LIBRARY} ${M_LIB} ${CURL_LIBRARIES})
+TARGET_LINK_LIBRARIES(${LIB_NAME} ${PTHREADS_LIBRARY} ${M_LIB} ${CURL_LIBRARIES} z)
 
 SET_TARGET_PROPERTIES(${LIB_NAME} PROPERTIES VERSION ${${PROJECT_NAME}_VERSION} SOVERSION ${${PROJECT_NAME}_MAJOR_VERSION})
-install(TARGETS ${LIB_NAME} DESTINATION ${LIB_DESTINATION})
-install(TARGETS ${LIB_NAME}
-                            RUNTIME DESTINATION bin
-                            LIBRARY DESTINATION lib
-                            ARCHIVE DESTINATION lib)
-install(FILES ${H_FILES} DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
+IF(WIN32)
+    SET_TARGET_PROPERTIES(${LIB_NAME}
+        PROPERTIES
+        OUTPUT_NAME ${LIB_NAME}
+        RUNTIME_OUTPUT_NAME "${LIB_NAME}-${${PROJECT_NAME}_SOVERSION}"
+        ARCHIVE_OUTPUT_NAME ${LIB_NAME}
+    )
+ENDIF(WIN32)
+
+INSTALL(TARGETS ${LIB_NAME}
+    RUNTIME DESTINATION bin COMPONENT libraries
+    ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT libraries
+    LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT libraries
+)
+INSTALL(FILES ${H_FILES} DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
 
 # Only build test code and executables if building a shared library:
 IF (BUILD_SHARED_LIBS)
@@ -160,9 +170,11 @@
 
     ADD_EXECUTABLE(FPack fpack.c fpackutil.c)
     TARGET_LINK_LIBRARIES(FPack ${LIB_NAME})
+    INSTALL(TARGETS FPack DESTINATION bin)
 
     ADD_EXECUTABLE(Funpack funpack.c fpackutil.c)
     TARGET_LINK_LIBRARIES(Funpack ${LIB_NAME})
+    INSTALL(TARGETS Funpack DESTINATION bin)
 
     ADD_EXECUTABLE(Fitscopy fitscopy.c)
     TARGET_LINK_LIBRARIES(Fitscopy ${LIB_NAME})
@@ -175,5 +187,7 @@
 
 ENDIF(BUILD_SHARED_LIBS)
 
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cfitsio.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/cfitsio.pc @ONLY)
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cfitsio.pc DESTINATION lib/pkgconfig/)
+STRING(REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}/" "" PC_INCLUDE_DIR ${INCLUDE_INSTALL_DIR})
+STRING(REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}/" "" PC_LIB_DIR lib${LIB_SUFFIX} )
+CONFIGURE_FILE(cfitsio.pc.in cfitsio.pc @ONLY)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/cfitsio.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig)
