CMakeLists.txt 1.85 KB
Newer Older
1 2 3 4 5
## This file is somehow copy and pasted as well as edited from the original file from niftilib src-package
#PROJECT(NIFTILIB)

MESSAGE( STATUS "Inlcuded NIfTI lib building information." )

6
OPTION ( NIFTI_BUILD_SHARED_LIBS "Toggle building shared libraries for NIfTI" OFF )
7

8 9
FIND_PACKAGE( ZLIB )

10
# this now works on win if we specify the zlib directory
11
IF( ZLIB_FOUND )
12 13
	ADD_DEFINITIONS( -DHAVE_ZLIB )
	INCLUDE_DIRECTORIES( ${OPENSCENEGRAPH_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} )
14
ENDIF( ZLIB_FOUND )
15

16
SET( PACKAGE_PREFIX "OWext_" )
17
SET(ZNZLIB_SRC znzlib.c znzlib.h)
18 19
SET(NIFTI_ZNZLIB_NAME ${PACKAGE_PREFIX}znz)
ADD_LIBRARY(${NIFTI_ZNZLIB_NAME} ${ZNZLIB_SRC} )
20 21
TARGET_LINK_LIBRARIES( ${NIFTI_ZNZLIB_NAME} ${NIFTI_ZLIB_LIBRARIES} )

22
# Zlib support currently not on Visual Studio
23
IF( ZLIB_FOUND ) 
24
    TARGET_LINK_LIBRARIES(  ${NIFTI_ZNZLIB_NAME} ${ZLIB_LIBRARY} )
25
ENDIF( ZLIB_FOUND )
26

27
# Set library version when building shared libs.
28
IF( NIFTI_BUILD_SHARED_LIBS)
29 30 31 32 33 34 35 36
  SET(CPACK_PACKAGE_VERSION_MAJOR "1")
  SET(CPACK_PACKAGE_VERSION_MINOR "1")
  SET(CPACK_PACKAGE_VERSION_PATCH "0")
  SET(NIFTI_SHAREDLIB_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} )
  STRING( REGEX MATCH "^[0-9]+" NIFTI_SHAREDLIB_SOVERSION ${NIFTI_SHAREDLIB_VERSION})
  SET(NIFTI_LIBRARY_PROPERTIES VERSION ${NIFTI_SHAREDLIB_VERSION} SOVERSION ${NIFTI_SHAREDLIB_SOVERSION})
  SET_TARGET_PROPERTIES(${NIFTI_NIFTILIB_NAME} PROPERTIES ${NIFTI_LIBRARY_PROPERTIES})
  SET_TARGET_PROPERTIES(${NIFTI_ZNZLIB_NAME} PROPERTIES ${NIFTI_LIBRARY_PROPERTIES})
37
ENDIF( NIFTI_BUILD_SHARED_LIBS)
38 39


40
SET(NIFTILIB_SRC nifti1_io.c nifti1_io.h nifti1.h)
41 42 43 44 45 46 47 48
SET(NIFTI_NIFTILIB_NAME ${PACKAGE_PREFIX}niftiio)
ADD_LIBRARY(${NIFTI_NIFTILIB_NAME} ${NIFTILIB_SRC} )
TARGET_LINK_LIBRARIES( ${NIFTI_NIFTILIB_NAME} ${PACKAGE_PREFIX}znz)


IF(UNIX)
  TARGET_LINK_LIBRARIES(${NIFTI_NIFTILIB_NAME} -lm)
ENDIF(UNIX)