Skip to content

Commit 2c02bac

Browse files
authored
Merge pull request #307 from allywarner/Seg3DLib_build_script
Seg3dlib build script
2 parents 6f1cfe2 + bc4a45a commit 2c02bac

17 files changed

Lines changed: 479 additions & 63 deletions

File tree

Superbuild/Superbuild.cmake

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,25 @@ ENDIF()
105105

106106
OPTION(BUILD_WITH_PYTHON "Build with python support." ON)
107107

108-
109108
###########################################
109+
# Configure Seg3D library build
110+
###########################################
111+
112+
IF((WIN32) AND (MSVC_VERSION GREATER 1900))
113+
114+
OPTION(BUILD_STANDALONE_LIBRARY "Build with a Seg3D library build." OFF)
115+
116+
IF(BUILD_STANDALONE_LIBRARY)
117+
SET(BUILD_TESTING OFF)
118+
SET(BUILD_WITH_PYTHON OFF)
119+
SET(SUPERBUILD_LIBS_SOURCE_DIR ${CMAKE_BINARY_DIR})
120+
ENDIF()
121+
122+
ENDIF()
123+
124+
OPTION(BUILD_MANUAL_TOOLS_ONLY "Build Seg3D library with only manual tools." OFF)
125+
126+
###########################################ß
110127
# Travis CI build needs to be as slim as possible
111128
###########################################
112129

@@ -126,7 +143,6 @@ ELSE()
126143
SET(ENABLED_WARNINGS "-Wall")
127144
ENDIF()
128145

129-
130146
###########################################
131147
# Configure Qt
132148
###########################################
@@ -165,14 +181,12 @@ IF(SEG3D_BUILD_INTERFACE)
165181

166182
ENDIF()
167183

168-
169184
###########################################
170185
# Configure sample data download
171186
###########################################
172187

173188
OPTION(DOWNLOAD_DATA "Download Seg3D sample and test data repository." ON)
174189

