Commit 86a3d73e authored by Marc Modat's avatar Marc Modat

(1) The png library is forced to be alwasys static to avoid conflict with the system library

parent 4d9599e8
......@@ -9,8 +9,8 @@ endif("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" MAT
#-----------------------------------------------------------------------------
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message("In-source builds not allowed by NiftyReg police.")
message("Please make a new directory (called a build directory) and run CMake from there.")
message(FATAL_ERROR "You may need to remove CMakeCache.txt.")
message("Please create a new directory (called a build directory) and run CMake from there.")
message(FATAL_ERROR "You may need to remove CMakeCache.txt and CMakeFiles.")
endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
#-----------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE)
......
if(BUILD_INTERNAL_PNG OR BUILD_ALL_DEP)
# If the png library is not present on the machine, it is build from the sources
# Most of the following lines are extracted from the libpng1510 CMakeLists.txt
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 5)
set(PNGLIB_RELEASE 10)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
# Check if the m library is present
if(NOT WIN32)
find_library(M_LIBRARY
NAMES m
PATHS /usr/lib /usr/local/lib
)
if(NOT M_LIBRARY)
message(STATUS
"math library 'libm' not found - floating point support disabled")
endif(NOT M_LIBRARY)
else(NOT WIN32)
# the m library is not needed on windows
set(M_LIBRARY "")
endif(NOT WIN32)
# generate the config file for libpng and set the path to use it
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lpng1510/pnglibconf.h.prebuilt
${CMAKE_BINARY_DIR}/pnglibconf.h)
include_directories(${CMAKE_BINARY_DIR})
# Set the libpng sources
set(png_HDRS
lpng1510/png.h
lpng1510/pngconf.h
lpng1510/pngdebug.h
lpng1510/pnginfo.h
lpng1510/pngpriv.h
lpng1510/pngstruct.h
)
set(png_SRCS
lpng1510/png.c
lpng1510/pngerror.c
lpng1510/pngget.c
lpng1510/pngmem.c
lpng1510/pngpread.c
lpng1510/pngread.c
lpng1510/pngrio.c
lpng1510/pngrtran.c
lpng1510/pngrutil.c
lpng1510/pngset.c
lpng1510/pngtest.c
lpng1510/pngtrans.c
lpng1510/pngwio.c
lpng1510/pngwrite.c
lpng1510/pngwtran.c
lpng1510/pngwutil.c
)
# Build the library
add_library(png ${png_SRCS} ${png_HDRS})
target_link_libraries(png z)
install(TARGETS png
LIBRARY DESTINATION lib COMPONENT Development
ARCHIVE DESTINATION lib COMPONENT Development
)
install(FILES ${png_HDRS} ${CMAKE_BINARY_DIR}/pnglibconf.h DESTINATION include COMPONENT Development)
# If the png library is not present on the machine, it is build from the sources
# Most of the following lines are extracted from the libpng1510 CMakeLists.txt
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 5)
set(PNGLIB_RELEASE 10)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
# Check if the m library is present
if(NOT WIN32)
find_library(M_LIBRARY
NAMES m
PATHS /usr/lib /usr/local/lib
)
if(NOT M_LIBRARY)
message(STATUS
"math library 'libm' not found - floating point support disabled")
endif(NOT M_LIBRARY)
else(NOT WIN32)
# the m library is not needed on windows
set(M_LIBRARY "")
endif(NOT WIN32)
# generate the config file for libpng and set the path to use it
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lpng1510/pnglibconf.h.prebuilt
${CMAKE_BINARY_DIR}/pnglibconf.h)
include_directories(${CMAKE_BINARY_DIR})
# Set the libpng sources
set(png_HDRS
lpng1510/png.h
lpng1510/pngconf.h
lpng1510/pngdebug.h
lpng1510/pnginfo.h
lpng1510/pngpriv.h
lpng1510/pngstruct.h
)
set(png_SRCS
lpng1510/png.c
lpng1510/pngerror.c
lpng1510/pngget.c
lpng1510/pngmem.c
lpng1510/pngpread.c
lpng1510/pngread.c
lpng1510/pngrio.c
lpng1510/pngrtran.c
lpng1510/pngrutil.c
lpng1510/pngset.c
lpng1510/pngtest.c
lpng1510/pngtrans.c
lpng1510/pngwio.c
lpng1510/pngwrite.c
lpng1510/pngwtran.c
lpng1510/pngwutil.c
)
# Build the library
add_library(png STATIC ${png_SRCS} ${png_HDRS})
set_target_properties(png PROPERTIES
VERSION "${PNGLIB_VERSION}"
SOVERSION "${PNGLIB_MAJOR}")
target_link_libraries(png z)
install(TARGETS png
LIBRARY DESTINATION lib COMPONENT Development
ARCHIVE DESTINATION lib COMPONENT Development
)
install(FILES ${png_HDRS} ${CMAKE_BINARY_DIR}/pnglibconf.h DESTINATION include COMPONENT Development)
endif(BUILD_INTERNAL_PNG OR BUILD_ALL_DEP)
add_library(reg_png reg_png.cpp reg_png.h readpng.cpp readpng.h)
target_link_libraries(reg_png ${PNG_LIBRARY} _reg_tools reg_nifti z)
install(TARGETS reg_png
RUNTIME DESTINATION bin COMPONENT Development
LIBRARY DESTINATION lib COMPONENT Development
ARCHIVE DESTINATION lib COMPONENT Development
RUNTIME DESTINATION bin COMPONENT Development
LIBRARY DESTINATION lib COMPONENT Development
ARCHIVE DESTINATION lib COMPONENT Development
)
install(FILES reg_png.h readpng.h DESTINATION include COMPONENT Development)
......@@ -1364,12 +1364,12 @@ void reg_spline_getDeformationField3D(nifti_image *splineControlPoint,
__declspec(align(16)) DTYPE f[64];
} xyzBasis;
#else // _WIN32
union u1
union
{
__m128 m[4];
DTYPE f[16] __attribute__((aligned(16)));
} yzBasis;
union u2
union
{
__m128 m[16];
DTYPE f[64] __attribute__((aligned(16)));
......@@ -4140,7 +4140,7 @@ void compute_lie_bracket(nifti_image *img1,
{
reg_exit(1); // to update
#ifdef _WIN32
long voxelNumber=(long)img1->nx*img1->ny*img1->nz;
long voxNumber=(long)img1->nx*img1->ny*img1->nz;
#else
size_t voxNumber=(size_t)img1->nx*img1->ny*img1->nz;
#endif
......@@ -4265,7 +4265,7 @@ void compute_lie_bracket(nifti_image *img1,
#ifdef _WIN32
long i;
voxelNumber=(long)res->nvox;
voxNumber=(long)res->nvox;
#else
size_t i;
voxNumber=res->nvox;
......
......@@ -1821,10 +1821,19 @@ double reg_spline_correctFolding2D(nifti_image *splineControlPoint,
bool approximation,
bool useHeaderInformation)
{
#ifdef WIN32
long i;
long jacobianNumber;
if(approximation)
jacobianNumber = (long)(splineControlPoint->nx-2)*(splineControlPoint->ny-2);
else jacobianNumber = (long)referenceImage->nx*referenceImage->ny;
#else
size_t i;
size_t jacobianNumber;
if(approximation)
jacobianNumber = (size_t)(splineControlPoint->nx-2)*(splineControlPoint->ny-2);
else jacobianNumber = (size_t)referenceImage->nx*referenceImage->ny;
#endif
mat33 *jacobianMatrices=(mat33 *)malloc(jacobianNumber*sizeof(mat33));
DTYPE *jacobianDeterminant=(DTYPE *)malloc(jacobianNumber*sizeof(DTYPE));
......@@ -1837,7 +1846,6 @@ double reg_spline_correctFolding2D(nifti_image *splineControlPoint,
/* The current Penalty term value is computed */
double penaltyTerm =0., logDet;
size_t i;
#ifdef _OPENMP
#pragma omp parallel for default(none) \
shared(jacobianNumber, jacobianDeterminant) \
......@@ -2063,10 +2071,19 @@ double reg_spline_correctFolding3D(nifti_image *splineControlPoint,
bool approximation,
bool useHeaderInformation)
{
#ifdef WIN32
long i;
long jacobianNumber;
if(approximation)
jacobianNumber = (long)(splineControlPoint->nx-2)*(splineControlPoint->ny-2)*(splineControlPoint->nz-2);
else jacobianNumber = (long)referenceImage->nx*referenceImage->ny*referenceImage->nz;
#else
size_t i;
size_t jacobianNumber;
if(approximation)
jacobianNumber = (size_t)(splineControlPoint->nx-2)*(splineControlPoint->ny-2)*(splineControlPoint->nz-2);
else jacobianNumber = (size_t)referenceImage->nx*referenceImage->ny*referenceImage->nz;
#endif
mat33 *jacobianMatrices=(mat33 *)malloc(jacobianNumber*sizeof(mat33));
DTYPE *jacobianDeterminant=(DTYPE *)malloc(jacobianNumber*sizeof(DTYPE));
......@@ -2079,7 +2096,6 @@ double reg_spline_correctFolding3D(nifti_image *splineControlPoint,
/* The current Penalty term value is computed */
double penaltyTerm =0., logDet;
size_t i;
#ifdef _OPENMP
#pragma omp parallel for default(none) \
shared(jacobianNumber, jacobianDeterminant) \
......
......@@ -1038,7 +1038,7 @@ void reg_tools_kernelConvolution_core(nifti_image *image,
bool *timePoint,
bool *axis)
{
#ifdef WIN23
#ifdef WIN32
long index;
long voxelNumber = (long)image->nx*image->ny*image->nz;
#else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment