FindACML.cmake 3.43 KB
Newer Older
1

Blake Nelson's avatar
Blake Nelson committed
2
SET(ACML_USE_SHARED_LIBRARIES OFF CACHE BOOL "Use the ACLM shared library." )
Blake Nelson's avatar
Blake Nelson committed
3
SET(ACML_USE_OPENMP_LIBRARIES ON CACHE BOOL "Use the OpenMP implementation.")
4

Blake Nelson's avatar
Blake Nelson committed
5 6


Blake Nelson's avatar
Blake Nelson committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
MACRO(RESET_VAR_IF_CHANGED toChange toCheck)
	IF( NOT ACML_${toCheck}_PREV_VALUE )
		IF( ${toCheck} )
			SET(NEED_TO_CLEAR TRUE)
		ENDIF( ${toCheck} )
	ENDIF( NOT ACML_${toCheck}_PREV_VALUE )


	IF( NOT ${toCheck} )
		IF( ACML_${toCheck}_PREV_VALUE )
			SET(NEED_TO_CLEAR TRUE)
		ENDIF( ACML_${toCheck}_PREV_VALUE )
	ENDIF( NOT ${toCheck} )

	IF( NEED_TO_CLEAR )
		SET(${toChange} "NOTFOUND" CACHE PATH "" FORCE)
	ENDIF( NEED_TO_CLEAR )

	SET(ACML_${toCheck}_PREV_VALUE ${${toCheck}} CACHE INTERNAL "" FORCE)
ENDMACRO(RESET_VAR_IF_CHANGED toChange)


RESET_VAR_IF_CHANGED( ACML_INCLUDE_PATH ACML_USE_OPENMP_LIBRARIES)
RESET_VAR_IF_CHANGED( ACML_INCLUDE_PATH ACML_USE_SHARED_LIBRARIES)
RESET_VAR_IF_CHANGED( ACML ACML_USE_OPENMP_LIBRARIES)
RESET_VAR_IF_CHANGED( ACML ACML_USE_SHARED_LIBRARIES)
Blake Nelson's avatar
Blake Nelson committed
33 34 35
RESET_VAR_IF_CHANGED( ACML_SEARCH_PATHS ACML_USE_OPENMP_LIBRARIES)
RESET_VAR_IF_CHANGED( ACML_SEARCH_PATHS ACML_USE_SHARED_LIBRARIES)

Blake Nelson's avatar
Blake Nelson committed
36
SET(ACML_BASE_SEARCH_PATHS "/opt/acml" "C:\\AMD\\acml" "C:\\Program Files\\AMD\\acml")
Blake Nelson's avatar
Blake Nelson committed
37
SET(ACML_SEARCH_PATHS "")
Blake Nelson's avatar
Blake Nelson committed
38

Blake Nelson's avatar
Blake Nelson committed
39 40
SET(MP_COMPILER_VERSIONS gfortran64_mp gfortran64_mp_int64 pgi32_mp ifort32_mp)
SET(COMPILER_VERSIONS gfortran64 gfortran64_int64 pgi32 ifort32)
Blake Nelson's avatar
Blake Nelson committed
41 42

SET(COMPILER_VERSION_TO_USE "a")
Blake Nelson's avatar
Blake Nelson committed
43 44

IF( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
45
    SET(COMPILER_VERSION_TO_USE ${MP_COMPILER_VERSIONS})
Blake Nelson's avatar
Blake Nelson committed
46
ELSE( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
47
    SET(COMPILER_VERSION_TO_USE ${COMPILER_VERSIONS})
Blake Nelson's avatar
Blake Nelson committed
48 49
ENDIF( ACML_USE_OPENMP_LIBRARIES )

Blake Nelson's avatar
Blake Nelson committed
50
FOREACH(path_iter ${ACML_BASE_SEARCH_PATHS})
51 52 53 54
    FILE( GLOB install_path ${path_iter}*/ACML-EULA.txt )
    IF (install_path)
        LIST( GET install_path 0 install_path)
        GET_FILENAME_COMPONENT( install_path ${install_path} PATH)
Blake Nelson's avatar
Blake Nelson committed
55
        FOREACH(compiler_iter ${COMPILER_VERSION_TO_USE})
56 57
            LIST(APPEND ACML_SEARCH_PATHS 
                 ${install_path}/${compiler_iter}/include)
Blake Nelson's avatar
Blake Nelson committed
58
        ENDFOREACH(compiler_iter ${COMPILER_VERSION_TO_USE})
59
    ENDIF (install_path)
Blake Nelson's avatar
Blake Nelson committed
60
ENDFOREACH(path_iter ${ACML_BASE_SEARCH_PATHS})
Blake Nelson's avatar
Blake Nelson committed
61 62

FIND_PATH(ACML_INCLUDE_PATH acml.h ${ACML_SEARCH_PATHS} )
63 64
SET(ACML_LIB_PATH ${ACML_INCLUDE_PATH}/../lib)

Blake Nelson's avatar
Blake Nelson committed
65 66
IF( ACML_USE_SHARED_LIBRARIES )
	IF( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
67
		SET(ACML_LIB_NAMES acml_mp acml_mp_dll libacml_mp_dll)
Blake Nelson's avatar
Blake Nelson committed
68
	ELSE( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
69
		SET(ACML_LIB_NAMES acml acml_dll libacml_dll)
Blake Nelson's avatar
Blake Nelson committed
70 71 72
	ENDIF( ACML_USE_OPENMP_LIBRARIES )
ELSE( ACML_USE_SHARED_LIBRARIES )
	IF( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
73
		SET(ACML_LIB_NAMES acml_mp libacml_mp)
Blake Nelson's avatar
Blake Nelson committed
74
	ELSE( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
75
		SET(ACML_LIB_NAMES acml libacml)
Blake Nelson's avatar
Blake Nelson committed
76 77 78 79 80
	ENDIF( ACML_USE_OPENMP_LIBRARIES )
ENDIF( ACML_USE_SHARED_LIBRARIES )

FIND_LIBRARY( ACML NAMES ${ACML_LIB_NAMES} PATHS ${ACML_LIB_PATH} )

Blake Nelson's avatar
Blake Nelson committed
81 82 83
IF( ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" )
	SET( ACML_TARGET_LINK_LIBRARIES ${ACML} gfortran )
ELSE( ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" )
Blake Nelson's avatar
Blake Nelson committed
84
	SET( ACML_TARGET_LINK_LIBRARIES ${ACML} )
Blake Nelson's avatar
Blake Nelson committed
85 86
ENDIF( ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" )

87 88 89 90 91 92 93 94 95 96 97 98 99
IF (ACML_INCLUDE_PATH)
  SET(ACML_FOUND ON)
ENDIF (ACML_INCLUDE_PATH)

IF (ACML_FOUND)
  IF (NOT ACML_FIND_QUIETLY)
     MESSAGE(STATUS "Found ACML: ${ACML_INCLUDE_PATH}")
  ENDIF (NOT ACML_FIND_QUIETLY)
ELSE(ACML_FOUND)
  IF (ACML_FIND_REQUIRED)
     MESSAGE(FATAL_ERROR "Could not find ACML")
  ENDIF (ACML_FIND_REQUIRED)
ENDIF (ACML_FOUND)
Blake Nelson's avatar
Blake Nelson committed
100

101 102
MARK_AS_ADVANCED(ACML ACML_INCLUDE_PATH ACML_SEARCH_PATHS
    ACML_USE_OPENMP_LIBRARIES ACML_USE_SHARED_LIBRARIES)
Blake Nelson's avatar
Blake Nelson committed
103