Skip to content

Commit

Permalink
Add build flavor option (all/tiny/nano).
Browse files Browse the repository at this point in the history
  • Loading branch information
ningfei committed Jul 26, 2024
1 parent ac39422 commit a8cf4ad
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 22 deletions.
16 changes: 8 additions & 8 deletions SuperBuild/SuperBuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@ endif()
option(FSLSTYLE "FSL behavior, pigz support" ON)
if(FSLSTYLE)
ADD_DEFINITIONS(-DFSLSTYLE)
ADD_DEFINITIONS(-DREJECT_COMPLEX)
ADD_DEFINITIONS(-DPIGZ)
ADD_DEFINITIONS(-DREJECT_COMPLEX)
endif()

ADD_DEFINITIONS(-DHAVE_64BITS)
ADD_DEFINITIONS(-DHAVE_BUTTERWORTH)
ADD_DEFINITIONS(-DHAVE_FORMATS)
ADD_DEFINITIONS(-DHAVE_TENSOR)
ADD_DEFINITIONS(-DHAVE_ZLIB)
ADD_DEFINITIONS(-DNII2MESH)
if(NOT BUILD_FLAVOR)
set(BUILD_FLAVOR "all" CACHE STRING
"Choose the flavor of build, options are: all tiny nano." FORCE)
set_property(CACHE BUILD_FLAVOR PROPERTY STRINGS "all;tiny;nano")
endif()

# Basic CMake build settings
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel")
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

Expand Down Expand Up @@ -74,6 +73,7 @@ ExternalProject_Add(src
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DCMAKE_VERBOSE_MAKEFILE:BOOL=${CMAKE_VERBOSE_MAKEFILE}
-DBUILD_FLAVOR:STRING=${BUILD_FLAVOR}
-DOPENMP_XCODE:BOOL=${OPENMP_XCODE}
-DUSE_STATIC_RUNTIME:BOOL=${USE_STATIC_RUNTIME}
-DZLIB_IMPLEMENTATION:STRING=${ZLIB_IMPLEMENTATION}
Expand Down
54 changes: 40 additions & 14 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,54 @@ endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug;Release;RelWithDebInfo;MinSizeRel")
endif()

#emulate fslmaths behavior, add pigz support
option(FSLSTYLE "FSL behavior, pigz support" ON)
if(FSLSTYLE)
ADD_DEFINITIONS(-DFSLSTYLE)
ADD_DEFINITIONS(-DREJECT_COMPLEX)
ADD_DEFINITIONS(-DPIGZ)
ADD_DEFINITIONS(-DREJECT_COMPLEX)
endif()

if(NOT BUILD_FLAVOR)
set(BUILD_FLAVOR "all" CACHE STRING
"Choose the flavor of build, options are: all tiny nano." FORCE)
set_property(CACHE BUILD_FLAVOR PROPERTY STRINGS "all;tiny;nano")
endif()

# Add NII2MESH support
ADD_DEFINITIONS(-DNII2MESH)
if(${BUILD_FLAVOR} STREQUAL "all")
ADD_DEFINITIONS(-DHAVE_64BITS)
set(ADDITIONAL_SRCS core64.c)
ADD_DEFINITIONS(-DHAVE_BUTTERWORTH)
set(ADDITIONAL_SRCS ${ADDITIONAL_SRCS} bw.c)
ADD_DEFINITIONS(-DHAVE_FORMATS)
set(ADDITIONAL_SRCS ${ADDITIONAL_SRCS} base64.c)
ADD_DEFINITIONS(-DHAVE_TENSOR)
set(ADDITIONAL_SRCS ${ADDITIONAL_SRCS} tensor.c)
ADD_DEFINITIONS(-DNII2MESH)
set(ADDITIONAL_SRCS ${ADDITIONAL_SRCS} bwlabel.c fdr.c meshify.c quadric.c radixsort.c)

option(USE_CLASSIC_CUBES "Use classic or marching cubes" ON)
if(USE_CLASSIC_CUBES)
ADD_DEFINITIONS(-DUSE_CLASSIC_CUBES)
set(ADDITIONAL_SRCS ${ADDITIONAL_SRCS} oldcubes.c)
else()
set(ADDITIONAL_SRCS ${ADDITIONAL_SRCS} MarchingCubes.c)
endif()
elseif(${BUILD_FLAVOR} STREQUAL "tiny")
ADD_DEFINITIONS(-DNII2MESH)
set(ADDITIONAL_SRCS bwlabel.c fdr.c meshify.c oldcubes.c quadric.c radixsort.c)

option(USE_CLASSIC_CUBES "Use classic or marching cubes" ON)
if(USE_CLASSIC_CUBES)
ADD_DEFINITIONS(-DUSE_CLASSIC_CUBES)
set(ADDITIONAL_SRCS ${ADDITIONAL_SRCS} oldcubes.c)
else()
set(ADDITIONAL_SRCS ${ADDITIONAL_SRCS} MarchingCubes.c)
endif()
endif()

if(${CMAKE_C_COMPILER_ID} STREQUAL "AppleClang")
#e.g. cmake -DOPENMP_XCODE=ON ..
Expand Down Expand Up @@ -81,19 +116,10 @@ set(PROGRAMS niimath)
set(NIIMATH_SRCS
niimath.c
core.c
tensor.c
bwlabel.c
bw.c
core32.c
core64.c
fdr.c
niftilib/nifti2_io.c
znzlib/znzlib.c
meshify.c
MarchingCubes.c
quadric.c
base64.c
radixsort.c
${ADDITIONAL_SRCS}
)

include_directories(niftilib)
Expand Down
4 changes: 4 additions & 0 deletions src/niimath.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,13 @@ int main(int argc, char * argv[]) {
}
}
if( argc < 3 ) return show_help(); //minimal command has input and output: "niimath in.nii out.nii"

#ifdef NII2MESH
if (isMz3(argv[1])) {
return mainMz3(argc, argv);
}
#endif

int dtCalc = DT_FLOAT32; //data type for calculation
int ac = 1;
if( ! strcmp(argv[ac], "-dt") ) {
Expand Down

0 comments on commit a8cf4ad

Please sign in to comment.