Skip to content
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.15)

set(libcmaes_VERSION 0.10.2)
set(libcmaes_VERSION 0.10.3)

project (libcmaes
VERSION ${libcmaes_VERSION}
Expand Down Expand Up @@ -28,6 +28,7 @@ option (LIBCMAES_BUILD_TESTS "build tests" OFF)
option (LIBCMAES_BUILD_EXAMPLES "build examples" ${LIBCMAES_TOP_LEVEL})
option (LIBCMAES_USE_OPENMP "Use OpenMP for multithreading" ON)
option (LIBCMAES_ENABLE_SURROG "support for surrogates" ON)
option (LIBCMAES_EIGEN_5 "Use Eigen v5" OFF)

# Offer the user the choice of overriding the installation directories
set (INSTALL_LIB_DIR lib${LIB_SUFFIX}
Expand Down Expand Up @@ -78,8 +79,9 @@ if(LIBCMAES_BUILD_PYTHON)
endif ()
endif()


find_package (Eigen3 3.4.0 REQUIRED)
if (NOT LIBCMAES_EIGEN_5)
find_package (Eigen3 3.4.0 REQUIRED)
endif()

if (LIBCMAES_USE_OPENMP)
find_package (OpenMP QUIET)
Expand Down
30 changes: 25 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,41 @@ clone_folder: C:\projects\libcmaes
environment:
matrix:
- CMAKE_PLATFORM: "Visual Studio 14 2015"
EIGEN_VERSION: "3.3.4"
EIGEN_URL: "https://bitbucket.org/eigen/eigen/get/3.3.4.tar.gz"
EIGEN_ZIP: "3.3.4.tar.gz"
LIBCMAES_EIGEN_5: OFF
- CMAKE_PLATFORM: "Visual Studio 14 2015"
EIGEN_VERSION: "5.0.0"
EIGEN_URL: "https://gitlab.com/libeigen/eigen/-/archive/5.0.0/eigen-5.0.0.tar.gz"
EIGEN_ZIP: "eigen-5.0.0.tar.gz"
LIBCMAES_EIGEN_5: ON
- CMAKE_PLATFORM: "Visual Studio 14 2015 Win64"
EIGEN_VERSION: "3.3.4"
EIGEN_URL: "https://bitbucket.org/eigen/eigen/get/3.3.4.tar.gz"
EIGEN_ZIP: "3.3.4.tar.gz"
LIBCMAES_EIGEN_5: OFF
- CMAKE_PLATFORM: "Visual Studio 14 2015 Win64"
EIGEN_VERSION: "5.0.0"
EIGEN_URL: "https://gitlab.com/libeigen/eigen/-/archive/5.0.0/eigen-5.0.0.tar.gz"
EIGEN_ZIP: "eigen-5.0.0.tar.gz"
LIBCMAES_EIGEN_5: ON

install:
- cinstall: python
- appveyor-retry appveyor DownloadFile https://bitbucket.org/eigen/eigen/get/3.3.4.tar.gz
- 7z x 3.3.4.tar.gz -oc:\projects > nul
- 7z x c:\projects\3.3.4.tar -oc:\projects > nul
- cd c:\projects\eigen-eigen-5a0156e40feb
- appveyor-retry appveyor DownloadFile "%EIGEN_URL%" -FileName eigen.tar.gz
- 7z x eigen.tar.gz -oc:\projects > nul
- 7z x c:\projects\eigen.tar -oc:\projects > nul
- cd c:\projects
- for /d %%i in (eigen-*) do set EIGEN_DIR=%%i
- cd %EIGEN_DIR%
- mkdir build && cd build
- cmake -G "%CMAKE_PLATFORM%" -DCMAKE_INSTALL_PREFIX=c:\Libraries\eigen -DCMAKE_BUILD_TYPE=Release ..
- cmake --build . --config Release --target install

build_script:
- cd c:\projects\libcmaes
- mkdir build && cd build
- cmake -G "%CMAKE_PLATFORM%" -DCMAKE_INSTALL_PREFIX=c:\Libraries\libcmaes -DEigen3_DIR=c:\Libraries\eigen\share\eigen3\cmake -DBOOST_ROOT="C:/Libraries/boost_1_63_0" ..
- cmake -G "%CMAKE_PLATFORM%" -DCMAKE_INSTALL_PREFIX=c:\Libraries\libcmaes -DLIBCMAES_EIGEN_5=%LIBCMAES_EIGEN_5% -DEigen3_DIR=c:\Libraries\eigen\share\eigen3\cmake -DBOOST_ROOT="C:/Libraries/boost_1_63_0" ..
- cmake --build . --config Release --target install
- ctest -C Release
11 changes: 9 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,22 @@ class CmaesConan(ConanFile):

# Binary configuration
settings = "os", "compiler", "build_type", "arch"

generators = "cmake"
options = {
"shared": [True, False],
"openmp": [True, False],
"surrog": [True, False],
"enable_tests": [True, False],
"eigen_5": [True, False],
}
default_options = {
"shared": True,
"openmp": True,
"surrog": True,
"enable_tests": False,
"boost/*:without_python": False,
"eigen_5": False,
}

# Sources are located in the same place as this recipe, copy them to the recipe
Expand All @@ -55,8 +59,10 @@ def build_requirements(self):
self.test_requires("boost/1.85.0")

def requirements(self):
self.requires("eigen/3.4.0", transitive_headers=True)

if self.options.eigen_5:
self.requires("eigen/5.0.0")
else:
self.requires("eigen/3.4.0", transitive_headers=True)
if self.options.openmp and self.settings.os != "Windows":
self.requires("llvm-openmp/17.0.6", transitive_headers=True)

Expand Down Expand Up @@ -94,6 +100,7 @@ def generate(self):
tc.variables["LIBCMAES_ENABLE_SURROG"] = self.options.surrog
tc.variables["LIBCMAES_BUILD_PYTHON"] = self.options.enable_tests
tc.variables["LIBCMAES_BUILD_TESTS"] = self.options.enable_tests
tc.variables["LIBCMAES_EIGEN_5"] = self.options.eigen_5
tc.generate()

def build(self):
Expand Down
11 changes: 10 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ target_include_directories (
cmaes PUBLIC $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
)
target_link_libraries (cmaes PUBLIC Eigen3::Eigen)

if (LIBCMAES_EIGEN_5)
include (${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

target_link_libraries (cmaes PUBLIC CONAN_PKG::eigen)
else ()
target_link_libraries (cmaes PUBLIC Eigen3::Eigen)
endif ()

if (LIBCMAES_USE_OPENMP)
target_link_libraries (cmaes PUBLIC OpenMP::OpenMP_CXX)
endif ()
Expand Down
Loading