diff options
author | Edoardo Pasca <edo.paskino@gmail.com> | 2018-01-19 18:34:40 +0000 |
---|---|---|
committer | Edoardo Pasca <edo.paskino@gmail.com> | 2018-01-23 22:45:21 +0000 |
commit | 514a10a8adf935f9254b9c25da200b4317277171 (patch) | |
tree | e888c3c58e0032cb589935eef1aab3ab72bfca2c | |
parent | 113762f1086a5e202f81b35e624da3d28402d70e (diff) | |
download | regularization-514a10a8adf935f9254b9c25da200b4317277171.tar.gz regularization-514a10a8adf935f9254b9c25da200b4317277171.tar.bz2 regularization-514a10a8adf935f9254b9c25da200b4317277171.tar.xz regularization-514a10a8adf935f9254b9c25da200b4317277171.zip |
Working conda recipe for Windows
-rw-r--r-- | Core/CMakeLists.txt | 85 | ||||
-rw-r--r-- | Core/recipe/bld.bat | 12 | ||||
-rw-r--r-- | Core/regularizers_CPU/PatchBased_Regul_core.c | 9 | ||||
-rw-r--r-- | recipes/regularizers/bld.bat | 21 | ||||
-rw-r--r-- | recipes/regularizers/build.sh (renamed from Core/recipe/build.sh) | 0 | ||||
-rw-r--r-- | recipes/regularizers/meta.yaml (renamed from Core/recipe/meta.yaml) | 20 |
6 files changed, 116 insertions, 31 deletions
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/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<dimX;i++){ for (j=0;j<dimY;j++){ diff --git a/recipes/regularizers/bld.bat b/recipes/regularizers/bld.bat new file mode 100644 index 0000000..6f2f7e7 --- /dev/null +++ b/recipes/regularizers/bld.bat @@ -0,0 +1,21 @@ +IF NOT DEFINED CIL_VERSION ( +ECHO CIL_VERSION Not Defined. +exit 1 +) + +mkdir "%SRC_DIR%\build" +ROBOCOPY /E "%RECIPE_DIR%\..\..\Core" "%SRC_DIR%\build" +::ROBOCOPY /E "%RECIPE_DIR%\..\..\Wrappers\python\src" "%SRC_DIR%\build\module" +cd "%SRC_DIR%\build" + +echo "we should be in %SRC_DIR%\build" + +cmake -G "NMake Makefiles" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library" "%SRC_DIR%\build" + +::-DBOOST_LIBRARYDIR="%CONDA_PREFIX%\Library\lib" -DBOOST_INCLUDEDIR="%CONDA_PREFIX%\Library\include" -DBOOST_ROOT="%CONDA_PREFIX%\Library\lib" + +:: Build C library +nmake install +if errorlevel 1 exit 1 + +:: Install step diff --git a/Core/recipe/build.sh b/recipes/regularizers/build.sh index ab5474b..ab5474b 100644 --- a/Core/recipe/build.sh +++ b/recipes/regularizers/build.sh diff --git a/Core/recipe/meta.yaml b/recipes/regularizers/meta.yaml index fbce22b..37e447e 100644 --- a/Core/recipe/meta.yaml +++ b/recipes/regularizers/meta.yaml @@ -2,8 +2,8 @@ package: name: cil_regularizer version: {{ environ['CIL_VERSION'] }} -source: - path: ../ +#source: + # path: ../ build: preserve_egg_dir: False @@ -12,21 +12,25 @@ build: requirements: build: - - boost == 1.64.0 - - boost-cpp == 1.64.0 + - boost ==1.64.0 + - boost-cpp ==1.64.0 # - toolchain - - python 3.5 + - python 3.5 # [py35] + - python 2.7 # [py27] - cmake >=3.1 # - zlib 1.2.11 - vc 14 # [win and py35] - - libtiff + - vc 9 # [win and py27] +# - libtiff - numpy run: - boost ==1.64.0 - - libtiff +# - libtiff - vc 14 # [win and py35] - - python 3.5 + - vc 9 # [win and py27] + - python 3.5 # [py35] + - python 2.7 # [py27] - numpy |