FindACML.cmake 3.42 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
# The various supported versions.  When new versions come out this will need
# to be updated to allow automatic detection.
Blake Nelson's avatar
Blake Nelson committed
41
SET(ACML_VERSIONS 4.2.0 4.1.0 4.0.0 3.5.0 3.6.0 3.6.1)
Blake Nelson's avatar
Blake Nelson committed
42

Blake Nelson's avatar
Blake Nelson committed
43 44
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
45 46

SET(COMPILER_VERSION_TO_USE "a")
Blake Nelson's avatar
Blake Nelson committed
47 48

IF( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
49
    SET(COMPILER_VERSION_TO_USE ${MP_COMPILER_VERSIONS})
Blake Nelson's avatar
Blake Nelson committed
50
ELSE( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
51
    SET(COMPILER_VERSION_TO_USE ${COMPILER_VERSIONS})
Blake Nelson's avatar
Blake Nelson committed
52 53
ENDIF( ACML_USE_OPENMP_LIBRARIES )

Blake Nelson's avatar
Blake Nelson committed
54 55 56 57 58 59 60
FOREACH(path_iter ${ACML_BASE_SEARCH_PATHS})
    FOREACH(version_iter ${ACML_VERSIONS})
        FOREACH(compiler_iter ${COMPILER_VERSION_TO_USE})
            LIST(APPEND ACML_SEARCH_PATHS ${path_iter}${version_iter}/${compiler_iter}/include)
        ENDFOREACH(compiler_iter ${COMPILER_VERSION_TO_USE})
    ENDFOREACH(version_iter ${ACML_VERSIONS})	     
ENDFOREACH(path_iter ${ACML_BASE_SEARCH_PATHS})
Blake Nelson's avatar
Blake Nelson committed
61

Blake Nelson's avatar
Blake Nelson committed
62
#MESSAGE(${ACML_SEARCH_PATHS})
Blake Nelson's avatar
Blake Nelson committed
63
FIND_PATH(ACML_INCLUDE_PATH acml.h ${ACML_SEARCH_PATHS} )
64
SET(ACML_LIB_PATH ${ACML_INCLUDE_PATH}/../lib)
Blake Nelson's avatar
Blake Nelson committed
65
#MESSAGE(${ACML_LIB_PATH})
66

Blake Nelson's avatar
Blake Nelson committed
67 68
IF( ACML_USE_SHARED_LIBRARIES )
	IF( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
69
		SET(ACML_LIB_NAMES acml_mp acml_mp_dll libacml_mp_dll)
Blake Nelson's avatar
Blake Nelson committed
70
	ELSE( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
71
		SET(ACML_LIB_NAMES acml acml_dll libacml_dll)
Blake Nelson's avatar
Blake Nelson committed
72 73 74
	ENDIF( ACML_USE_OPENMP_LIBRARIES )
ELSE( ACML_USE_SHARED_LIBRARIES )
	IF( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
75
		SET(ACML_LIB_NAMES acml_mp libacml_mp)
Blake Nelson's avatar
Blake Nelson committed
76
	ELSE( ACML_USE_OPENMP_LIBRARIES )
Blake Nelson's avatar
Blake Nelson committed
77
		SET(ACML_LIB_NAMES acml libacml)
Blake Nelson's avatar
Blake Nelson committed
78 79 80 81 82
	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
83 84 85
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
86
	SET( ACML_TARGET_LINK_LIBRARIES ${ACML} )
Blake Nelson's avatar
Blake Nelson committed
87 88
ENDIF( ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" )

89 90 91 92 93 94 95 96 97 98 99 100 101
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
102 103 104