Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for conan package #234

Open
wants to merge 53 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
621bd19
Enable to get dependencies through conan.
Apr 8, 2022
97f1918
Fixed missed python cmake links
Apr 9, 2022
1aacd71
Fixed windows compile problems
phbasler Apr 10, 2022
7f5fa1b
cmake was not using the cmake files provided by conan, fixed it toget…
Apr 10, 2022
10460e1
Merge pull request #4 from phbasler/cmake-windows
phbasler Apr 10, 2022
f083088
Had to include scalar_normal_dist_op copy ctr for MVSC compiler and M…
phbasler Apr 10, 2022
f065ae5
Conan windows (#5)
phbasler Apr 28, 2022
55f2d39
Add conan to readme
Apr 28, 2022
b5f8687
Merge branch 'master' into conan
phbasler May 4, 2022
1d3eca5
Fixed doc target if cmaes is included as a subdirectory
May 4, 2022
7827c96
Use the LIBCMAES_TOP_LEVEL variable instead
May 4, 2022
0ecfc3b
Update README.md
phbasler May 7, 2022
b43565e
Adding conanfile (#6)
phbasler Sep 10, 2022
016f5cb
Change in conanfile to retrigger workflow
phbasler Mar 22, 2023
25ee637
Update for conan 2
Jun 1, 2024
3f6a5bd
Fix cmake target name
Jun 1, 2024
dc49bc7
Merge branch 'conan' of https://github.com/phbasler/libcmaes into conan
Jun 1, 2024
7640f16
Add workflow for conan create
Jun 1, 2024
c9d6539
Update conan.yml
phbasler Jun 1, 2024
bb4a850
test workflow
Jun 1, 2024
c80bce9
run detect
Jun 1, 2024
d4b334f
remove test branch
Jun 1, 2024
41b1bf8
format with black
Jun 1, 2024
b04a492
Merge branch 'master' into conan
phbasler Jun 1, 2024
2e330a8
remove refreshenv
Jun 1, 2024
5c4f091
Merge branch 'conan' of https://github.com/phbasler/libcmaes into conan
Jun 1, 2024
e9b461d
Rename test name so that cmake finds it
Jun 1, 2024
0850f7e
fix mac os pip install
Jun 1, 2024
e05092a
try to fix workflows
Jun 1, 2024
23a3e4a
update windows runner
Jun 1, 2024
0914836
use new conan provider file
Jun 1, 2024
e0abfcd
install eigen through choco
Jun 1, 2024
4140bce
add missing pip package
Jun 1, 2024
485e0a5
try conan provider file for gflags on windows
Jun 1, 2024
94ef8da
try through conan
Jun 1, 2024
d177845
Install conan
phbasler Jun 1, 2024
e2ada20
Update windows_unit_tests.yml
phbasler Jun 1, 2024
f504bbb
Update boost version
Jun 2, 2024
01ee12a
change preset name
Jun 2, 2024
c85eaf7
execute unit tests through conan
Jun 2, 2024
320e524
export tests
Jun 2, 2024
8a6d414
add missing python export
Jun 2, 2024
a1a9802
remove unused file
Jun 2, 2024
de733a0
Remove unused option
Jun 2, 2024
4c44f41
Add openmp as dependency
phbasler Jun 4, 2024
0bab1ea
only mp in not windows
phbasler Jun 4, 2024
15e50ce
fix typo
phbasler Jun 4, 2024
5ac44a5
Format conanfile
phbasler Dec 5, 2024
160bb4f
Run unit tests in conan
phbasler Dec 5, 2024
1883014
Revert "Run unit tests in conan"
phbasler Dec 5, 2024
457b9fc
Remove build missing
phbasler Dec 5, 2024
783c3ac
fix syntax
phbasler Dec 5, 2024
cef09f0
Remove windows unit tests
phbasler Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/conan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Run conan

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:
conan:
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{matrix.os}}
if: "!contains(github.event.head_commit.message, 'skip-ci')"

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install conan
run: pip install conan>2
- run: conan profile detect
- run: conan create . --build=missing --options shared=True
name: Build shared
- run: conan create . --build=missing --options shared=False
name: Build static
32 changes: 32 additions & 0 deletions .github/workflows/test-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Mac unit tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
mac-tests:
runs-on: macos-latest
if: "!contains(github.event.head_commit.message, 'skip-ci')"

steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name : installPackages
run : brew install eigen boost boost-python3 libomp gflags
- name : install python packages
run: pip3 install numpy setuptools --break-system-packages
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
- name: cmake
run: mkdir build && cd build && cmake .. -DLIBCMAES_BUILD_PYTHON=On -DLIBCMAES_BUILD_TESTS=On -DLIBCMAES_USE_OPENMP=On
- name: compile
run: cd build && cmake --build . -j${{ steps.cpu-cores.outputs.count }}
- name: Run ctest
run: cd build && ctest -j${{ steps.cpu-cores.outputs.count }} --output-on-failure

34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Ubuntu unit tests

on:
push:
branches: [ master]
pull_request:
branches: [ master, develop ]
workflow_dispatch:


jobs:
ubuntu-tests-fullSetup:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'skip-ci')"

steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name : installPackages
run : sudo apt-get update && sudo apt-get install --no-install-recommends --yes libeigen3-dev libboost-all-dev libgflags-dev
- name : install python packages
run: pip3 install numpy
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
- name: cmake
run: mkdir build && cd build && cmake .. -DLIBCMAES_BUILD_PYTHON=On -DLIBCMAES_BUILD_TESTS=On -DLIBCMAES_USE_OPENMP=On
- name: compile
run: cd build && cmake --build . -j${{ steps.cpu-cores.outputs.count }}
- name: Run ctest
run: cd build && ctest -j${{ steps.cpu-cores.outputs.count }} --output-on-failure


8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
build/
CMakeLists.txt.user
CMakeUserPresets.json
install/
installFolder/
conandummy/
test_package/CMakeUserPresets.json
lib/
81 changes: 49 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
cmake_minimum_required (VERSION 3.9)
cmake_minimum_required (VERSION 3.15)

set(libcmaes_VERSION 0.10.1)

project (libcmaes
VERSION 0.10
VERSION ${libcmaes_VERSION}
LANGUAGES C CXX
DESCRIPTION "A C++11 library for stochastic optimization with CMA-ES")

if (NOT DEFINED CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
endif ()

set(CMAKE_CXX_FLAGS "-Wall -Wextra")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")

list (APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

include(CompilerOptions)

set (LIBCMAES_TOP_LEVEL NO)
if (${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
set (LIBCMAES_TOP_LEVEL YES)
Expand Down Expand Up @@ -66,7 +67,19 @@ check_include_file (sys/types.h HAVE_SYS_TYPES_H)
check_include_file (sys/stat.h HAVE_SYS_STAT_H)

# ---------- dependencies ----------
find_package (Eigen3 3.0.0 REQUIRED)
if(LIBCMAES_BUILD_PYTHON)
find_package (Python3 COMPONENTS Interpreter Development NumPy)
if (NOT TARGET Python3::Module AND Python3_Development_FOUND)
add_library (Python3::Module SHARED IMPORTED)
set_target_properties (
Python3::Module
PROPERTIES IMPORTED_LOCATION ${Python3_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${Python3_INCLUDE_DIRS})
endif ()
endif()


find_package (Eigen3 3.4.0 REQUIRED)

if (LIBCMAES_USE_OPENMP)
find_package (OpenMP QUIET)
Expand All @@ -77,24 +90,21 @@ if (LIBCMAES_USE_OPENMP)
endif ()

if (LIBCMAES_BUILD_PYTHON)
find_package (PythonInterp)
find_package (PythonLibs)
if (NOT TARGET Python::Module AND PYTHONLIBS_FOUND)
add_library (Python::Module SHARED IMPORTED)
find_package (Python3 COMPONENTS Interpreter Development NumPy)
if (NOT TARGET Python3::Module AND Python3_Development_FOUND)
add_library (Python3::Module SHARED IMPORTED)
set_target_properties (
Python::Module
PROPERTIES IMPORTED_LOCATION ${PYTHON_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
Python3::Module
PROPERTIES IMPORTED_LOCATION ${Python3_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${Python3_INCLUDE_DIRS})
endif ()

find_package (NumPy)

# python site dir
if (PYTHON_EXECUTABLE AND NOT DEFINED PYTHON_SITE_PACKAGES)
if (Python3_EXECUTABLE AND NOT DEFINED PYTHON_SITE_PACKAGES)
# $ENV{VIRTUAL_ENV} does not work because not exported by activate :/
execute_process (
COMMAND
${PYTHON_EXECUTABLE} -c "
${Python3_EXECUTABLE} -c "
import sys;
if 'real_prefix' in dir(sys):
print(sys.prefix)"
Expand All @@ -107,7 +117,7 @@ if 'real_prefix' in dir(sys):
endif ()
execute_process (
COMMAND
${PYTHON_EXECUTABLE} -c
${Python3_EXECUTABLE} -c
"from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${SITE_DIR_PREFIX}'))"
OUTPUT_VARIABLE _ABS_PYTHON_SITE_PACKAGES
RESULT_VARIABLE _exit_code
Expand All @@ -120,7 +130,7 @@ if 'real_prefix' in dir(sys):
${_ABS_PYTHON_SITE_PACKAGES})
set (PYTHON_SITE_PACKAGES ${_REL_PYTHON_SITE_PACKAGES})
else ()
message (SEND_ERROR "Could not run ${PYTHON_EXECUTABLE}")
message (SEND_ERROR "Could not run ${Python3_EXECUTABLE}")
endif ()
endif ()

Expand Down Expand Up @@ -161,42 +171,49 @@ if (LIBCMAES_BUILD_EXAMPLES)
add_subdirectory (examples)
endif ()
if (LIBCMAES_BUILD_TESTS)
enable_testing ()
include(CTest)
add_subdirectory (tests)
endif ()

if (Boost_FOUND AND NumPy_FOUND)
if (Boost_FOUND AND Python3_NumPy_FOUND)
add_subdirectory (python)
endif ()

# ------------ export ------------
add_library (libcmaes::cmaes ALIAS cmaes)

include (CMakePackageConfigHelpers)
write_basic_package_version_file (
libcmaesConfigVersion.cmake VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion)
write_basic_package_version_file(
libcmaes-config-version.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion)



configure_package_config_file(
libcmaes-config.cmake.in
libcmaes-config.cmake
INSTALL_DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR})

# export target to build directory
export (TARGETS cmaes NAMESPACE libcmaes:: FILE libcmaesTargets.cmake)

# export target on install
install (
EXPORT libcmaesTargets
FILE libcmaesTargets.cmake
NAMESPACE libcmaes::
DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR})

configure_file (libcmaesConfig.cmake.in libcmaesConfig.cmake @ONLY)
install (
FILES "${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/libcmaesConfigVersion.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindEigen3.cmake"
FILES "${CMAKE_CURRENT_BINARY_DIR}/libcmaes-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/libcmaes-config-version.cmake"
DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR})

# ------------------------ Doxygen --------------------------------------------

find_package(Doxygen)
if(DOXYGEN_FOUND)
if(DOXYGEN_FOUND AND LIBCMAES_TOP_LEVEL)

set(DOXYGEN_USE_MATHJAX YES)
set(DOXYGEN_STRIP_FROM_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include")
Expand All @@ -213,6 +230,6 @@ if(DOXYGEN_FOUND)
"${CMAKE_CURRENT_SOURCE_DIR}/src/"
"${CMAKE_CURRENT_SOURCE_DIR}/README.md")

else (DOXYGEN_FOUND)
else ()
message("Doxygen need to be installed to generate the doxygen documentation")
endif(DOXYGEN_FOUND)
endif()
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## libcmaes

[![Doxygen](https://img.shields.io/badge/Documentation-Doxygen-success)](https://beniz.github.io/libcmaes/doc/html/index.html)
[![Doxygen](https://img.shields.io/badge/Documentation-Doxygen-success)](https://cma-es.github.io/libcmaes/doc/html/index.html)

libcmaes is a multithreaded C++11 implementation (with Python bindings) of algorithms of the CMA-ES family for optimization of nonlinear non-convex 'blackbox' functions. The implemented algorithms have a wide range of applications in various disciplines, ranging from pure function minimization, optimization in industrial and scientific applications, to the solving of reinforcement and machine learning problems.

Expand All @@ -26,7 +26,7 @@ Current features include:
Documentation:

- Full documentation is available from https://github.com/beniz/libcmaes/wiki
- API documentation is available from http://beniz.github.io/libcmaes/doc/html/index.html
- API documentation is available from https://cma-es.github.io/libcmaes/doc/html/index.html

Dependencies:

Expand Down
Loading
Loading