conditional build scripts with boost xor eigen

This commit is contained in:
nojhan 2012-07-09 16:26:19 +02:00
commit 766ac33c5a
11 changed files with 134 additions and 14 deletions

View file

@ -29,25 +29,57 @@ SET(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT
######################################################################################
# include useful features for cmake
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/cmake/modules)
INCLUDE(FindDoxygen)
INCLUDE(FindPkgConfig)
FIND_PACKAGE(Boost 1.33.0)
IF( WITH_BOOST AND WITH_EIGEN )
MESSAGE( "ERROR: You have to choose between Boost:ublas and Eigen, you cannot compile with both libraries" )
SET(IS_FATAL 1)
ELSEIF( NOT WITH_BOOST AND NOT WITH_EIGEN )
#MESSAGE( "WARNING: Boost:ublas and Eigen are both deactivated, some features may lack." )
# FIXME ideally, we would have a minimal implementation with STL vectors…
MESSAGE( "FIXME: Boost:ublas and Eigen are both deactivated, too much features will lack, you should choose one." )
SET(IS_FATAL 1)
ENDIF()
IF(WITH_BOOST)
FIND_PACKAGE(Boost 1.33.0)
IF( Boost_FOUND )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIRS} )
ADD_DEFINITIONS( -DWITH_BOOST )
ELSE()
MESSAGE( "ERROR: You asked for Boost:ublas but it has nost been found." )
SET(IS_FATAL 1)
ENDIF()
ELSEIF( WITH_EIGEN )
# FIXME FindEigen3.cmake does not work
#find_package(Eigen3)
#include_directories(EIGEN3_INCLUDE_DIR)
SET( EIGEN3_FOUND 1)
SET( EIGEN3_INCLUDE_DIR "/usr/include/eigen3/" )
IF( EIGEN3_FOUND )
INCLUDE_DIRECTORIES( ${EIGEN3_INCLUDE_DIR} )
ADD_DEFINITIONS( -DWITH_EIGEN )
ELSE()
MESSAGE( "ERROR: You asked for Eigen but it has nost been found." )
SET(IS_FATAL 1)
ENDIF()
ENDIF()
FIND_PACKAGE(EO)
INCLUDE_DIRECTORIES(
${EO_INCLUDE_DIRS}
${MO_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
# /Dev/ometah-0.3/common
)
)
LINK_DIRECTORIES(
${EO_LIBRARY_DIRS}
)
)
######################################################################################
@ -58,7 +90,7 @@ LINK_DIRECTORIES(
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/src
)
)
######################################################################################

View file

@ -1,12 +1,17 @@
PROJECT(cma-es)
PROJECT(cmaes)
FIND_PACKAGE(Boost 1.33.0)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
#find_package(Eigen3 REQUIRED)
#include_directories(EIGEN3_INCLUDE_DIR)
INCLUDE_DIRECTORIES( ${EIGEN3_INCLUDE_DIR} )
MESSAGE( "MESSAGE:" ${EIGEN3_INCLUDE_DIR} )
#FIND_PACKAGE(Boost 1.33.0)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
SET(RESOURCES
${PROJECT_NAME}.param
)
@ -19,10 +24,13 @@ FOREACH(file ${RESOURCES})
)
ENDFOREACH(file)
FILE(GLOB SOURCES *.cpp)
#FILE(GLOB SOURCES *.cpp)
SET(EXECUTABLE_OUTPUT_PATH ${EDO_BINARY_DIR})
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
ADD_EXECUTABLE(${PROJECT_NAME} main.cpp)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} edo edoutils ${EO_LIBRARIES} ${Boost_LIBRARIES})
IF( WITH_EIGEN )
ADD_EXECUTABLE(t-eigen t-eigen.cpp)
ENDIF()

View file

@ -0,0 +1,15 @@
#include <iostream>
#include <Eigen/Dense>
using Eigen::MatrixXd;
int main()
{
MatrixXd m(2,2);
m(0,0) = 3;
m(1,0) = 2.5;
m(0,1) = -1;
m(1,1) = m(1,0) + m(0,1);
std::cout << m << std::endl;
}

View file

@ -2,6 +2,6 @@
mkdir -p debug
cd debug
cmake -DCMAKE_BUILD_TYPE=Debug ..
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_BOOST=1 ..
make
cd ..

View file

@ -0,0 +1,7 @@
#!/usr/bin/env sh
mkdir -p debug
cd debug
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_EIGEN=1 ..
make
cd ..

View file

@ -29,9 +29,11 @@ Authors:
#ifndef _edoEstimatorNormalMulti_h
#define _edoEstimatorNormalMulti_h
#include "edoEstimator.h"
#include "edoNormalMulti.h"
#ifdef WITH_BOOST
//! edoEstimatorNormalMulti< EOT >
template < typename EOT >
@ -149,4 +151,10 @@ public:
}
};
#else
#ifdef WITH_EIGEN
#endif // WITH_EIGEN
#endif // WITH_BOOST
#endif // !_edoEstimatorNormalMulti_h

View file

@ -28,10 +28,13 @@ Copyright (C) 2010 Thales group
#ifndef _edoNormalMulti_h
#define _edoNormalMulti_h
#include "edoDistrib.h"
#ifdef WITH_BOOST
#include <boost/numeric/ublas/symmetric.hpp>
#include <boost/numeric/ublas/lu.hpp>
#include "edoDistrib.h"
namespace ublas = boost::numeric::ublas;
@ -70,4 +73,11 @@ private:
ublas::symmetric_matrix< AtomType, ublas::lower > _varcovar;
};
#else
#ifdef WITH_EIGEN
#endif // WITH_EIGEN
#endif // WITH_BOOST
#endif // !_edoNormalMulti_h

View file

@ -31,6 +31,9 @@ Authors:
#include "edoModifierMass.h"
#include "edoNormalMulti.h"
#ifdef WITH_BOOST
//! edoNormalMultiCenter< EOT >
template < typename EOT >
@ -47,4 +50,11 @@ public:
}
};
#else
#ifdef WITH_EIGEN
#endif // WITH_EIGEN
#endif // WITH_BOOST
#endif // !_edoNormalMultiCenter_h

View file

@ -32,6 +32,9 @@ Authors:
#include <limits>
#include <edoSampler.h>
#ifdef WITH_BOOST
#include <utils/edoCholesky.h>
#include <boost/numeric/ublas/lu.hpp>
#include <boost/numeric/ublas/symmetric.hpp>
@ -84,4 +87,11 @@ protected:
cholesky::CholeskyLLT<AtomType> _cholesky;
};
#else
#ifdef WITH_EIGEN
#endif // WITH_EIGEN
#endif // WITH_BOOST
#endif // !_edoSamplerNormalMulti_h

View file

@ -27,6 +27,9 @@ Authors:
namespace cholesky {
#ifdef WITH_BOOST
/** Cholesky decomposition, given a matrix V, return a matrix L
* such as V = L L^T (L^T being the transposed of L).
*
@ -282,4 +285,11 @@ public:
}
};
#else
#ifdef WITH_EIGEN
#endif // WITH_EIGEN
#endif // WITH_BOOST
} // namespace cholesky

View file

@ -33,6 +33,9 @@ Authors:
#include "edoStat.h"
#include "edoNormalMulti.h"
#ifdef WITH_BOOST
//! edoStatNormalMulti< EOT >
template < typename EOT >
@ -67,4 +70,11 @@ public:
}
};
#else
#ifdef WITH_EIGEN
#endif // WITH_EIGEN
#endif // WITH_BOOST
#endif // !_edoStatNormalMulti_h