175-
176190
###########################################
177191
# *Nix C++ compiler flags
178192
###########################################
@@ -288,7 +302,10 @@ SET(SEG3D_CACHE_ARGS
288302
"-DSEG3D_BUILD_INTERFACE:BOOL=${SEG3D_BUILD_INTERFACE}"
289303
"-DSEG3D_SHOW_CONSOLE:BOOL=${SEG3D_SHOW_CONSOLE}"
290304
"-DBUILD_WITH_PYTHON:BOOL=${BUILD_WITH_PYTHON}"
305+
"-DBUILD_STANDALONE_LIBRARY:BOOL=${BUILD_STANDALONE_LIBRARY}"
306+
"-DSEG3D_MANUAL_TOOLS_ONLY:BOOL=${SEG3D_MANUAL_TOOLS_ONLY}"
291307
"-DDO_ZLIB_MANGLE:BOOL=${DO_ZLIB_MANGLE}"
308+
"-DSUPERBUILD_LIBS_SOURCE_DIR:PATH=${SUPERBUILD_LIBS_SOURCE_DIR}"
292309
"-DZlib_DIR:PATH=${Zlib_DIR}"
293310
"-DLibPNG_DIR:PATH=${LibPNG_DIR}"
294311
"-DSQLite_DIR:PATH=${SQLite_DIR}"

src/Application/Tool/ToolFactory.cc

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,32 +95,50 @@ ToolFactory::~ToolFactory()
9595
{
9696
}
9797

98-
void ToolFactory::register_tool( ToolBuilderBase* builder, ToolInfoHandle info,
99-
std::string tool_name )
98+
#ifdef SEG3D_MANUAL_TOOLS_ONLY
99+
static std::set<std::string> nonManualTools = { "croptool", "resampletool", "thresholdtool", "cannyedgedetectionfilter",
100+
"confidenceconnectedfilter", "connectedcomponentfilter", "curvatureanisotropicdiffusionfilter",
101+
"discretegaussianfilter", "distancefilter", "extractdatalayer", "gradientanisotropicdiffusionfilter",
102+
"gradientmagnitudefilter", "histogramequalizationfilter", "intensitycorrectionfilter",
103+
"maskdatafilter", "medianfilter", "meanfilter", "neighborhoodconnectedfilter",
104+
"otsuthresholdfilter", "thresholdsegmentationlsfilter", "transformtool", "measurementtool",
105+
"pointsetfilter", "speedlinetool", "pointsselecttool", "padtool", "implicitmodeltool", "watershedfilter" };
106+
#endif
107+
108+
void ToolFactory::register_tool(ToolBuilderBase* builder, ToolInfoHandle info,
109+
std::string tool_name)
100110
{
101-
tool_name = Core::StringToLower( tool_name );
111+
tool_name = Core::StringToLower(tool_name);
102112

103-
lock_type lock( this->get_mutex() );
113+
#ifdef SEG3D_MANUAL_TOOLS_ONLY
114+
//When building a library, we don't want to include the tools in nonManualTools
115+
if (nonManualTools.find(tool_name) != nonManualTools.end())
116+
{
117+
return;
118+
}
119+
#endif
120+
121+
lock_type lock(this->get_mutex());
104122

105123
// Test is tool was registered before.
106-
if ( this->private_->tools_.find( tool_name ) != this->private_->tools_.end() )
124+
if (this->private_->tools_.find(tool_name) != this->private_->tools_.end())
107125
{
108126
// Actions that are registered twice, will cause problems
109127
// Hence the program will throw an exception.
110128
// As registration is done on startup, this will cause a
111129
// faulty program to fail always on startup.
112-
CORE_THROW_LOGICERROR( std::string( "Tool '" ) + tool_name + "' is registered twice" );
130+
CORE_THROW_LOGICERROR(std::string("Tool '") + tool_name + "' is registered twice");
113131
}
114132

115133
// Register the action and set its properties
116134
ToolEntry entry;
117135
entry.builder_ = builder;
118136
entry.info_ = info;
119-
this->private_->tools_[ tool_name ] = entry;
137+
this->private_->tools_[tool_name] = entry;
120138

121-
this->private_->tool_menus_.insert( info->get_menu() );
122-
123-
CORE_LOG_DEBUG( std::string( "Registering tool : " ) + tool_name );
139+
this->private_->tool_menus_.insert(info->get_menu());
140+
141+
CORE_LOG_DEBUG(std::string("Registering tool : ") + tool_name);
124142
}
125143

126144
void ToolFactory::register_toolinterface( ToolInterfaceBuilderBase* builder,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
SET all_libs_dest_dir=@ALL_LIBS_DEST_DIR@
2+
SET superbuild_dir=@SUPERBUILD_LIBS_SOURCE_DIR_CMD@
3+
SET zlib_file=@ZLIB_FILE@
4+
SET vs_bin_path=@_vs_bin_path@
5+
SET dependencies_dest_dir=@DEPENDENCIES_DEST_DIR@
6+
SET batch_file_path=@BATCH_FILE_PATH@
7+
SET lib_tool_path=@LIB_TOOL_PATH@
8+
9+
rmdir /S /Q %all_libs_dest_dir%
10+
mkdir %all_libs_dest_dir%
11+
12+
cd %superbuild_dir%
13+
for /r %%A IN (*.lib) DO copy %%A %all_libs_dest_dir%
14+
copy %zlib_file% %all_libs_dest_dir%
15+
del %all_libs_dest_dir%\Seg3D_lib.lib
16+
del %all_libs_dest_dir%\Seg3D_dependencies.lib
17+
del %all_libs_dest_dir%\Seg3D_lib_complete.lib
18+
19+
del %dependencies_dest_dir%\Seg3D_dependencies.lib
20+
del %dependencies_dest_dir%\Seg3D_lib_complete.lib
21+
%batch_file_path% & %lib_tool_path% /OUT:%dependencies_dest_dir%\Seg3D_dependencies.lib %all_libs_dest_dir%\*.lib & %lib_tool_path% /OUT:%dependencies_dest_dir%\Seg3D_lib_complete.lib %dependencies_dest_dir%\*.lib

src/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ ELSE()
144144
ADD_DEFINITIONS(-DSCI_32BITS)
145145
ENDIF()
146146

147+
IF(BUILD_STANDALONE_LIBRARY)
148+
MESSAGE("Library build successful")
149+
ADD_DEFINITIONS(-DBUILD_STANDALONE_LIBRARY)
150+
ENDIF()
151+
152+
IF(SEG3D_MANUAL_TOOLS_ONLY)
153+
ADD_DEFINITIONS(-DSEG3D_MANUAL_TOOLS_ONLY)
154+
ENDIF()
147155

148156
###########################################
149157
# Microsoft VC compiler flags

0 commit comments

Comments
 (0)