Skip to content

Commit

Permalink
Made some changes to fix problems with finding cfitsio.
Browse files Browse the repository at this point in the history
	modified:   CMakeLists.txt
	modified:   cmake/Modules/FindCFITSIO.cmake
  • Loading branch information
rbmetcalf committed Feb 6, 2020
1 parent 83bf674 commit 7d9a208
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 23 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ include(GLAMER)
find_package(Threads)

if(ENABLE_FITS)
##find_package(cfitsio REQUIRED)
find_package(CFITSIO REQUIRED)
include_directories(${CFITSIO_INCLUDE_DIRS})
endif()

if(ENABLE_FFTW)
Expand Down
85 changes: 64 additions & 21 deletions cmake/Modules/FindCFITSIO.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,77 @@
# CFITSIO_LIBRARIES - The libraries needed to use CFITSIO
# CFITSIO_DEFINITIONS - Compiler switches required for using CFITSIO

set(CFITSIO CACHE FILEPATH "Path to CFITSIO.")
INCLUDE( FindPackageHandleStandardArgs )

find_path(CFITSIO_INCLUDE_DIR
fitsio.h
HINTS ${CFITSIO}
PATH_SUFFIXES "include"
DOC "CFITSIO include directory"
#set(CFITSIO CACHE FILEPATH "Path to CFITSIO.")

IF( DEFINED ENV{CFITSIO_DIR} )
SET( CFITSIO "$ENV{CFITSIO_DIR}" )
ENDIF()

FIND_PATH( CFITSIO_INCLUDE_DIR
fitsio.h
HINTS ${CFITSIO}
)

FIND_LIBRARY( CFITSIO_LIBRARY
NAMES cfitsio
HINTS ${CFITSIO}
)

find_library(CFITSIO_LIBRARY
NAMES cfitsio libcfitsio
HINTS ${CFITSIO}
PATH_SUFFIXES "lib"
DOC "CFITSIO library"
FIND_PACKAGE_HANDLE_STANDARD_ARGS( CFITSIO DEFAULT_MSG
CFITSIO_INCLUDE_DIR
CFITSIO_LIBRARY
)

set(CFITSIO_LIBRARIES ${CFITSIO_LIBRARY})
set(CFITSIO_INCLUDE_DIRS ${CFITSIO_INCLUDE_DIR})
IF( CFITSIO_FOUND )
SET( CFITSIO_INCLUDE_DIRS ${CFITSIO_INCLUDE_DIR} )
SET( CFITSIO_LIBRARIES ${CFITSIO_LIBRARY} )

MARK_AS_ADVANCED(
CFITSIO_LIBRARY
CFITSIO_INCLUDE_DIR
CFITSIO_DIR
)
ELSE()
SET( CFITSIO_DIR "" CACHE STRING
"An optional hint to a directory for finding `cfitsio`"
)
ENDIF()

###############################################################

include(FindPackageHandleStandardArgs)
#find_path(CFITSIO_INCLUDE_DIR
# fitsio.h
# HINTS ${CFITSIO}
# PATHS
# /usr/local/
# /opt/anaconda3/
# /opt/anaconda2/
# PATH_SUFFIXES "include"
# DOC "CFITSIO include directory"
#)

#set(CFITSIO_INCLUDE_DIRS ${CFITSIO_INCLUDE_DIR})

#find_library(CFITSIO_LIBRARY
# NAMES cfitsio libcfitsio
# HINTS ${CFITSIO}
# PATH_SUFFIXES "lib"
# DOC "CFITSIO library"
#)

#set(CFITSIO_LIBRARIES ${CFITSIO_LIBRARY})

#include(FindPackageHandleStandardArgs)

# handle the QUIETLY and REQUIRED arguments and set CFITSIO_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(
CFITSIO
DEFAULT_MSG
CFITSIO_LIBRARY
CFITSIO_INCLUDE_DIR
)
#find_package_handle_standard_args(
# CFITSIO
# DEFAULT_MSG
# CFITSIO_LIBRARY
# CFITSIO_INCLUDE_DIR
#)

mark_as_advanced(CFITSIO_INCLUDE_DIR CFITSIO_LIBRARY)
#mark_as_advanced(CFITSIO_INCLUDE_DIR CFITSIO_LIBRARY)

0 comments on commit 7d9a208

Please sign in to comment.