From 514a10a8adf935f9254b9c25da200b4317277171 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca Date: Fri, 19 Jan 2018 18:34:40 +0000 Subject: Working conda recipe for Windows --- Core/CMakeLists.txt | 85 ++++++++++++++++++++++++--- Core/recipe/bld.bat | 12 ---- Core/recipe/build.sh | 17 ------ Core/recipe/meta.yaml | 36 ------------ Core/regularizers_CPU/PatchBased_Regul_core.c | 9 ++- recipes/regularizers/bld.bat | 21 +++++++ recipes/regularizers/build.sh | 17 ++++++ recipes/regularizers/meta.yaml | 40 +++++++++++++ 8 files changed, 161 insertions(+), 76 deletions(-) delete mode 100644 Core/recipe/bld.bat delete mode 100644 Core/recipe/build.sh delete mode 100644 Core/recipe/meta.yaml create mode 100644 recipes/regularizers/bld.bat create mode 100644 recipes/regularizers/build.sh create mode 100644 recipes/regularizers/meta.yaml diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 146b6a0..67505dd 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -1,15 +1,71 @@ -# Copyright 2017 Edoardo Pasca +# Copyright 2018 Edoardo Pasca cmake_minimum_required (VERSION 3.0) -project(regularizers) +project(RegularizerLibrary) +#https://stackoverflow.com/questions/13298504/using-cmake-with-setup-py +# The version number. + +set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE) + +# conda orchestrated build +message("CIL_VERSION ${CIL_VERSION}") + +find_package(PythonInterp REQUIRED) +if (PYTHONINTERP_FOUND) + message ("Current Python " ${PYTHON_VERSION_STRING} " found " ${PYTHON_EXECUTABLE}) + if (PYTHON_VERSION_MAJOR EQUAL "3") + set (BOOST_PYTHON "python3") + set (BOOST_NUMPY "numpy3") + else() + set (BOOST_PYTHON "python") + set (BOOST_NUMPY "numpy") + endif() +endif() + +find_package(Boost REQUIRED + COMPONENTS ${BOOST_PYTHON} ${BOOST_NUMPY}) + +if (Boost_FOUND) + message("Boost version " ${Boost_VERSION}) + message("Boost include dir " ${Boost_INCLUDE_DIRS}) + message("Boost library dir " ${Boost_LIBRARY_DIRS}) + message("Boost libraries " ${Boost_LIBRARIES}) +endif() + +## Build the regularizers package as a library +message("Creating Iterative Reconstruction CGLS as shared library") +message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}") + +set(CMAKE_BUILD_TYPE "Release") + +if(WIN32) + set (FLAGS "/DWIN32 /EHsc /DBOOST_ALL_NO_LIB /openmp /DCCPiReconstructionIterative_EXPORTS") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:MSVCRT.lib") + + set (EXTRA_LIBRARIES + ${Boost_LIBRARIES} + #"tiff" + ) + + message("library lib: ${LIBRARY_LIB}") + +elseif(UNIX) + set (FLAGS "-fopenmp -O2 -funsigned-char -Wall -Wl,--no-undefined -DCCPiReconstructionIterative_EXPORTS -std=c++0x") + set (EXTRA_LIBRARIES + ${Boost_LIBRARIES} + #"tiff" + "gomp" + ) + +endif() ## Build the regularizers package as a library message("Adding regularizers as shared library") -set(CMAKE_C_FLAGS "-fopenmp -O2 -funsigned-char -Wall -std=c++0x") + #set(CMAKE_C_COMPILER /apps/pgi/linux86-64/17.4/bin/pgcc) #set(CMAKE_C_FLAGS "-acc -Minfo -ta=tesla:cc20 -openmp") #set(CMAKE_C_FLAGS "-acc -Minfo -ta=multicore -openmp -fPIC") -add_library(regularizers_lib SHARED +add_library(cilreg SHARED ${CMAKE_CURRENT_SOURCE_DIR}/regularizers_CPU/FGP_TV_core.c ${CMAKE_CURRENT_SOURCE_DIR}/regularizers_CPU/LLT_model_core.c ${CMAKE_CURRENT_SOURCE_DIR}/regularizers_CPU/PatchBased_Regul_core.c @@ -17,9 +73,22 @@ add_library(regularizers_lib SHARED ${CMAKE_CURRENT_SOURCE_DIR}/regularizers_CPU/TGV_PD_core.c ${CMAKE_CURRENT_SOURCE_DIR}/regularizers_CPU/utils.c ) -#GENERATE_EXPORT_HEADER(regularizers_lib) -install (TARGETS regularizers_lib DESTINATION $ENV{PREFIX}/lib) -add_executable(regularizer_test ${CMAKE_CURRENT_SOURCE_DIR}/test/test_regularizer.cpp) +if (UNIX) +message ("I'd install into ${CMAKE_INSTALL_PREFIX}/lib") +install(TARGETS cilreg + LIBRARY DESTINATION lib + CONFIGURATIONS ${CMAKE_BUILD_TYPE} + ) +elseif(WIN32) +message ("I'd install into ${CMAKE_INSTALL_PREFIX} lib bin") + install(TARGETS cilreg + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + CONFIGURATIONS ${CMAKE_BUILD_TYPE} + ) +endif() + +#add_executable(regularizer_test ${CMAKE_CURRENT_SOURCE_DIR}/test/test_regularizer.cpp) -target_link_libraries (regularizer_test LINK_PUBLIC regularizers_lib) \ No newline at end of file +#target_link_libraries (regularizer_test LINK_PUBLIC regularizers_lib) \ No newline at end of file diff --git a/Core/recipe/bld.bat b/Core/recipe/bld.bat deleted file mode 100644 index 1b97893..0000000 --- a/Core/recipe/bld.bat +++ /dev/null @@ -1,12 +0,0 @@ -IF NOT DEFINED CIL_VERSION ( -ECHO CIL_VERSION Not Defined. -exit 1 -) - -mkdir "%SRC_DIR%\build" - -cd %SRC_DIR%\build - -BUILD_CONFIG=Release - -cmake .. -Wno-dev -DCMAKE_BUILD_TYPE=$BUILD_CONFIG -DCMAKE_PREFIX_PATH:PATH="${PREFIX}" -DCMAKE_INSTALL_PREFIX:PATH="${PREFIX}" -DCMAKE_INSTALL_RPATH:PATH="${PREFIX}/lib" diff --git a/Core/recipe/build.sh b/Core/recipe/build.sh deleted file mode 100644 index ab5474b..0000000 --- a/Core/recipe/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env bash - -mkdir build -cd build - -#configure -BUILD_CONFIG=Release -echo `pwd` -cmake .. -G "Ninja" \ - -Wno-dev \ - -DCMAKE_BUILD_TYPE=$BUILD_CONFIG \ - -DCMAKE_PREFIX_PATH:PATH="${PREFIX}" \ - -DCMAKE_INSTALL_PREFIX:PATH="${PREFIX}" \ - -DCMAKE_INSTALL_RPATH:PATH="${PREFIX}/lib" - -# compile & install -ninja install diff --git a/Core/recipe/meta.yaml b/Core/recipe/meta.yaml deleted file mode 100644 index fbce22b..0000000 --- a/Core/recipe/meta.yaml +++ /dev/null @@ -1,36 +0,0 @@ -package: - name: cil_regularizer - version: {{ environ['CIL_VERSION'] }} - -source: - path: ../ - -build: - preserve_egg_dir: False - script_env: - - CIL_VERSION - -requirements: - build: - - boost == 1.64.0 - - boost-cpp == 1.64.0 -# - toolchain - - python 3.5 - - cmake >=3.1 -# - zlib 1.2.11 - - vc 14 # [win and py35] - - libtiff - - numpy - - run: - - boost ==1.64.0 - - libtiff - - vc 14 # [win and py35] - - python 3.5 - - numpy - - -about: - home: http://www.ccpi.ac.uk - license: Apache v2.0 - summary: Regularizer package from CCPi diff --git a/Core/regularizers_CPU/PatchBased_Regul_core.c b/Core/regularizers_CPU/PatchBased_Regul_core.c index fe88ffb..5ceb5e2 100644 --- a/Core/regularizers_CPU/PatchBased_Regul_core.c +++ b/Core/regularizers_CPU/PatchBased_Regul_core.c @@ -51,9 +51,12 @@ float PB_FUNC2D(float *Ap, float *Bp, int dimX, int dimY, int padXY, int SearchW int i, j, i_n, j_n, i_m, j_m, i_p, j_p, i_l, j_l, i1, j1, i2, j2, i3, j3, i5,j5, count, SimilW_full; float *Eucl_Vec, h2, denh2, normsum, Weight, Weight_norm, value, denom, WeightGlob, t1; - float A[dimX*dimY], B[dimX*dimY]; - - //fill the structures + //float A[dimX*dimY], B[dimX*dimY]; + float *A , *B; + A = (float*) calloc (dimX*dimY,sizeof(float)); + B = (float*) calloc (dimX*dimY,sizeof(float)); + + //fill the structures int index=0; for (i=0;i=3.1 +# - zlib 1.2.11 + - vc 14 # [win and py35] + - vc 9 # [win and py27] +# - libtiff + - numpy + + run: + - boost ==1.64.0 +# - libtiff + - vc 14 # [win and py35] + - vc 9 # [win and py27] + - python 3.5 # [py35] + - python 2.7 # [py27] + - numpy + + +about: + home: http://www.ccpi.ac.uk + license: Apache v2.0 + summary: Regularizer package from CCPi -- cgit v1.2.3