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

Experimental support for statically linked NOMAD #126

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e807cff
Experimental support for statically linked NOMAD
jan-provaznik Jan 11, 2023
47e5555
Fixed CMakeFiles for C interface.
jan-provaznik Jan 11, 2023
6eb7d45
Fixed CMakeFilesLibs and setup_PyNomadStatic.
jan-provaznik Jan 11, 2023
305f7eb
Separated STATIC.
jan-provaznik Jan 12, 2023
44eaab5
Fixed up PyNomad interface
jan-provaznik Jan 12, 2023
1dd1c5e
Fixed problems with MSVC. Static build now optional.
jan-provaznik Jan 12, 2023
aca72af
Merged static libraries into nomadStatic.
jan-provaznik Jan 12, 2023
e66690a
Make PyNomad build work without installing first.
ctribes Jan 20, 2023
3b62d9c
Static build by default.
jan-provaznik Jan 21, 2023
f204bea
Fixed MSVC missing exports in CInterface header.
jan-provaznik Jan 21, 2023
d505757
Cleaned up CMakeLists*, fixed leftover comments.
jan-provaznik Jan 23, 2023
6d3154b
Merge branch 'feature-buildPyNomad-without-install' into feature-expe…
ctribes Jan 25, 2023
7510b5c
Make PyNomad build work without installing first.
ctribes Jan 25, 2023
7958771
Link against CInterface a shared nomad libraries.
jan-provaznik Jan 27, 2023
72ff71f
Merge branch 'feature-experimental-static' of https://github.com/jan-…
ctribes Feb 1, 2023
830e3f1
Updated PyNomad to work with MSVC.
jan-provaznik Feb 4, 2023
c4ccd8c
Introduced PyPi workflow.
jan-provaznik Feb 9, 2023
e542072
Introduced 'next' continuous integration workflow.
jan-provaznik Feb 11, 2023
7953441
Fixed incorrect PyNomad test.
jan-provaznik Feb 14, 2023
84c73d4
Test configuration moved to PyPi workflow.
jan-provaznik Feb 28, 2023
dbd6eb0
Renamed PyNomadStatic target to PyNomad.
jan-provaznik Feb 28, 2023
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
78 changes: 78 additions & 0 deletions .github/workflows/ci-next.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Continuous integration, next version.

on:
workflow_dispatch:

jobs:

build:
strategy:
fail-fast: false
matrix:
target:
- name: Windows
os: windows-latest
- name: Ubuntu
os: ubuntu-latest
- name: macOS
os: macos-latest
feature:
- name: with PyNomad enabled
python: true
option: >-
-DTEST_OPENMP=OFF
-DBUILD_INTERFACE_PYTHON=ON
-DBUILD_INTERFACE_C=ON
-DBUILD_EXAMPLES=ON
- name: with OpenMP enabled
python: false
option: >-
-DTEST_OPENMP=ON
-DBUILD_INTERFACE_PYTHON=OFF
-DBUILD_INTERFACE_C=ON
-DBUILD_EXAMPLES=ON

