max@0: max@0: # Copyright (C) 2008-2011 NICTA (www.nicta.com.au) max@0: # Copyright (C) 2008-2011 Conrad Sanderson max@0: # Copyright (C) 2011 Clement Creusot max@0: # max@0: # This file is part of the Armadillo C++ library. max@0: # It is provided without any warranty of fitness max@0: # for any purpose. You can redistribute this file max@0: # and/or modify it under the terms of the GNU max@0: # Lesser General Public License (LGPL) as published max@0: # by the Free Software Foundation, either version 3 max@0: # of the License or (at your option) any later version. max@0: # (see http://www.opensource.org/licenses for more info) max@0: max@0: cmake_minimum_required(VERSION 2.6 FATAL_ERROR) max@0: max@0: set(ARMA_MAJOR 2) max@0: set(ARMA_MINOR 4) max@0: set(ARMA_PATCH 4) max@0: max@0: message(STATUS "Configuring Armadillo ${ARMA_MAJOR}.${ARMA_MINOR}.${ARMA_PATCH}") max@0: max@0: set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/build_aux/cmake/Modules/") max@0: max@0: include(CheckIncludeFileCXX) max@0: include(CheckLibraryExists) max@0: include(FindBoost) max@0: include(ARMA_CheckProto) max@0: include(ARMA_CheckMathProto) max@0: max@0: project(armadillo CXX) max@0: max@0: #CMAKE_REQUIRED_FLAGS = string of compile command line flags max@0: #CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) max@0: #CMAKE_REQUIRED_LIBRARIES = list of libraries to link max@0: max@0: max@0: set(ARMA_USE_LAPACK false) max@0: set(ARMA_USE_BLAS false) max@0: set(ARMA_USE_ATLAS false) max@0: set(ARMA_USE_BOOST false) max@0: set(ARMA_USE_WRAPPER true ) max@0: max@0: max@0: if(WIN32) max@0: message(STATUS "") max@0: message(STATUS "WARNING:") max@0: message(STATUS "Automatic installation is currently not available for this platform.") max@0: message(STATUS "Please use the manual installation, as described in the README.txt file.") max@0: message(STATUS "You can also use the 'include' folder directly, but you may want to edit") max@0: message(STATUS "'include/armadillo_bits/config.hpp' if you have LAPACK installed.") max@0: message(STATUS "") max@0: endif() max@0: max@0: max@0: max@0: # max@0: # Find LAPACK and BLAS libraries, or their optimised versions max@0: # max@0: max@0: if(APPLE) max@0: set(ARMA_OS macos) max@0: max@0: set(ARMA_USE_LAPACK true) max@0: set(ARMA_USE_BLAS true) max@0: max@0: # Under MacOS, the current version of ARMA_FindCLAPACK can get confused between max@0: # two incompatible versions of "clapack.h" (one provided by the system and one max@0: # provided by ATLAS). As such, use of ATLAS under MacOS is disabled for now. max@0: max@0: else() max@0: set(ARMA_OS unix) max@0: max@0: include(ARMA_FindMKL) max@0: include(ARMA_FindACMLMP) max@0: include(ARMA_FindACML) max@0: max@0: message(STATUS "MKL_FOUND = ${MKL_FOUND}") max@0: message(STATUS "ACMLMP_FOUND = ${ACMLMP_FOUND}") max@0: message(STATUS "ACML_FOUND = ${ACML_FOUND}") max@0: max@0: if(MKL_FOUND OR ACMLMP_FOUND OR ACML_FOUND) max@0: max@0: set(ARMA_USE_BLAS true) max@0: set(ARMA_USE_LAPACK true) max@0: max@0: message(STATUS "*** If the MKL or ACML libraries are installed in a non-standard location,") max@0: message(STATUS "*** make sure the run-time linker can find them.") max@0: message(STATUS "*** On Linux systems this can be done by editing /etc/ld.so.conf") max@0: message(STATUS "*** or modifying the LD_LIBRARY_PATH environment variable.") max@0: message(STATUS "*** On systems with SELinux enabled (e.g. Fedora, RHEL),") max@0: message(STATUS "*** you may need to change the SELinux type of all MKL/ACML libraries") max@0: message(STATUS "*** to fix permission problems that may occur during run-time.") max@0: message(STATUS "*** See README.txt for more information") max@0: max@0: else() max@0: max@0: include(ARMA_FindLAPACK) max@0: include(ARMA_FindBLAS) max@0: include(ARMA_FindCLAPACK) max@0: include(ARMA_FindCBLAS) max@0: max@0: message(STATUS "LAPACK_FOUND = ${LAPACK_FOUND}") max@0: message(STATUS "BLAS_FOUND = ${BLAS_FOUND}") max@0: message(STATUS "CLAPACK_FOUND = ${CLAPACK_FOUND}") max@0: message(STATUS "CBLAS_FOUND = ${CBLAS_FOUND}") max@0: max@0: if(LAPACK_FOUND) max@0: set(ARMA_USE_LAPACK true) max@0: endif() max@0: max@0: if(BLAS_FOUND) max@0: set(ARMA_USE_BLAS true) max@0: endif() max@0: max@0: if(CLAPACK_FOUND AND CBLAS_FOUND) max@0: message(STATUS "CLAPACK_INCLUDE_DIR = ${CLAPACK_INCLUDE_DIR}") max@0: message(STATUS "CBLAS_INCLUDE_DIR = ${CBLAS_INCLUDE_DIR}") max@0: if(${CLAPACK_INCLUDE_DIR} STREQUAL ${CBLAS_INCLUDE_DIR}) max@0: set(ARMA_USE_ATLAS true) max@0: set(ARMA_ATLAS_INCLUDE_DIR ${CLAPACK_INCLUDE_DIR}) max@0: endif() max@0: endif() max@0: max@0: endif() max@0: max@0: endif() max@0: max@0: max@0: if(MKL_FOUND OR ACMLMP_FOUND OR ACML_FOUND) max@0: max@0: if(MKL_FOUND) max@0: set(ARMA_LIBS ${ARMA_LIBS} ${MKL_LIBRARIES}) max@0: max@0: if(ACMLMP_FOUND OR ACML_FOUND) max@0: message(STATUS "*** Intel MKL as well as AMD ACML libraries were found.") max@0: message(STATUS "*** Using only the MKL library to avoid linking conflicts.") max@0: message(STATUS "*** If you wish to use ACML instead, please link manually with") max@0: message(STATUS "*** acml or acml_mp instead of the armadillo run-time component.") max@0: message(STATUS "*** Alternatively, remove MKL from your system and rerun") max@0: message(STATUS "*** Armadillo's configuration using ./configure") max@0: endif() max@0: max@0: else() max@0: max@0: if(ACMLMP_FOUND) max@0: set(ARMA_LIBS ${ARMA_LIBS} ${ACMLMP_LIBRARIES}) max@0: max@0: message(STATUS "*** Both single-core and multi-core ACML libraries were found.") max@0: message(STATUS "*** Using only the multi-core library to avoid linking conflicts.") max@0: else() max@0: if(ACML_FOUND) max@0: set(ARMA_LIBS ${ARMA_LIBS} ${ACML_LIBRARIES}) max@0: endif() max@0: endif() max@0: max@0: endif() max@0: max@0: else() max@0: max@0: if(ARMA_USE_BLAS STREQUAL true) max@0: set(ARMA_LIBS ${ARMA_LIBS} ${BLAS_LIBRARIES}) max@0: endif() max@0: max@0: if(ARMA_USE_LAPACK STREQUAL true) max@0: set(ARMA_LIBS ${ARMA_LIBS} ${LAPACK_LIBRARIES}) max@0: endif() max@0: max@0: if(ARMA_USE_ATLAS STREQUAL true) max@0: set(ARMA_LIBS ${ARMA_LIBS} ${CBLAS_LIBRARIES}) max@0: set(ARMA_LIBS ${ARMA_LIBS} ${CLAPACK_LIBRARIES}) max@0: endif() max@0: max@0: endif() max@0: max@0: max@0: if(APPLE) max@0: set(ARMA_LIBS ${ARMA_LIBS} "-framework Accelerate") # or "-framework accelerate" ? max@0: message(STATUS "MacOS X detected. Added '-framework Accelerate' to compiler flags") max@0: endif() max@0: max@0: message(STATUS "*** ") max@0: message(STATUS "*** The Armadillo run-time library component will be an alias for the following libraries:") max@0: message(STATUS "*** ARMA_LIBS = ${ARMA_LIBS}") max@0: message(STATUS "*** ") max@0: max@0: find_package(Boost) max@0: max@0: if(Boost_FOUND) max@0: max@0: message(STATUS "Boost_MAJOR_VERSION = ${Boost_MAJOR_VERSION}") max@0: message(STATUS "Boost_MINOR_VERSION = ${Boost_MINOR_VERSION}") max@0: max@0: if(Boost_MAJOR_VERSION GREATER 0) max@0: if(Boost_MINOR_VERSION GREATER 33) max@0: set(ARMA_USE_BOOST true) max@0: message(STATUS "Boost_INCLUDE_DIR = ${Boost_INCLUDE_DIR}") max@0: endif() max@0: endif() max@0: max@0: endif() max@0: max@0: if(ARMA_USE_BOOST STREQUAL false) max@0: message(STATUS "Boost libraries either not found or their version is too low (version 1.34 or later is good).") max@0: message(STATUS "( It's possible that CMake didn't find the particular version of Boost you may have. )") max@0: message(STATUS "( If that's the case, please edit include/armadillo_bits/config.hpp manually. )") max@0: endif() max@0: max@0: max@0: # If Boost libraries were found, explicitly check if Boost's date_time library is also present. max@0: # This is due to the non-standard packaging of Boost libraries on Debian and Ubuntu systems, max@0: # where certain individual Boost libraries are packaged separately. max@0: max@0: if(ARMA_USE_BOOST STREQUAL true) max@0: set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Boost_INCLUDE_DIR}) max@0: CHECK_INCLUDE_FILE_CXX("boost/date_time/posix_time/posix_time.hpp" ARMA_USE_BOOST_DATE) max@0: endif() max@0: max@0: ARMA_CHECK_MATH_PROTO("isfinite" "std" "cmath" ARMA_HAVE_STD_ISFINITE) max@0: ARMA_CHECK_MATH_PROTO("isinf" "std" "cmath" ARMA_HAVE_STD_ISINF) max@0: ARMA_CHECK_MATH_PROTO("isnan" "std" "cmath" ARMA_HAVE_STD_ISNAN) max@0: ARMA_CHECK_MATH_PROTO("log1p" "" "cmath" ARMA_HAVE_LOG1P) max@0: max@0: ARMA_CHECK_PROTO("snprintf" "std" "cstdio" ARMA_HAVE_STD_SNPRINTF) max@0: ARMA_CHECK_PROTO("gettimeofday" "" "sys/time.h" ARMA_HAVE_GETTIMEOFDAY) max@0: max@0: max@0: message(STATUS "Generating 'include/armadillo_bits/config.hpp'") max@0: configure_file(include/armadillo_bits/config.hpp.cmake include/armadillo_bits/config.hpp) max@0: max@0: message(STATUS "Generating 'examples/Makefile'") max@0: configure_file(examples/Makefile.cmake examples/Makefile) max@0: max@0: max@0: if(ARMA_USE_BOOST STREQUAL true) max@0: include_directories(include ${Boost_INCLUDE_DIR}) max@0: else() max@0: include_directories(include) max@0: endif() max@0: max@0: max@0: ## For any library that is not in a default location, max@0: ## embed its path into the Armadillo runtime library. max@0: ## Examples of default locations are "/lib", "/usr/lib", max@0: ## or as specified in "/etc/ld.so.conf". max@0: ## max@0: ## Path embedding is not recommended unless you know max@0: ## what you're doing. It might be better to add the max@0: ## path to the "/etc/ld.so.conf" file and then run "ldconfig". max@0: ## max@0: #set(CMAKE_SKIP_BUILD_RPATH FALSE) max@0: #set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) max@0: #set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) max@0: max@0: max@0: add_library( armadillo SHARED src/wrap_libs ) max@0: target_link_libraries( armadillo ${ARMA_LIBS} ) max@0: max@0: set_target_properties(armadillo PROPERTIES VERSION ${ARMA_MAJOR}.${ARMA_MINOR}.${ARMA_PATCH} SOVERSION 2) max@0: max@0: max@0: max@0: ################################################################################ max@0: # INSTALL CONFIGURATION max@0: max@0: max@0: # As Red Hat Enterprise Linux (and related systems such as Fedora) max@0: # does not search /usr/local/lib by default, we need to place the max@0: # library in either /usr/lib or /usr/lib64 max@0: max@0: if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) max@0: set(CMAKE_INSTALL_PREFIX "/usr") max@0: endif() max@0: max@0: # Allow for the "lib" directory to be specified on the command line max@0: if(NOT INSTALL_LIB_DIR) max@0: set(INSTALL_LIB_DIR "lib") max@0: if(UNIX AND NOT APPLE) # I don't know how Mac OS handles 64 bit systems max@0: if(CMAKE_SIZEOF_VOID_P EQUAL 8) max@0: message(STATUS "Detected 64 bit system") max@0: if(IS_DIRECTORY "${CMAKE_INSTALL_PREFIX}/lib64") max@0: unset(INSTALL_LIB_DIR) max@0: set(INSTALL_LIB_DIR "lib64") max@0: endif() max@0: endif() max@0: endif() max@0: endif() max@0: max@0: # Allow for the "include" directory to be specified on the command line max@0: max@0: if(NOT INSTALL_INCLUDE_DIR) max@0: set(INSTALL_INCLUDE_DIR "include") max@0: endif() max@0: max@0: # We use data dir to store files shared with other programs max@0: # like the ArmadilloConfig.cmake file. max@0: if(NOT INSTALL_DATA_DIR) max@0: set(INSTALL_DATA_DIR "share") max@0: endif() max@0: max@0: # Make relative paths absolute so we can write them in Config.cmake files max@0: foreach(p LIB INCLUDE DATA) max@0: set(var INSTALL_${p}_DIR) max@0: if(NOT IS_ABSOLUTE "${${var}}") max@0: set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") max@0: endif() max@0: endforeach() max@0: max@0: message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}") max@0: message(STATUS "INSTALL_LIB_DIR = ${INSTALL_LIB_DIR}" ) max@0: message(STATUS "INSTALL_INCLUDE_DIR = ${INSTALL_INCLUDE_DIR}" ) max@0: message(STATUS "INSTALL_DATA_DIR = ${INSTALL_DATA_DIR}" ) max@0: max@0: max@0: # Note that the trailing / character in "include/" is critical max@0: max@0: install(DIRECTORY include/ DESTINATION ${INSTALL_INCLUDE_DIR} max@0: PATTERN ".svn" EXCLUDE max@0: PATTERN "*.cmake" EXCLUDE max@0: PATTERN "*~" EXCLUDE max@0: PATTERN "*orig" EXCLUDE max@0: ) max@0: max@0: install(TARGETS armadillo max@0: DESTINATION ${INSTALL_LIB_DIR} max@0: EXPORT ArmadilloLibraryDepends) max@0: max@0: # Export the package for use from the build-tree max@0: # (this registers the build-tree with a global CMake-registry) max@0: if(CMAKE_VERSION VERSION_GREATER "2.7") max@0: export(PACKAGE armadillo) max@0: endif() max@0: max@0: ## LOCAL FILES max@0: # Create ArmadilloConfig.cmake file for the use from the build tree max@0: set(ARMADILLO_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}") max@0: set(ARMADILLO_LIB_DIR "${PROJECT_BINARY_DIR}") max@0: set(ARMADILLO_CMAKE_DIR "${PROJECT_BINARY_DIR}") max@0: max@0: max@0: message(STATUS "Generating '${PROJECT_BINARY_DIR}/ArmadilloConfig.cmake'") max@0: # copy/change config and configVersion file (modify only the @xyz@ variables) max@0: configure_file(build_aux/cmake/InstallFiles/ArmadilloConfig.cmake.in max@0: "${PROJECT_BINARY_DIR}/ArmadilloConfig.cmake" @ONLY) max@0: max@0: message(STATUS "Generating '${PROJECT_BINARY_DIR}/ArmadilloConfigVersion.cmake'") max@0: configure_file(build_aux/cmake/InstallFiles/ArmadilloConfigVersion.cmake.in max@0: "${PROJECT_BINARY_DIR}/ArmadilloConfigVersion.cmake" @ONLY) max@0: max@0: max@0: # Install the export set for use with the install-tree max@0: install(EXPORT ArmadilloLibraryDepends DESTINATION max@0: "${INSTALL_DATA_DIR}/Armadillo/CMake" max@0: COMPONENT dev) max@0: max@0: max@0: ## GLOBAL INSTALL FILES max@0: # Create ArmadilloConfig.cmake file for the use from the install tree max@0: # and install it max@0: set(ARMADILLO_INCLUDE_DIRS "${INSTALL_INCLUDE_DIR}") max@0: set(ARMADILLO_LIB_DIR "${INSTALL_LIB_DIR}") max@0: set(ARMADILLO_CMAKE_DIR "${INSTALL_DATA_DIR}/Armadillo/CMake") max@0: max@0: max@0: message(STATUS "Generating '${PROJECT_BINARY_DIR}/InstallFiles/ArmadilloConfig.cmake'") max@0: # copy/change config and configVersion file (modify only the @xyz@ variables) max@0: configure_file(build_aux/cmake/InstallFiles/ArmadilloConfig.cmake.in max@0: "${PROJECT_BINARY_DIR}/InstallFiles/ArmadilloConfig.cmake" @ONLY) max@0: max@0: message(STATUS "Generating '${PROJECT_BINARY_DIR}/InstallFiles/ArmadilloConfigVersion.cmake'") max@0: configure_file(build_aux/cmake/InstallFiles/ArmadilloConfigVersion.cmake.in max@0: "${PROJECT_BINARY_DIR}/InstallFiles/ArmadilloConfigVersion.cmake" @ONLY) max@0: max@0: # Install files to be found by cmake users with find_package() max@0: install(FILES max@0: "${PROJECT_BINARY_DIR}/InstallFiles/ArmadilloConfig.cmake" max@0: "${PROJECT_BINARY_DIR}/InstallFiles/ArmadilloConfigVersion.cmake" max@0: DESTINATION "${ARMADILLO_CMAKE_DIR}" COMPONENT dev)