conditional build scripts with boost xor eigen
This commit is contained in:
parent
42be24628e
commit
766ac33c5a
11 changed files with 134 additions and 14 deletions
|
|
@ -29,25 +29,57 @@ SET(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
# include useful features for cmake
|
# 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(FindDoxygen)
|
||||||
INCLUDE(FindPkgConfig)
|
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)
|
FIND_PACKAGE(EO)
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${EO_INCLUDE_DIRS}
|
${EO_INCLUDE_DIRS}
|
||||||
${MO_INCLUDE_DIRS}
|
${MO_INCLUDE_DIRS}
|
||||||
${Boost_INCLUDE_DIRS}
|
)
|
||||||
# /Dev/ometah-0.3/common
|
|
||||||
)
|
|
||||||
|
|
||||||
LINK_DIRECTORIES(
|
LINK_DIRECTORIES(
|
||||||
${EO_LIBRARY_DIRS}
|
${EO_LIBRARY_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
|
|
@ -58,7 +90,7 @@ LINK_DIRECTORIES(
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||||
)
|
)
|
||||||
|
|
||||||
######################################################################################
|
######################################################################################
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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})
|
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
|
||||||
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
SET(RESOURCES
|
SET(RESOURCES
|
||||||
${PROJECT_NAME}.param
|
${PROJECT_NAME}.param
|
||||||
)
|
)
|
||||||
|
|
@ -19,10 +24,13 @@ FOREACH(file ${RESOURCES})
|
||||||
)
|
)
|
||||||
ENDFOREACH(file)
|
ENDFOREACH(file)
|
||||||
|
|
||||||
FILE(GLOB SOURCES *.cpp)
|
#FILE(GLOB SOURCES *.cpp)
|
||||||
|
|
||||||
SET(EXECUTABLE_OUTPUT_PATH ${EDO_BINARY_DIR})
|
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})
|
TARGET_LINK_LIBRARIES(${PROJECT_NAME} edo edoutils ${EO_LIBRARIES} ${Boost_LIBRARIES})
|
||||||
|
|
||||||
|
IF( WITH_EIGEN )
|
||||||
|
ADD_EXECUTABLE(t-eigen t-eigen.cpp)
|
||||||
|
ENDIF()
|
||||||
|
|
|
||||||
15
edo/application/cmaes/t-eigen.cpp
Normal file
15
edo/application/cmaes/t-eigen.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
mkdir -p debug
|
mkdir -p debug
|
||||||
cd debug
|
cd debug
|
||||||
cmake -DCMAKE_BUILD_TYPE=Debug ..
|
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_BOOST=1 ..
|
||||||
make
|
make
|
||||||
cd ..
|
cd ..
|
||||||
|
|
|
||||||
7
edo/build_gcc_linux_eigen_debug
Executable file
7
edo/build_gcc_linux_eigen_debug
Executable file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
mkdir -p debug
|
||||||
|
cd debug
|
||||||
|
cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_EIGEN=1 ..
|
||||||
|
make
|
||||||
|
cd ..
|
||||||
|
|
@ -29,9 +29,11 @@ Authors:
|
||||||
#ifndef _edoEstimatorNormalMulti_h
|
#ifndef _edoEstimatorNormalMulti_h
|
||||||
#define _edoEstimatorNormalMulti_h
|
#define _edoEstimatorNormalMulti_h
|
||||||
|
|
||||||
|
|
||||||
#include "edoEstimator.h"
|
#include "edoEstimator.h"
|
||||||
#include "edoNormalMulti.h"
|
#include "edoNormalMulti.h"
|
||||||
|
|
||||||
|
#ifdef WITH_BOOST
|
||||||
//! edoEstimatorNormalMulti< EOT >
|
//! edoEstimatorNormalMulti< EOT >
|
||||||
|
|
||||||
template < typename EOT >
|
template < typename EOT >
|
||||||
|
|
@ -149,4 +151,10 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifdef WITH_EIGEN
|
||||||
|
|
||||||
|
#endif // WITH_EIGEN
|
||||||
|
#endif // WITH_BOOST
|
||||||
|
|
||||||
#endif // !_edoEstimatorNormalMulti_h
|
#endif // !_edoEstimatorNormalMulti_h
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,13 @@ Copyright (C) 2010 Thales group
|
||||||
#ifndef _edoNormalMulti_h
|
#ifndef _edoNormalMulti_h
|
||||||
#define _edoNormalMulti_h
|
#define _edoNormalMulti_h
|
||||||
|
|
||||||
|
#include "edoDistrib.h"
|
||||||
|
|
||||||
|
#ifdef WITH_BOOST
|
||||||
|
|
||||||
#include <boost/numeric/ublas/symmetric.hpp>
|
#include <boost/numeric/ublas/symmetric.hpp>
|
||||||
#include <boost/numeric/ublas/lu.hpp>
|
#include <boost/numeric/ublas/lu.hpp>
|
||||||
|
|
||||||
#include "edoDistrib.h"
|
|
||||||
|
|
||||||
namespace ublas = boost::numeric::ublas;
|
namespace ublas = boost::numeric::ublas;
|
||||||
|
|
||||||
|
|
@ -70,4 +73,11 @@ private:
|
||||||
ublas::symmetric_matrix< AtomType, ublas::lower > _varcovar;
|
ublas::symmetric_matrix< AtomType, ublas::lower > _varcovar;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifdef WITH_EIGEN
|
||||||
|
|
||||||
|
#endif // WITH_EIGEN
|
||||||
|
#endif // WITH_BOOST
|
||||||
|
|
||||||
#endif // !_edoNormalMulti_h
|
#endif // !_edoNormalMulti_h
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,9 @@ Authors:
|
||||||
#include "edoModifierMass.h"
|
#include "edoModifierMass.h"
|
||||||
#include "edoNormalMulti.h"
|
#include "edoNormalMulti.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WITH_BOOST
|
||||||
|
|
||||||
//! edoNormalMultiCenter< EOT >
|
//! edoNormalMultiCenter< EOT >
|
||||||
|
|
||||||
template < typename EOT >
|
template < typename EOT >
|
||||||
|
|
@ -47,4 +50,11 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifdef WITH_EIGEN
|
||||||
|
|
||||||
|
#endif // WITH_EIGEN
|
||||||
|
#endif // WITH_BOOST
|
||||||
|
|
||||||
|
|
||||||
#endif // !_edoNormalMultiCenter_h
|
#endif // !_edoNormalMultiCenter_h
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ Authors:
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include <edoSampler.h>
|
#include <edoSampler.h>
|
||||||
|
|
||||||
|
#ifdef WITH_BOOST
|
||||||
|
|
||||||
#include <utils/edoCholesky.h>
|
#include <utils/edoCholesky.h>
|
||||||
#include <boost/numeric/ublas/lu.hpp>
|
#include <boost/numeric/ublas/lu.hpp>
|
||||||
#include <boost/numeric/ublas/symmetric.hpp>
|
#include <boost/numeric/ublas/symmetric.hpp>
|
||||||
|
|
@ -84,4 +87,11 @@ protected:
|
||||||
cholesky::CholeskyLLT<AtomType> _cholesky;
|
cholesky::CholeskyLLT<AtomType> _cholesky;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifdef WITH_EIGEN
|
||||||
|
|
||||||
|
#endif // WITH_EIGEN
|
||||||
|
#endif // WITH_BOOST
|
||||||
|
|
||||||
|
|
||||||
#endif // !_edoSamplerNormalMulti_h
|
#endif // !_edoSamplerNormalMulti_h
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@ Authors:
|
||||||
|
|
||||||
namespace cholesky {
|
namespace cholesky {
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WITH_BOOST
|
||||||
|
|
||||||
/** Cholesky decomposition, given a matrix V, return a matrix L
|
/** Cholesky decomposition, given a matrix V, return a matrix L
|
||||||
* such as V = L L^T (L^T being the transposed of 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
|
} // namespace cholesky
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,9 @@ Authors:
|
||||||
#include "edoStat.h"
|
#include "edoStat.h"
|
||||||
#include "edoNormalMulti.h"
|
#include "edoNormalMulti.h"
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef WITH_BOOST
|
||||||
|
|
||||||
//! edoStatNormalMulti< EOT >
|
//! edoStatNormalMulti< EOT >
|
||||||
|
|
||||||
template < typename EOT >
|
template < typename EOT >
|
||||||
|
|
@ -67,4 +70,11 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
#ifdef WITH_EIGEN
|
||||||
|
|
||||||
|
#endif // WITH_EIGEN
|
||||||
|
#endif // WITH_BOOST
|
||||||
|
|
||||||
|
|
||||||
#endif // !_edoStatNormalMulti_h
|
#endif // !_edoStatNormalMulti_h
|
||||||
|
|
|
||||||
Reference in a new issue