name: ${{ matrix.target.name }} ${{ matrix.feature.name }}
runs-on: ${{ matrix.target.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'

# Prepare environment

- name: Prepare Python environment
run: >-
pip install setuptools wheel cython pytest
if: ${{ matrix.feature.python }}

# Configure, build and install NOMAD

- name: Configure
run: >-
cmake ${{ matrix.feature.option }} -B build -S .

- name: Build
run: >-
cmake --build build --config Release --clean-first --parallel 2

- name: Install
run: >-
cmake --install build

# Execute tests

- name: Test (standard examples)
run: >-
ctest -C Release --test-dir build

- name: Test (PyNomad wheel)
shell: bash
run: |-
cd interfaces/PyNomad
pip install --force-reinstall dist/*.whl
pytest
if: ${{ matrix.feature.python }}

88 changes: 88 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build and publish binary wheels onto PyPi

on:
workflow_dispatch:

jobs:

build:
strategy:
fail-fast: false
matrix:
target:
- name: Windows
os: windows-latest
archs: AMD64
msvc: 1

- name: Ubuntu
os: ubuntu-latest
archs: x86_64

- name: macOS
os: macos-latest
archs: x86_64

name: Wheels for ${{ matrix.target.name }}
runs-on: ${{ matrix.target.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Build binary wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS: >-
${{ matrix.target.archs }}
CIBW_BEFORE_ALL: >-
cmake -DTEST_OPENMP=OFF -DBUILD_INTERFACE_PYTHON=OFF -DBUILD_EXAMPLES=OFF -S . -B build &&
cmake --build build --config Release --clean-first --target nomadStatic --parallel 2
CIBW_ENVIRONMENT: >-
NOMAD_SRC=../../src
NOMAD_BUILD_DIR=../../build
NOMAD_MSVC_FLAG=${{ matrix.target.msvc }}
NOMAD_MSVC_CONF=Release
CIBW_PROJECT_REQUIRES_PYTHON: >-
>=3.8
CIBW_BUILD_FRONTEND: >-
build
CIBW_BUILD_VERBOITY: >-
3
CIBW_TEST_COMMAND: >-
python -m pytest -s -- {package}/tests
CIBW_TEST_REQUIRES: >-
pytest
with:
output-dir: wheelhouse
package-dir: interfaces/PyNomad

- name: Collect wheels for processing
uses: actions/upload-artifact@v3
with:
path: wheelhouse/*.whl

# We use pypa/gh-action-pypi-publish to upload the binary wheels onto PyPi.

publish:
name: Publish to PyPi (testing)
runs-on: ubuntu-latest
needs: build

steps:
- name: Collect wheels for publication
uses: actions/download-artifact@v3
with:
name: artifact
path: wheelhouse

- name: Publish wheels to PyPi (testing)
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository_url: https://test.pypi.org/legacy/
password: ${{ secrets.PYPI_API_TOKEN }}
packages_dir: wheelhouse
skip_existing: true

4 changes: 2 additions & 2 deletions examples/advanced/library/c_api/example1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ set_target_properties(example1_c_api.exe PROPERTIES INSTALL_RPATH "${CMAKE_INSTA


if(OpenMP_CXX_FOUND)
target_link_libraries(example1_c_api.exe PUBLIC nomadAlgos nomadUtils nomadEval nomadCInterface OpenMP::OpenMP_CXX)
target_link_libraries(example1_c_api.exe PUBLIC nomadCInterface OpenMP::OpenMP_CXX)
else()
target_link_libraries(example1_c_api.exe PUBLIC nomadAlgos nomadUtils nomadEval nomadCInterface)
target_link_libraries(example1_c_api.exe PUBLIC nomadCInterface)
endif()
if (WIN32)
else()
Expand Down
4 changes: 2 additions & 2 deletions examples/advanced/library/c_api/example2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ set_target_properties(example2_c_api.exe PROPERTIES INSTALL_RPATH "${CMAKE_INSTA


if(OpenMP_CXX_FOUND)
target_link_libraries(example2_c_api.exe PUBLIC nomadAlgos nomadUtils nomadEval nomadCInterface OpenMP::OpenMP_CXX)
target_link_libraries(example2_c_api.exe PUBLIC nomadCInterface OpenMP::OpenMP_CXX)
else()
target_link_libraries(example2_c_api.exe PUBLIC nomadAlgos nomadUtils nomadEval nomadCInterface)
target_link_libraries(example2_c_api.exe PUBLIC nomadCInterface)
endif()
if (WIN32)
else()
Expand Down
50 changes: 13 additions & 37 deletions ext/sgtelib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,42 +103,18 @@ set(SGTELIB_MAIN_SOURCE src/sgtelib.cpp)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# build shared library sgtelib
add_library (sgtelib SHARED ${SGTELIB_SOURCES})
target_include_directories(sgtelib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/sgtelib>
)

# export symbols on Windows
if (WIN32)
target_compile_definitions(sgtelib PRIVATE -DDLL_EXPORTS)
endif()

#add_executable (sgtelib_main ${SGTELIB_MAIN_SOURCE})
#set_target_properties(sgtelib_main PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
#target_include_directories(sgtelib_main PUBLIC
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
# $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/sgtelib>
#)
#target_link_libraries(sgtelib_main PUBLIC sgtelib)

set_target_properties(sgtelib PROPERTIES
VERSION ${SGTELIB_VERSION}
SOVERSION ${SGTELIB_VERSION_MAJOR}.${SGTELIB_VERSION_MINOR})

# installing executables and libraries
install(TARGETS sgtelib
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sgtelib
)

# install header files
install(FILES ${SGTELIB_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/sgtelib
)


# Build shared libraries (sgtelib)
include(./CMakeListsLibs.txt)

# Build static libraries (sgtelibStatic)
include(./CMakeListsLibsStatic.txt)

# Install header files
install(
FILES
${SGTELIB_HEADERS}
DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/sgtelib
)


50 changes: 50 additions & 0 deletions ext/sgtelib/CMakeListsLibs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Shared library
#

add_library(
sgtelib
SHARED
${SGTELIB_SOURCES}
)

target_include_directories(
sgtelib
PUBLIC
$<BUILD_INTERFACE:
${CMAKE_CURRENT_SOURCE_DIR}/src
>
$<INSTALL_INTERFACE:
${CMAKE_INSTALL_INCLUDEDIR}/sgtelib
>
)

set_target_properties(
sgtelib
PROPERTIES
VERSION ${SGTELIB_VERSION}
SOVERSION ${SGTELIB_VERSION_MAJOR}.${SGTELIB_VERSION_MINOR}
OUTPUT_NAME sgtelib
)

if (WIN32)
target_compile_definitions(
sgtelib
PRIVATE
-DDLL_EXPORTS
)
endif()

# Install the library
#

install(
TARGETS
sgtelib
RUNTIME DESTINATION
${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION
${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION
${CMAKE_INSTALL_INCLUDEDIR}/sgtelib
)

48 changes: 48 additions & 0 deletions ext/sgtelib/CMakeListsLibsStatic.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Static library
#

add_library(
sgtelibStatic
STATIC
${SGTELIB_SOURCES}
)

target_include_directories(
sgtelibStatic
PUBLIC
$<BUILD_INTERFACE:
${CMAKE_CURRENT_SOURCE_DIR}/src
>
$<INSTALL_INTERFACE:
${CMAKE_INSTALL_INCLUDEDIR}/sgtelib
>
)

set_target_properties(
sgtelibStatic
PROPERTIES
VERSION ${SGTELIB_VERSION}
SOVERSION ${SGTELIB_VERSION_MAJOR}.${SGTELIB_VERSION_MINOR}
OUTPUT_NAME sgtelibStatic
)

if (WIN32)
target_compile_definitions(
sgtelibStatic
PRIVATE
-DNOMAD_STATIC_BUILD
)
endif()

# Install the library
#

install(
TARGETS
sgtelibStatic
RUNTIME DESTINATION
${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION
${CMAKE_INSTALL_LIBDIR}
)

2 changes: 1 addition & 1 deletion ext/sgtelib/src/Defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <limits.h>

// CASE Visual Studio C++ compiler
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(NOMAD_STATIC_BUILD)
#pragma warning(disable:4251)
#ifdef DLL_EXPORTS
#define DLL_API __declspec(dllexport)
Expand Down
Loading