127 lines
4.2 KiB
CMake
Raw Permalink Normal View History

2021-10-14 13:47:35 +02:00
# ---------------------------------
# Finds ITPP toolkit
#
# Sets ITPP_FOUND
# Sets ITPP_LIBRARIES
# Sets ITPP_LIBRARY_DIRS
# Sets ITPP_LDFLAGS
# Sets ITPP_LDFLAGS_OTHERS
# Sets ITPP_INCLUDE_DIRS
# Sets ITPP_CFLAGS
# Sets ITPP_CFLAGS_OTHERS
#
# Adds library to target
# Adds include path
# ---------------------------------
GET_PROPERTY(OV_PRINTED GLOBAL PROPERTY OV_TRIED_ThirdPartyITPP)
IF(WIN32)
FIND_PATH(PATH_ITPP include/itpp/itbase.h PATHS ${LIST_DEPENDENCIES_PATH} PATH_SUFFIXES itpp)
IF(PATH_ITPP)
SET(ITPP_FOUND TRUE)
SET(ITPP_INCLUDE_DIRS ${PATH_ITPP}/include)
# Currently the different versions we package for different VS have a bit different lib names...
STRING(REGEX MATCH "vc100.*" MSVC_VER100 ${MSVC_SERVICE_PACK})
STRING(REGEX MATCH "vc120.*" MSVC_VER120 ${MSVC_SERVICE_PACK})
IF(MSVC_VER100)
SET(ITPP_LIBRARIES libblas.a libfftw3-3 liblapack.a libgcc.a libg2c.a)
SET(ITPP_LIBRARIES_RELEASE itpp)
SET(ITPP_LIBRARIES_DEBUG itppd)
ENDIF(MSVC_VER100)
IF(MSVC_VER120)
IF("${PLATFORM_TARGET}" STREQUAL "x64")
SET(ITPP_LIBRARIES libfftw3-3_win64)
SET(ITPP_LIBRARIES_RELEASE blas_win64_MT lapack_win64_MT itpp)
SET(ITPP_LIBRARIES_DEBUG blas_win64_MT lapack_win64_MT itpp) # we dont have a good 64bit debug build, just use release
ELSE()
SET(ITPP_LIBRARIES libfftw3-3_win32)
SET(ITPP_LIBRARIES_RELEASE blas_win32_MT lapack_win32_MT itpp)
SET(ITPP_LIBRARIES_DEBUG blas_win32_MTd lapack_win32_MTd itppd)
ENDIF()
ENDIF(MSVC_VER120)
SET(ITPP_LIBRARY_DIRS ${PATH_ITPP}/lib )
ENDIF(PATH_ITPP)
ENDIF(WIN32)
IF(UNIX)
INCLUDE("FindThirdPartyPkgConfig")
FIND_PATH(PATH_ITPP include/itpp PATHS ${LIST_DEPENDENCIES_PATH})
IF(PATH_ITPP)
FIND_LIBRARY(ITPP_LIBRARY itpp PATHS ${PATH_ITPP}/lib)
SET(ITPP_FOUND TRUE)
SET(ITPP_INCLUDE_DIRS ${PATH_ITPP}/include/)
GET_FILENAME_COMPONENT(ITPP_LIBRARY_DIRS ${ITPP_LIBRARY} DIRECTORY)
SET(ITPP_LIBRARIES_RELEASE libitpp.so)
ELSE()
pkg_check_modules(ITPP itpp)
ENDIF()
ENDIF(UNIX)
IF(ITPP_FOUND)
OV_PRINT(OV_PRINTED " Found it++...")
SET(ITPP_LOADING_FAILURE FALSE)
INCLUDE_DIRECTORIES(${ITPP_INCLUDE_DIRS})
ADD_DEFINITIONS(${ITPP_CFLAGS})
ADD_DEFINITIONS(${ITPP_CFLAGS_OTHERS})
# LINK_DIRECTORIES(${ITPP_LIBRARY_DIRS})
FOREACH(ITPP_LIB ${ITPP_LIBRARIES})
SET(ITPP_LIB1 "ITPP_LIB1-NOTFOUND")
FIND_LIBRARY(ITPP_LIB1 NAMES ${ITPP_LIB} PATHS ${ITPP_LIBRARY_DIRS} ${ITPP_LIBDIR} NO_DEFAULT_PATH)
IF(ITPP_LIB1)
OV_PRINT(OV_PRINTED " [ OK ] Third party lib ${ITPP_LIB1}")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${ITPP_LIB1})
IF(WIN32)
INSTALL(FILES "${ITPP_LIBRARY_DIRS}/../bin/${ITPP_LIB}.dll" DESTINATION "${DIST_BINDIR}")
ENDIF()
ELSE()
OV_PRINT(OV_PRINTED " [FAILED] Third party lib ${ITPP_LIB}")
SET(ITPP_LOADING_FAILURE TRUE)
ENDIF()
ENDFOREACH()
FOREACH(ITPP_LIB ${ITPP_LIBRARIES_RELEASE})
SET(ITPP_LIB1 "ITPP_LIB1-RELEASE-NOTFOUND")
FIND_LIBRARY(ITPP_LIB1 NAMES ${ITPP_LIB} PATHS ${ITPP_LIBRARY_DIRS} ${ITPP_LIBDIR} NO_DEFAULT_PATH)
IF(ITPP_LIB1)
OV_PRINT(OV_PRINTED " [ OK ] Third party lib ${ITPP_LIB1}")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} optimized ${ITPP_LIB1})
IF(WIN32)
INSTALL(FILES "${ITPP_LIBRARY_DIRS}/../bin/${ITPP_LIB}.dll" DESTINATION "${DIST_BINDIR}" CONFIGURATIONS Release)
ENDIF()
ELSE()
OV_PRINT(OV_PRINTED " [FAILED] Third party lib ${ITPP_LIB}")
SET(ITPP_LOADING_FAILURE TRUE)
ENDIF()
ENDFOREACH()
FOREACH(ITPP_LIB ${ITPP_LIBRARIES_DEBUG})
SET(ITPP_LIB1 "ITPP_LIB1-DEBUG-NOTFOUND")
FIND_LIBRARY(ITPP_LIB1 NAMES ${ITPP_LIB} PATHS ${ITPP_LIBRARY_DIRS} ${ITPP_LIBDIR} NO_DEFAULT_PATH)
IF(ITPP_LIB1)
OV_PRINT(OV_PRINTED " [ OK ] Third party lib ${ITPP_LIB1}")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} debug ${ITPP_LIB1})
IF(WIN32)
INSTALL(FILES "${ITPP_LIBRARY_DIRS}/../bin/${ITPP_LIB}.dll" DESTINATION "${DIST_BINDIR}" CONFIGURATIONS Debug)
ENDIF()
ELSE()
OV_PRINT(OV_PRINTED " [FAILED] Third party lib ${ITPP_LIB}")
SET(ITPP_LOADING_FAILURE TRUE)
ENDIF()
ENDFOREACH()
# We only add ITPP if everything was found
IF(NOT ITPP_LOADING_FAILURE)
ADD_DEFINITIONS(-DTARGET_HAS_ThirdPartyITPP)
ENDIF()
ELSE(ITPP_FOUND)
OV_PRINT(OV_PRINTED " FAILED to find it++...")
ENDIF()
SET_PROPERTY(GLOBAL PROPERTY OV_TRIED_ThirdPartyITPP "Yes")