diff --git a/cmake/FindGecode.cmake b/cmake/FindGecode.cmake index 5a37d173b..776b5e350 100644 --- a/cmake/FindGecode.cmake +++ b/cmake/FindGecode.cmake @@ -21,10 +21,6 @@ if(GECODE_FOUND) set(GECODE_LIBRARIES ${GECODE_LIBRARY} ${GECODE_SUPPORT_LIBRARY}) set(GECODE_INCLUDE_DIRS ${GECODE_INCLUDE_DIR}) find_library(GECODE_DRIVER_LIBRARY gecodedriver) - if(GECODE_DRIVER_LIBRARY) - list(APPEND GECODE_LIBRARIES ${GECODE_DRIVER_LIBRARY}) - endif() - find_library(GECODE_FZ_LIBRARY gecodeflatzinc) if(GECODE_FZ_LIBRARY) list(APPEND GECODE_LIBRARIES ${GECODE_FZ_LIBRARY}) endif() diff --git a/cmake/FindLibR.cmake b/cmake/FindLibR.cmake new file mode 100644 index 000000000..d6a05569d --- /dev/null +++ b/cmake/FindLibR.cmake @@ -0,0 +1,183 @@ +# +# FindLibR.cmake +# +# Copyright (C) 2009-11 by RStudio, Inc. +# +# This program is licensed to you under the terms of version 3 of the +# GNU Affero General Public License. This program is distributed WITHOUT +# ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT, +# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the +# AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details. +# +# + +# LIBR_FOUND +# LIBR_HOME +# LIBR_INCLUDE_DIRS +# LIBR_DOC_DIR +# LIBR_LIBRARIES + +# detection for OSX (look for R framework) +if(APPLE) + + find_library(LIBR_LIBRARIES R) + if(LIBR_LIBRARIES) + set(LIBR_HOME "${LIBR_LIBRARIES}/Resources" CACHE PATH "R home directory") + set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory") + set(LIBR_DOC_DIR "${LIBR_HOME}/doc" CACHE PATH "R doc directory") + set(LIBR_EXECUTABLE "${LIBR_HOME}/R" CACHE PATH "R executable") + endif() + +# detection for UNIX & Win32 +else() + + # Find R executable and paths (UNIX) + if(UNIX) + + # find executable + find_program(LIBR_EXECUTABLE R) + if(LIBR_EXECUTABLE-NOTFOUND) + message(STATUS "Unable to locate R executable") + endif() + + # ask R for the home path + if(NOT LIBR_HOME) + execute_process( + COMMAND ${LIBR_EXECUTABLE} "--slave" "--vanilla" "-e" "cat(R.home())" + OUTPUT_VARIABLE LIBR_HOME + ) + if(LIBR_HOME) + set(LIBR_HOME ${LIBR_HOME} CACHE PATH "R home directory") + endif() + endif() + + # ask R for the include dir + if(NOT LIBR_INCLUDE_DIRS) + execute_process( + COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home('include'))" + OUTPUT_VARIABLE LIBR_INCLUDE_DIRS + ) + if(LIBR_INCLUDE_DIRS) + set(LIBR_INCLUDE_DIRS ${LIBR_INCLUDE_DIRS} CACHE PATH "R include directory") + endif() + endif() + + # ask R for the doc dir + if(NOT LIBR_DOC_DIR) + execute_process( + COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home('doc'))" + OUTPUT_VARIABLE LIBR_DOC_DIR + ) + if(LIBR_DOC_DIR) + set(LIBR_DOC_DIR ${LIBR_DOC_DIR} CACHE PATH "R doc directory") + endif() + endif() + + # ask R for the lib dir + if(NOT LIBR_LIB_DIR) + execute_process( + COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home('lib'))" + OUTPUT_VARIABLE LIBR_LIB_DIR + ) + endif() + + # Find R executable and paths (Win32) + else() + + # find the home path + if(NOT LIBR_HOME) + + # read home from the registry + get_filename_component(LIBR_HOME + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\R-core\\R;InstallPath]" + ABSOLUTE CACHE) + + # print message if not found + if(NOT LIBR_HOME) + message(STATUS "Unable to locate R home (not written to registry)") + endif() + + endif() + + # set other R paths based on home path + set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include" CACHE PATH "R include directory") + set(LIBR_DOC_DIR "${LIBR_HOME}/doc" CACHE PATH "R doc directory") + + # set library hint path based on whether we are doing a special session 64 build + if(LIBR_FIND_WINDOWS_64BIT) + set(LIBRARY_ARCH_HINT_PATH "${LIBR_HOME}/bin/x64") + else() + set(LIBRARY_ARCH_HINT_PATH "${LIBR_HOME}/bin/i386") + endif() + + endif() + + # look for the R executable + find_program(LIBR_EXECUTABLE R + HINTS ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin) + if(LIBR_EXECUTABLE-NOTFOUND) + message(STATUS "Unable to locate R executable") + endif() + + # look for the core R library + find_library(LIBR_CORE_LIBRARY NAMES R + HINTS ${LIBR_LIB_DIR} ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin) + if(LIBR_CORE_LIBRARY) + set(LIBR_LIBRARIES ${LIBR_CORE_LIBRARY}) + else() + message(STATUS "Could not find libR shared library.") + endif() + + if(WIN32) + # look for lapack + find_library(LIBR_LAPACK_LIBRARY NAMES Rlapack + HINTS ${LIBR_LIB_DIR} ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin) + if(LIBR_LAPACK_LIBRARY) + set(LIBR_LIBRARIES ${LIBR_LIBRARIES} ${LIBR_LAPACK_LIBRARY}) + if(UNIX) + set(LIBR_LIBRARIES ${LIBR_LIBRARIES} gfortran) + endif() + endif() + + # look for blas + find_library(LIBR_BLAS_LIBRARY NAMES Rblas + HINTS ${LIBR_LIB_DIR} ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin) + if(LIBR_BLAS_LIBRARY) + set(LIBR_LIBRARIES ${LIBR_LIBRARIES} ${LIBR_BLAS_LIBRARY}) + endif() + + # look for rgraphapp + find_library(LIBR_GRAPHAPP_LIBRARY NAMES Rgraphapp + HINTS ${LIBR_LIB_DIR} ${LIBRARY_ARCH_HINT_PATH} ${LIBR_HOME}/bin) + if(LIBR_GRAPHAPP_LIBRARY) + set(LIBR_LIBRARIES ${LIBR_LIBRARIES} ${LIBR_GRAPHAPP_LIBRARY}) + endif() + endif() + + # cache LIBR_LIBRARIES + if(LIBR_LIBRARIES) + set(LIBR_LIBRARIES ${LIBR_LIBRARIES} CACHE PATH "R runtime libraries") + endif() + +endif() + +# define find requirements +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibR DEFAULT_MSG + LIBR_HOME + LIBR_EXECUTABLE + LIBR_INCLUDE_DIRS + LIBR_LIBRARIES + LIBR_DOC_DIR +) + +if(LIBR_FOUND) + message(STATUS "Found R: ${LIBR_HOME}") +endif() + +# mark low-level variables from FIND_* calls as advanced +mark_as_advanced( + LIBR_CORE_LIBRARY + LIBR_LAPACK_LIBRARY + LIBR_BLAS_LIBRARY +) diff --git a/cmake/FindPAPI.cmake.txt b/cmake/FindPAPI.cmake.txt new file mode 100644 index 000000000..20ee7a68d --- /dev/null +++ b/cmake/FindPAPI.cmake.txt @@ -0,0 +1,45 @@ +# Try to find PAPI headers and libraries. +# +# Usage of this module as follows: +# +# find_package(PAPI) +# +# Variables used by this module, they can change the default behaviour and need +# to be set before calling find_package: +# +# PAPI_PREFIX Set this variable to the root installation of +# libpapi if the module has problems finding the +# proper installation path. +# +# Variables defined by this module: +# +# PAPI_FOUND System has PAPI libraries and headers +# PAPI_LIBRARIES The PAPI library +# PAPI_INCLUDE_DIRS The location of PAPI headers + +find_path(PAPI_PREFIX + NAMES include/papi.h +) + +find_library(PAPI_LIBRARIES + # Pick the static library first for easier run-time linking. + NAMES libpapi.a papi + HINTS ${PAPI_PREFIX}/lib ${HILTIDEPS}/lib +) + +find_path(PAPI_INCLUDE_DIRS + NAMES papi.h + HINTS ${PAPI_PREFIX}/include ${HILTIDEPS}/include +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PAPI DEFAULT_MSG + PAPI_LIBRARIES + PAPI_INCLUDE_DIRS +) + +mark_as_advanced( + PAPI_PREFIX_DIRS + PAPI_LIBRARIES + PAPI_INCLUDE_DIRS +) diff --git a/cmake/FindThrust.cmake b/cmake/FindThrust.cmake new file mode 100644 index 000000000..8e5aa7399 --- /dev/null +++ b/cmake/FindThrust.cmake @@ -0,0 +1,69 @@ +##============================================================================= +## +## Copyright (c) Kitware, Inc. +## All rights reserved. +## See LICENSE.txt for details. +## +## This software is distributed WITHOUT ANY WARRANTY; without even +## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +## PURPOSE. See the above copyright notice for more information. +## +## Copyright 2012 Sandia Corporation. +## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, +## the U.S. Government retains certain rights in this software. +## +##============================================================================= + +# +# FindThrust +# +# This module finds the Thrust header files and extrats their version. It +# sets the following variables. +# +# THRUST_INCLUDE_DIR - Include directory for thrust header files. (All header +# files will actually be in the thrust subdirectory.) +# THRUST_VERSION - Version of thrust in the form "major.minor.patch". +# + +find_path( THRUST_INCLUDE_DIR + HINTS + /usr/include/cuda + /usr/local/include + /usr/local/cuda/include + ${CUDA_INCLUDE_DIRS} + NAMES thrust/version.h + DOC "Thrust headers" + ) +if( THRUST_INCLUDE_DIR ) + list( REMOVE_DUPLICATES THRUST_INCLUDE_DIR ) +endif( THRUST_INCLUDE_DIR ) + +# Find thrust version +file( STRINGS ${THRUST_INCLUDE_DIR}/thrust/version.h + version + REGEX "#define THRUST_VERSION[ \t]+([0-9x]+)" + ) +string( REGEX REPLACE + "#define THRUST_VERSION[ \t]+" + "" + version + "${version}" + ) + +string( REGEX MATCH "^[0-9]" major ${version} ) +string( REGEX REPLACE "^${major}00" "" version "${version}" ) +string( REGEX MATCH "^[0-9]" minor ${version} ) +string( REGEX REPLACE "^${minor}0" "" version "${version}" ) +set( THRUST_VERSION "${major}.${minor}.${version}") +set( THRUST_MAJOR_VERSION "${major}") +set( THRUST_MINOR_VERSION "${minor}") + +# Check for required components +include( FindPackageHandleStandardArgs ) +find_package_handle_standard_args( Thrust + REQUIRED_VARS THRUST_INCLUDE_DIR + VERSION_VAR THRUST_VERSION + ) + +set(THRUST_INCLUDE_DIRS ${THRUST_INCLUDE_DIR}) +mark_as_advanced(THRUST_INCLUDE_DIR) \ No newline at end of file diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake new file mode 100644 index 000000000..c8d27f2e8 --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake @@ -0,0 +1,130 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${hash} + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() diff --git a/cmake/GetGitRevisionDescription.cmake.in b/cmake/GetGitRevisionDescription.cmake.in new file mode 100644 index 000000000..a22a037bc --- /dev/null +++ b/cmake/GetGitRevisionDescription.cmake.in @@ -0,0 +1,43 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + else() + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) + endif() + + \ No newline at end of file