Commit 85b8eded authored by Carl Poelking's avatar Carl Poelking
Browse files

Build system mods, cxx_tests, NablaYlm.

parent da237325
...@@ -23,6 +23,7 @@ endif(${CMAKE_VERSION} VERSION_GREATER 3.1) ...@@ -23,6 +23,7 @@ endif(${CMAKE_VERSION} VERSION_GREATER 3.1)
# LOCAL PACKAGES # LOCAL PACKAGES
# ... # ...
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
# FIND PACKAGES # FIND PACKAGES
find_package(PythonLibs) find_package(PythonLibs)
...@@ -57,5 +58,5 @@ foreach(lib ${local_dirs}) ...@@ -57,5 +58,5 @@ foreach(lib ${local_dirs})
endforeach() endforeach()
# SUBDIRECTORIES # SUBDIRECTORIES
add_subdirectory(src) add_subdirectory(src/soap)
# CONFIGURE CMAKE
message("CMake version: ${CMAKE_VERSION}")
cmake_minimum_required(VERSION 2.8.3)
# PROJECT OPTIONS
project(soapxx_tests)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})
set(LOCAL_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/soap_tests)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# BUILD OPTIONS
enable_language(CXX)
#set(CMAKE_CXX_COMPILER "/usr/local/shared/intel/compilers_and_libraries_2016.0.109/linux/bin/intel64/icc")
message("C++ compiler: " ${CMAKE_CXX_COMPILER} " " ${CMAKE_CXX_COMPILER_ID})
option(BUILD_SHARED_LIBS "Build shared libs" ON)
if(${CMAKE_VERSION} VERSION_GREATER 3.1)
message("Setting C++ standard 11 (CMake version > 3.1)")
set(CMAKE_CXX_STANDARD 11)
else(${CMAKE_VERSION} VERSION_GREATER 3.1)
message("Setting C++ standard 11 (CMake version <= 3.1)")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif(${CMAKE_VERSION} VERSION_GREATER 3.1)
# LOCAL PACKAGES
find_package(SOAP REQUIRED)
find_package(GTEST REQUIRED)
# FIND PACKAGES
find_package(PythonLibs)
include_directories(${PYTHON_INCLUDE_DIRS})
if(DEFINED ENV{BOOST_ROOT})
set(BOOST_ROOT "$ENV{BOOST_ROOT}")
message("-- BOOST_ROOT is set: ${BOOST_ROOT}")
else(DEFINED ENV{BOOST_ROOT})
message("-- Note: BOOST_ROOT not set.")
endif(DEFINED ENV{BOOST_ROOT})
message("-- BOOST_ROOT is set: ${BOOST_ROOT}")
find_package(Boost 1.60.0 COMPONENTS python mpi filesystem serialization)
include_directories(${Boost_INCLUDE_DIRS})
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
# SUMMARIZE INCLUDES & LIBS
get_property(local_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
get_property(local_libs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY SOAPXX_LINK_LIBRARIES)
message(STATUS "Include directories: ")
foreach(dir ${local_dirs})
message(STATUS " o ${dir}")
endforeach()
message(STATUS "Linked libraries: ")
foreach(lib ${local_dirs})
message(STATUS " o ${lib}")
endforeach()
# SUBDIRECTORIES
add_subdirectory(src)
#! /bin/bash
mkdir -p build
cd build
cmake .. && make && make install
cd ..
# - Find FFTW3
# Find the native FFTW3 includes and library
#
# FFTW3_INCLUDES - where to find fftw3.h
# FFTW3_LIBRARIES - List of libraries when using FFTW3.
# FFTW3_FOUND - True if FFTW3 found.
if (FFTW3_INCLUDES)
# Already in cache, be silent
set (FFTW3_FIND_QUIETLY TRUE)
endif (FFTW3_INCLUDES)
find_path (FFTW3_INCLUDES fftw3.h)
find_library (FFTW3_LIBRARIES NAMES fftw3)
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE if
# all listed variables are TRUE
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (FFTW3 DEFAULT_MSG FFTW3_LIBRARIES FFTW3_INCLUDES)
mark_as_advanced (FFTW3_LIBRARIES FFTW3_INCLUDES)
# - Find gsl
# Find the native GSL headers and libraries.
#
# GSL_INCLUDE_DIRS - where to find gsl/gsl_linalg.h, etc.
# GSL_LIBRARIES - List of libraries when using gsl.
# GSL_FOUND - True if gsl found.
#
# Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
find_package(PkgConfig)
pkg_check_modules(PC_GSL gsl)
find_path(GSL_INCLUDE_DIR gsl/gsl_linalg.h HINTS ${PC_GSL_INCLUDE_DIRS})
find_library(GSL_LIBRARY NAMES gsl HINTS ${PC_GSL_LIBRARY_DIRS} )
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set GSL_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(GSL DEFAULT_MSG GSL_LIBRARY GSL_INCLUDE_DIR)
set(GSL_LIBRARIES "${GSL_LIBRARY}")
set(GSL_INCLUDE_DIRS ${GSL_INCLUDE_DIR} )
if (GSL_FOUND)
include(CheckLibraryExists)
#adding MATH_LIBRARIES here to allow static libs, this does not harm us as we are anyway using it
check_library_exists("${GSL_LIBRARIES};${MATH_LIBRARIES}" gsl_linalg_QR_decomp "" FOUND_QR_DECOMP)
if(NOT FOUND_QR_DECOMP)
#Some distributions like OpenSUSE need cblas in the linker flags, too
find_library(GSLCBLAS_LIBRARY NAMES gslcblas cblas HINTS ${PC_GSL_LIBRARY_DIRS} )
find_package_handle_standard_args(GSLCBLAS DEFAULT_MSG GSLCBLAS_LIBRARY)
if (GSLCBLAS_FOUND)
check_library_exists("${GSLCBLAS_LIBRARY};${MATH_LIBRARIES}" cblas_dsyrk "" FOUND_DSYRK)
if(NOT FOUND_DSYRK)
message(FATAL_ERROR "Could not find cblas_dsyrk in ${GSLCBLAS_LIBRARY}, take a look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. If you are using a static lib (.a) make sure you have specified all dependencies of libcblas in GSLCBLAS_LIBRARY by hand (i.e. -DGSLCBLAS_LIBRARY='/path/to/libcblas.so;/path/to/libm.so')! If your gsl was build against an different version of cblas, specify it in GSLCBLAS_LIBRARY")
endif(NOT FOUND_DSYRK)
set(GSL_LIBRARIES "${GSL_LIBRARY};${GSLCBLAS_LIBRARY}")
check_library_exists("${GSL_LIBRARIES};${MATH_LIBRARIES}" gsl_linalg_QR_lssolve "" FOUND_QR_DECOMP_AGAIN)
endif(GSLCBLAS_FOUND)
endif(NOT FOUND_QR_DECOMP)
if(NOT FOUND_QR_DECOMP AND NOT FOUND_QR_DECOMP_AGAIN)
message(FATAL_ERROR "Could not find gsl_linalg_QR_decompx in ${GSL_LIBRARY}, take a look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. If you are using a static lib (.a) make sure you have specified all dependencies of libgsl in GSL_LIBRARY by hand (i.e. -DGSL_LIBRARY='/path/to/libgsl.so;/path/to/libm.so') !")
endif(NOT FOUND_QR_DECOMP AND NOT FOUND_QR_DECOMP_AGAIN)
endif (GSL_FOUND)
mark_as_advanced(GSL_INCLUDE_DIR GSL_LIBRARY)
if(DEFINED ENV{GTEST_ROOT})
set(GTEST_ROOT "$ENV{GTEST_ROOT}")
message("-- GTEST_ROOT is set: ${GTEST_ROOT}")
else()
message(FATAL_ERROR "-- Note: GTEST_ROOT not set.")
endif()
message("-- GTEST_ROOT is set: ${GTEST_ROOT}")
set(GTEST_LIBRARIES "${GTEST_ROOT}/lib/libgtest_main.a" "${GTEST_ROOT}/lib/libgtest.a")
set(GTEST_INCLUDE_DIRS "${GTEST_ROOT}/include")
include_directories(${GTEST_INCLUDE_DIRS})
# CMake script to detect Intel(R) Math Kernel Library (MKL)
#
# This will try to find Intel MKL libraries, and include path by automatic
# search through typical install locations and if failed it will
# examine MKLROOT environment variable.
# Note, MKLROOT is not set by IPP installer, it should be set manually.
#
# Usage example:
# set(MKL_USE_STATIC_LIBS ON)
# find_package(MKL)
# if (MKL_FOUND)
# include_directories(${MKL_INCLUDE_DIRS})
# add_executable(foo foo.cc)
# target_link_libraries(foo ${MKL_LIBRARIES})
# endif()
#
# Variables used by this module, they can change the default behaviour and
# need to be set before calling find_package:
#
# MKL_ADDITIONAL_VERSIONS A list of version numbers to use for searching
# the MKL include directory.
#
# MKL_USE_STATIC_LIBS Can be set to ON to force the use of the static
# boost libraries. Defaults to OFF.
#
# MKL_FIND_DEBUG Set this to TRUE to enable debugging output
# of FindMKL.cmake if you are having problems.
#
# On return this will define:
# MKL_FOUND Indicates whether MKL was found (True/False)
# MKL_INCLUDE_DIRS MKL include folder
# MKL_LIBRARY_DIRS MKL libraries folder
# MKL_LIBRARIES MKL libraries names
#
# NOTE: this script has only been tested with Intel(R) Parallel Studio XE 2011
# and may need changes for compatibility with older versions.
#
# Adapted from OpenCV IPP detection script
# https://code.ros.org/trac/opencv/browser/trunk/opencv/OpenCVFindIPP.cmake
# Many portions taken from FindBoost.cmake
# TODO:
# - caller needs to link with libiomp5md.lib or /Qopenmp...
# - runtime DLLs:
# <Composer XE directory> -> C:\Program Files\Intel\ComposerXE-2011
# redist\ia32\mkl
# redist\intel64\mkl
set(_MKL_IA32 FALSE)
set(_MKL_INTEL64 FALSE)
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(_MKL_IA32 TRUE)
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_MKL_INTEL64 TRUE)
else()
message(FATAL_ERROR "Unsupported 'void *' size (${SIZEOF_VOID_P})")
endif()
# Versions should be listed is decreasing order of preference
set(_MKL_TEST_VERSIONS ${MKL_ADDITIONAL_VERSIONS}
"2011"
# alternative form: "2011.xxx.y"
# (y is the release-update number and xxx is the package number)
)
set(MKL_FIND_QUIETLY true)
if (MKL_FIND_VERSION AND NOT MKL_FIND_QUIETLY)
message(WARNING "Requesting a specific version of Intel(R) MKL is not supported")
endif()
# Use environment variables from Intel build scripts, if available
if (NOT MKL_ROOT AND NOT $ENV{MKLROOT} STREQUAL "")
set(MKL_ROOT $ENV{MKLROOT})
endif()
if (MKL_ROOT)
file(TO_CMAKE_PATH ${MKL_ROOT} MKL_ROOT)
endif()
if (NOT INTEL_ROOT AND NOT $ENV{INTELROOT} STREQUAL "")
set(INTEL_ROOT $ENV{INTELROOT})
endif()
if (INTEL_ROOT)
file(TO_CMAKE_PATH ${INTEL_ROOT} INTEL_ROOT)
endif()
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_MKL_TEST_VERSIONS = ${_MKL_TEST_VERSIONS}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"MKL_ADDITIONAL_VERSIONS = ${MKL_ADDITIONAL_VERSIONS}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"MKL_USE_STATIC_LIBS = ${MKL_USE_STATIC_LIBS}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"MKL_ROOT = ${MKL_ROOT}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"INTEL_ROOT = ${INTEL_ROOT}")
endif()
# Find MKL include directory
set(_MKL_ROOT_SEARCH_DIRS
${MKL_ROOT}
)
foreach (_MKL_VER ${_MKL_TEST_VERSIONS})
if (WIN32)
list(APPEND _MKL_ROOT_SEARCH_DIRS "$ENV{ProgramFiles}/Intel/Composer XE/mkl")
else()
list(APPEND _MKL_ROOT_SEARCH_DIRS "/opt/intel/composerxe-${_MKL_VER}/mkl")
endif()
endforeach()
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_MKL_ROOT_SEARCH_DIRS = ${_MKL_ROOT_SEARCH_DIRS}")
endif()
find_path(MKL_INCLUDE_DIR
NAMES mkl.h
PATHS ${_MKL_ROOT_SEARCH_DIRS}
PATH_SUFFIXES include
DOC "The path to Intel(R) MKL header files"
)
if (MKL_INCLUDE_DIR)
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"location of mkl.h: ${MKL_INCLUDE_DIR}/mkl.h")
endif()
else()
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"unable to find Intel(R) MKL header files. Please set MKLROOT"
" to the root directory containing MKL.")
endif()
endif()
# Find MKL library directory
set(_INTEL_LIBRARY_DIR_SUFFIXES "lib")
if (_MKL_IA32)
list(APPEND _INTEL_LIBRARY_DIR_SUFFIXES "lib/ia32")
elseif (_MKL_INTEL64)
list(APPEND _INTEL_LIBRARY_DIR_SUFFIXES "lib/intel64")
else()
message(FATAL_ERROR "unreachable")
endif()
set(_MKL_LIBRARY_SEARCH_DIRS ${_MKL_ROOT_SEARCH_DIRS})
if (MKL_INCLUDE_DIR)
list(APPEND _MKL_LIBRARY_SEARCH_DIRS "${MKL_INCLUDE_DIR}/..")
endif()
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_INTEL_LIBRARY_DIR_SUFFIXES = ${_INTEL_LIBRARY_DIR_SUFFIXES}")
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_MKL_LIBRARY_SEARCH_DIRS = ${_MKL_LIBRARY_SEARCH_DIRS}")
endif()
set(MKL_LIB_PREFIX "mkl_")
if (MKL_USE_STATIC_LIBS)
if (_MKL_IA32)
if (WIN32)
set(_MKL_LIBRARIES intel_c)
else()
set(_MKL_LIBRARIES intel)
endif()
elseif (_MKL_INTEL64)
set(_MKL_LIBRARIES intel_lp64)
else()
message(FATAL_ERROR "unreachable")
endif()
list(APPEND _MKL_LIBRARIES intel_thread)
list(APPEND _MKL_LIBRARIES core)
else()
set(_MKL_LIBRARIES rt)
endif()
set(_MKL_MISSING_LIBRARIES "")
set(MKL_LIBRARIES "")
set(MKL_LIBRARY_DIRS "")
# Find MKL libraries
foreach (_MKL_LIB_RAW ${_MKL_LIBRARIES})
set(_MKL_LIB ${MKL_LIB_PREFIX}${_MKL_LIB_RAW})
string(TOUPPER ${_MKL_LIB} _MKL_LIB_UPPER)
find_library(${_MKL_LIB_UPPER}_LIBRARY
NAMES ${_MKL_LIB}
PATHS ${_MKL_LIBRARY_SEARCH_DIRS}
PATH_SUFFIXES ${_INTEL_LIBRARY_DIR_SUFFIXES}
DOC "The path to Intel(R) MKL ${_MKL_LIB_RAW} library"
)
mark_as_advanced(${_MKL_LIB_UPPER}_LIBRARY)
if (NOT ${_MKL_LIB_UPPER}_LIBRARY)
list(APPEND _MKL_MISSING_LIBRARIES ${_MKL_LIB})
else()
list(APPEND MKL_LIBRARIES ${${_MKL_LIB_UPPER}_LIBRARY})
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Found ${_MKL_LIB}: ${${_MKL_LIB_UPPER}_LIBRARY}")
endif()
get_filename_component(_MKL_LIB_PATH "${${_MKL_LIB_UPPER}_LIBRARY}" PATH)
list(APPEND MKL_LIBRARY_DIRS ${_MKL_LIB_PATH})
endif()
endforeach()
## Find OpenMP, pthread and math libraries
set(_INTEL_LIBRARY_SEARCH_DIRS
${INTEL_ROOT}
${INTEL_ROOT}/compiler
)
foreach(_MKL_DIR ${_MKL_ROOT_SEARCH_DIRS})
list(APPEND _INTEL_LIBRARY_SEARCH_DIRS "${_MKL_DIR}/..")
list(APPEND _INTEL_LIBRARY_SEARCH_DIRS "${_MKL_DIR}/../compiler")
endforeach()
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"_INTEL_LIBRARY_SEARCH_DIRS = ${_INTEL_LIBRARY_SEARCH_DIRS}")
endif()
if (NOT WIN32)
find_library(PTHREAD_LIBRARY pthread DOC "Path to POSIX threads library")
endif()
set(_IOMP5_LIB iomp5)
if (WIN32)
if (MKL_USE_STATIC_LIBS)
list(APPEND _IOMP5_LIB libiomp5mt.lib)
else()
list(APPEND _IOMP5_LIB libiomp5md.lib)
endif()
endif()
find_library(IOMP5_LIBRARY
NAMES ${_IOMP5_LIB}
PATHS ${_INTEL_LIBRARY_SEARCH_DIRS}
PATH_SUFFIXES ${_INTEL_LIBRARY_DIR_SUFFIXES}
DOC "Path to OpenMP runtime library"
)
if (NOT IOMP5_LIBRARY)
# we could instead fallback to default library (via FindOpenMP.cmake)
list(APPEND _MKL_MISSING_LIBRARIES IOMP5)
else()
list(APPEND MKL_LIBRARIES ${IOMP5_LIBRARY})
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Found IOMP5_LIBRARY: ${IOMP5_LIBRARY}")
endif()
get_filename_component(_MKL_LIB_PATH "${IOMP5_LIBRARY}" PATH)
list(APPEND MKL_LIBRARY_DIRS ${_MKL_LIB_PATH})
endif()
# Optimized math library (optional)
set(_MATH_LIB imf) # linked by default with Intel compiler
if (WIN32)
if (MKL_USE_STATIC_LIBS)
list(APPEND _MATH_LIB libmmds.lib) # assumes (/MD) otherwise libmmt.lib (for /MT)
else()
list(APPEND _MATH_LIB libmmd.lib)
endif()
endif()
find_library(MATH_LIBRARY
NAMES ${_MATH_LIB}
PATHS ${_INTEL_LIBRARY_SEARCH_DIRS}
PATH_SUFFIXES ${_INTEL_LIBRARY_DIR_SUFFIXES}
DOC "Path to optimized math library"
)
if (NOT MATH_LIBRARY)
# we could instead fallback to default library (via FindOpenMP.cmake)
list(APPEND _MKL_MISSING_LIBRARIES MATH)
else()
list(APPEND MKL_LIBRARIES ${MATH_LIBRARY})
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"Found MATH_LIBRARY: ${MATH_LIBRARY}")
endif()
get_filename_component(_MKL_LIB_PATH "${MATH_LIBRARY}" PATH)
list(APPEND MKL_LIBRARY_DIRS ${_MKL_LIB_PATH})
endif()
# Check all required libraries are available
list(REMOVE_DUPLICATES MKL_LIBRARY_DIRS)
set(MKL_INCLUDE_DIRS
${MKL_INCLUDE_DIR}
)
set(MKL_FOUND TRUE)
if (NOT MKL_INCLUDE_DIR)
set(MKL_FOUND FALSE)
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"MKL not found - MKL_INCLUDE_DIR was empty")
endif()
elseif (_MKL_MISSING_LIBRARIES)
set(MKL_FOUND FALSE)
if (MKL_FIND_DEBUG)
message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
"MKL not found - the following libraries are missing: "
"${_MKL_MISSING_LIBRARIES}")
endif()
endif()
if (MKL_FOUND)
if (NOT MKL_FIND_QUIETLY OR MKL_FIND_DEBUG)
message(STATUS
"Intel(R) MKL was found:\n"
" MKL_INCLUDE_DIRS: ${MKL_INCLUDE_DIRS}\n"
" MKL_LIBRARY_DIRS: ${MKL_LIBRARY_DIRS}\n"
" MKL_LIBRARIES: ${MKL_LIBRARIES}"
)
endif()
else()
if (MKL_FIND_REQUIRED)
message(SEND_ERROR "Intel(R) MKL could not be found.")
else()
message(STATUS "Intel(R) MKL could not be found.")
endif()
endif()
mark_as_advanced(
MKL_INCLUDE_DIR
MKL_INCLUDE_DIRS
MKL_LIBRARY_DIRS
)
if(DEFINED ENV{SOAP_ROOT})
set(SOAP_ROOT "$ENV{SOAP_ROOT}")
message("-- SOAP_ROOT is set: ${SOAP_ROOT}")
else()
message(FATAL_ERROR "-- Note: SOAP_ROOT not set.")
endif()
message("-- SOAP_ROOT is set: ${SOAP_ROOT}")
set(SOAP_LIBRARIES "${SOAP_ROOT}/soap/_soapxx.so")
set(SOAP_INCLUDE_DIRS "${SOAP_ROOT}/soap/include")
include_directories(${SOAP_INCLUDE_DIRS})
#! /bin/bash
soap_tests/test.exe
# COMPILE LIBRARIES
set(LD_LIBRARIES ${Boost_LIBRARIES} ${PYTHON_LIBRARIES} ${MPI_LIBRARIES} ${SOAP_LIBRARIES} ${GTEST_LIBRARIES})
add_executable(test_functions.exe test_functions.cpp)
target_link_libraries(test_functions.exe ${LD_LIBRARIES})
install(TARGETS test_functions.exe DESTINATION ${LOCAL_INSTALL_DIR})
add_executable(test_dylm.exe test_dylm.cpp)
target_link_libraries(test_dylm.exe ${LD_LIBRARIES})
install(TARGETS test_dylm.exe DESTINATION ${LOCAL_INSTALL_DIR})
file(GLOB local_sources gtest_*.cpp)
add_executable(test.exe ${local_sources})
target_link_libraries(test.exe ${LD_LIBRARIES})
install(TARGETS test.exe DESTINATION ${LOCAL_INSTALL_DIR})
#include <iostream>
#include <vector>
#include <boost/format.hpp>
#include <gtest/gtest.h>
#include <soap/functions.hpp>
TEST(TestFunctions, PowerExponentZero) {
// CAREFUL, THIS CAN LEAD TO NAN'S DEPENDING ON IMPLEMENTATION!
double p = pow(0.,0);
std::complex<double> q = soap::pow_nnan(std::complex<double>(0.,0.),0);
EXPECT_EQ(p, 1);
EXPECT_EQ(q, std::complex<double>(1.,0.));
}
TEST(TestFunctions, GradientYlm) {
// SETUP
std::vector< soap::vec > r_list;
r_list.push_back(soap::vec(2.,0.,0.));
r_list.push_back(soap::vec(0.,1.,0.));
r_list.push_back(soap::vec(0.,0.,1.));
r_list.push_back(soap::vec(std::sqrt(0.5),0.,std::sqrt(0.5)));
r_list.push_back(soap::vec(-0.2,0.3,0.7));
r_list.push_back(soap::vec(-0.2,-0.4,-0.1));
std::vector< std::pair<int,int> > lm_list;
lm_list.push_back(std::pair<int,int>(1,0));
lm_list.push_back(std::pair<int,int>(1,1));
lm_list.push_back(std::pair<int,int>(2,0));
lm_list.push_back(std::pair<int,int>(2,1));
lm_list.push_back(std::pair<int,int>(2,-1));
lm_list.push_back(std::pair<int,int>(2,2));
lm_list.push_back(std::pair<int,int>(2,-2));
std::vector<std::complex<double> > results;
results.push_back(std::complex<double>(-1.4959138e-17, +0.0000000e+00));
results.push_back(std::complex<double>(-0.0000000e+00, +0.0000000e+00));
results.push_back(std::complex<double>(+2.4430126e-01, +0.0000000e+00));
results.push_back(std::complex<double>(-1.8319660e-33, +0.0000000e+00));
results.push_back(std::complex<double>(-2.9918275e-17, +0.0000000e+00));
results.push_back(std::complex<double>(+4.8860251e-01, +0.0000000e+00));
results.push_back(std::complex<double>(-0.0000000e+00, +0.0000000e+00));
results.push_back(std::complex<double>(+0.0000000e+00, +0.0000000e+00));
results.push_back(std::complex<double>(+0.0000000e+00, +0.0000000e+00));
results.push_back(std::complex<double>(-2.4430126e-01, +0.0000000e+00));
results.push_back(std::complex<double>(-0.0000000e+00, +0.0000000e+00));
results.push_back(std::complex<double>(+2.4430126e-01, +0.0000000e+00));
results.push_back(std::complex<double>(+1.4011873e-01, +0.0000000e+00));
results.push_back(std::complex<double>(-2.1017810e-01, +0.0000000e+00));
results.push_back(std::complex<double>(+1.3011025e-01, +0.0000000e+00));
results.push_back(std::complex<double>(-1.0154458e-01, +0.0000000e+00));
results.push_back(std::complex<double>(-2.0308916e-01, +0.0000000e+00));
results.push_back(std::complex<double>(+1.0154458e+00, +0.0000000e+00));