Skip to content

Commit

Permalink
Merge pull request #46 from Fluorescence-Tools/development
Browse files Browse the repository at this point in the history
Build simplification
  • Loading branch information
tpeulen authored Nov 15, 2024
2 parents 957c767 + b3be20d commit e763cee
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 52 deletions.
25 changes: 12 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()

CMAKE_MINIMUM_REQUIRED(VERSION 3.13)
SET(PROJECT_NAME tttrlib)
PROJECT(${PROJECT_NAME})
Expand All @@ -12,7 +16,6 @@ ADD_DEFINITIONS(-D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
MESSAGE(STATUS "CMAKE_MODULE_PATH='${CMAKE_MODULE_PATH}'")

INCLUDE(simd)
################################################################################
# BUILD OPTIONS
################################################################################
Expand All @@ -33,13 +36,14 @@ IF((NOT CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") OR APPLE)
set(WITH_AVX OFF CACHE STRING "Disable AVX when compiling WITH_AVX=OFF." FORCE)
ENDIF()
IF(WITH_AVX)
IF (MSVC)
# https://devblogs.microsoft.com/cppblog/simd-extension-to-c-openmp-in-visual-studio/
# /Oi is for intrinsics
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX -openmp:experimental /Oi")
ELSE(MSVC)
STRING(APPEND CMAKE_CXX_FLAGS " -O3 -mavx -mfma")
ENDIF ()
INCLUDE(simd)
IF (MSVC)
# https://devblogs.microsoft.com/cppblog/simd-extension-to-c-openmp-in-visual-studio/
# /Oi is for intrinsics
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Oi")
ELSE(MSVC)
STRING(APPEND CMAKE_CXX_FLAGS " -O3 -mfma")
ENDIF ()
ENDIF()

# Debug build
Expand Down Expand Up @@ -88,13 +92,8 @@ endif()
# INCLUDES AND LIBRARIES
#######################################

# Conda
#######################################
FIND_PACKAGE(Conda)

## Boost
###########################
FIND_PACKAGE(CondaBoost)
IF(Boost_USE_STATIC_LIBS)
SET(Boost_USE_STATIC_LIBS ON)
ENDIF(Boost_USE_STATIC_LIBS)
Expand Down
14 changes: 6 additions & 8 deletions conda-recipe/bld.bat
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ rmdir b2 /s /q
mkdir b2
cd b2

REM Call Python with the --version flag to get the version information
for /f "tokens=2 delims= " %%v in ('%PYTHON% --version 2^>^&1') do set PYTHON_VERSION=%%v

REM Extract only the numeric part of the version
for /f "tokens=1-3 delims=." %%a in ("%PYTHON_VERSION%") do set PYTHON_VERSION_NUMERIC=%%a.%%b.%%c

echo Python version: %PYTHON_VERSION_NUMERIC%
cmake .. -G "NMake Makefiles" ^
-DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
Expand All @@ -24,8 +18,12 @@ cmake .. -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="%SP_DIR%" ^
-DCMAKE_SWIG_OUTDIR="%SP_DIR%" ^
-DPYTHON_VERSION="%PYTHON_VERSION_NUMERIC%" ^
-DBUILD_LIBRARY=ON
-DPython_ROOT_DIR="%PREFIX%\bin" ^
-DBUILD_LIBRARY=OFF ^
-DBUILD_PYTHON_DOCS=ON ^
-DWITH_AVX=OFF ^
-DBoost_USE_STATIC_LIBS=OFF

nmake install

:: Add wrappers to path for each Python command line tool
Expand Down
31 changes: 15 additions & 16 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ if [[ "${target_platform}" == osx-* ]]; then
CXXFLAGS="${CXXFLAGS} -D_LIBCPP_DISABLE_AVAILABILITY"
fi

cmake \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DCMAKE_PREFIX_PATH="$PREFIX" \
-DBUILD_PYTHON_INTERFACE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY="$SP_DIR" \
-DCMAKE_SWIG_OUTDIR="$SP_DIR" \
-DBUILD_LIBRARY=ON \
-DPYTHON_VERSION=$(python -c 'import platform; print(platform.python_version())')\
-G Ninja ..
cmake -S .. -B . \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_INSTALL_PREFIX="$PREFIX" \
-DBUILD_PYTHON_INTERFACE=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_LIBRARY=OFF \
-DWITH_AVX=OFF \
-DBoost_USE_STATIC_LIBS=OFF \
-DPython_ROOT_DIR="${PREFIX}/bin" \
-DBUILD_PYTHON_DOCS=ON \
-G Ninja \
${CONFIG_ARGS}

# On some platforms (notably aarch64 with Drone) builds can fail due to
# running out of memory. If this happens, try the build again; if it
# still fails, restrict to one core.
ninja install -k 0 || ninja install -k 0 || ninja install -j 1
ninja install -j ${CPU_COUNT}

# Copy programs to bin
cd $PREFIX/bin
cp $SRC_DIR/bin/* .
chmod 0755 $SRC_DIR/bin/*
cp -f $SRC_DIR/bin/* $PREFIX/bin
36 changes: 22 additions & 14 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,39 @@ source:
build:
number: 1
detect_binary_files_with_prefix: True # [not win]
run_exports: '{{ pin_subpackage("tttrlib", max_pin="x.x") }}'

requirements:
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- llvm-openmp # [osx]
- libgomp # [linux]
- pkg-config # [not win]
- pkg-config # [not win]
- cmake
- ninja
- make # [linux]
- doxygen
- swig 4.2.*
- python
- numpy
- make # [not win]
host:
- swig <4.3.0
- doxygen
- llvm-openmp # [osx]
- libgomp # [linux]
- boost-cpp
- hdf5
- python
- setuptools
- pip
- numpy
run:
- python
- {{ pin_compatible('numpy', max_pin='x.x') }}
- llvm-openmp # [osx]
- libgomp # [linux]
- boost-cpp
- hdf5
- tqdm
- numpy
- click
- click-didyoumean
- scikit-image
- matplotlib-base
- hdf5

test:
imports:
Expand All @@ -52,11 +53,18 @@ test:

about:
home: https://github.com/fluorescence-tools/tttrlib
summary: 'A file format agnostic library for time-resolved imaging and spectroscopic data.'
description: |
tttrlib is a simple, fast, libray to read, write and process
time-resolved imaging and spectroscopic data. For speed, it
is written in C++ and wrapped for Python via SWIG.
license: BSD-3-Clause
summary: |
{{ data.get('description') }}
license_family: BSD
license_file: LICENSE.txt
doc_url: https://tttrlib.readthedocs.io
dev_url: https://github.com/fluorescence-tools/tttrlib

extra:
recipe-maintainers:
- tpeulen
- khemmen
- khemmen
2 changes: 1 addition & 1 deletion ext/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IF(BUILD_PYTHON_INTERFACE)
MESSAGE(STATUS "Python version: '${PYTHON_VERSION}'")
cmake_policy(SET CMP0094 NEW)

FIND_PACKAGE(Python ${PYTHON_VERSION} EXACT COMPONENTS Interpreter Development.Module NumPy)
FIND_PACKAGE(Python COMPONENTS Interpreter Development.Module NumPy)
INCLUDE_DIRECTORIES(BEFORE ${Python_NumPy_PATH} ${Python_INCLUDE_DIRS})
LINK_LIBRARIES(${Python_LIBRARY} Python::NumPy)

Expand Down

0 comments on commit e763cee

Please sign in to comment.