GithubHelp home page GithubHelp logo

slicer / slicerexecutionmodel Goto Github PK

View Code? Open in Web Editor NEW
32.0 23.0 50.0 824 KB

An open-source CMake-based project that provides macros and associated tools for the easy building of 3D Slicer command line interface (CLI) modules.

Home Page: https://www.slicer.org/wiki/Documentation/Nightly/Developers/SlicerExecutionModel

License: Other

CMake 11.75% C++ 72.23% Shell 5.28% HTML 7.95% CSS 0.23% Perl 0.04% Makefile 1.04% M4 0.66% Dockerfile 0.22% Python 0.61%
3d-slicer command-line-parser c-plus-plus cross-platform medical-imaging kitware

slicerexecutionmodel's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

slicerexecutionmodel's Issues

paramType in schema improperly described

Looking at the schema allowing to validated the XML description, I noticed that the paramType is specified as a xsd:choice of name, flag, longflag, ... which is probably incorrect.

For example, I believe name is mandatory, at least flag or longflag should be specified, ...

See https://github.com/Slicer/SlicerExecutionModel/blob/master/ModuleDescriptionParser/ModuleDescription.xsd#L52

For reference, what motivated the creation of this issue if what's discussed here: http://www.na-mic.org/Bug/view.php?id=1828

Relax ITK version requirement

Is ITK v4.5 really required? I was able build against ITK v4.3.1 (using all default build options) and things seem to still work fine (100% tests passed)

Define C++ pre-processor code via SEMMacroBuildCLI

Sometimes it is useful to pass CMake variables into C++ code. The way to do it is to use the CMake configure_file() macro. It takes a *.h.in as input and generate a .h file.
SEMMacroBuildCLI already generate a *CLP.h file. It would be great if we could define pre-processor variables by passing a simple SEMMacroBuildCLI parameter. For example:
in cmake:

SEMMacroBuildCLI( MyCLI PREPROCESSOR MY_CMAKE_VARIABLE ...)

If MY_CMAKE_VARIABLE is True, that would generate in the CLP.h file:
#define MY_CMAKE_VARIABLE
which could then be used in the MyCLI.cxx file:

int main(int argc, char* argv[])
{
  PARSE_ARGS
#ifdefined MY_CMAKE_VARIABLE
  // do something here
#endif
  ...
}

`longflag` is required, `name` is optional

I ran into this problem before, and now again: longflag is required, name is optional. This is counterintuitive.

Consider the following CLI XML specification:

<?xml version="1.0" encoding="UTF-8"?>
<executable>
  <category>IGT</category>
  <title>crashExample</title>
  <description><![CDATA[This is a CLI module for ...]]></description>
  <version>0.0.1</version>
  <contributor>Dženan Zukić (Kitware Inc.)</contributor>
  <acknowledgements>This work was funded by ...</acknowledgements>
  <parameters>
    <label>IO</label>
    <description><![CDATA[Input/output parameters]]></description>
    <image>
      <name>inputImage</name>
      <label>Input Image</label>
      <channel>input</channel>
      <flag>i</flag>
      <description><![CDATA[The input image]]></description>
    </image>
    <image>
      <name>outputImage</name>
      <label>Output Image</label>
      <channel>output</channel>
      <flag>o</flag>
      <description><![CDATA[The output image]]></description>
    </image>
  </parameters>
</executable>

PARSE_ARGS; crashes here with the following exception message: -o <std::string>, -- <std::string> -- Argument with same flag/name already exists!. That is because a->name is an empty string, and matches the the argument -i which also has empty string as a name.

If the name tags are replaced by longflags, the problem goes away:

<?xml version="1.0" encoding="UTF-8"?>
<executable>
  <category>IGT</category>
  <title>crashExample</title>
  <description><![CDATA[This is a CLI module for ...]]></description>
  <version>0.0.1</version>
  <contributor>Dženan Zukić (Kitware Inc.)</contributor>
  <acknowledgements>This work was funded by ...</acknowledgements>
  <parameters>
    <label>IO</label>
    <description><![CDATA[Input/output parameters]]></description>
    <image>
      <longflag>inputImage</longflag>
      <label>Input Image</label>
      <channel>input</channel>
      <flag>i</flag>
      <description><![CDATA[The input image]]></description>
    </image>
    <image>
      <longflag>outputImage</longflag>
      <label>Output Image</label>
      <channel>output</channel>
      <flag>o</flag>
      <description><![CDATA[The output image]]></description>
    </image>
  </parameters>
</executable>

Longflag should support dash ('-') chars

command line applications typically have dashes in the names of their long flags.
It should be possible to have parameters such as:
--no-something
--use-something
...

OUTPUT_DIRECTORY variables cannot be changed

SlicerExecutionModel_DEFAULT_CLI___OUTPUT_DIRECTORY and SlicerExecutionModel_DEFAULT_CLI_INSTALL___DESTINATION variables' default value is used when using SEMMacroBuildCLI.cmake because of find_package(SlicerExecutionModel REQUIRED GenerateCLP) (line 100). One solution is to set those varialbes as CACHE variables when setting their default value in SlicerExecutionModelConfig.cmake.

Add support for CMake function target_compile_features

When compiling a target that has specific C++ requirements, one can use the new CMake function target_compile_features() [1].

There is currently no way of passing these requirements to SEMMacroBuildCLI, and the targets created in the macro are not exposed to the user.
It would be great to either be able:

  1. to pass the requirements to the CMake macro or
  2. to expose the list of targets created by the macro.

Note: Both solutions are not mutually exclusive and even if 1) is implemented, 2) might still be useful in certain corner cases.

[1] https://cmake.org/cmake/help/v3.6/command/target_compile_features.html

Only installs one shared library

Only one file is installed: lib/ModuleDescriptionParser/libModuleDescriptionParser.so
Is this what's intended?

The description says: project that provides macros and associated tools.

find_package() perform in SEMMacroBuildCLI and ITK_LIBRARIES issues

When using the SEMMacroBuildCLI, the macro perfoms a find_package() step:
https://github.com/Slicer/SlicerExecutionModel/blob/master/CMake/SEMMacroBuildCLI.cmake#L103
This step leads to another find_package() step in UseGenerateCLP.cmake:
https://github.com/Slicer/SlicerExecutionModel/blob/master/GenerateCLP/UseGenerateCLP.cmake.in#L20
In this last step, the CMake variable ITK_LIBRARIES is reset.
This reset could lead to link errors, mostly related to the IO factory mechanism if the ITK_LIBRARIES is used again after calling the SEMMacroBuildCLI, i.e. if one calls the macro multiple times to compile multiple CLIs in the same CMakeLists.txt file.
When trying to compile the example available here (branch ITKLinkError):
https://github.com/fbudin69500/3D4DImageConversion/blob/ITKLinkError/CMakeLists.txt
It results in linking error messages:
Linking CXX executable bin/4DTo3DImages
lib/lib4DTo3DImagesLib.a(4DTo3DImages.cxx.o):(.data+0x3a0): undefined reference to itk::NiftiImageIOFactoryRegister__Private()' lib/lib4DTo3DImagesLib.a(4DTo3DImages.cxx.o):(.data+0x3a8): undefined reference toitk::NrrdImageIOFactoryRegister__Private()'
lib/lib4DTo3DImagesLib.a(4DTo3DImages.cxx.o):(.data+0x3b0): undefined reference to `itk::MetaImageIOFactoryRegister__Private()'

One easy solution for the user is to save the value of the ITK_LIBRARIES in a different variable. However, this should be done directly in SEMMacroBuild.

This issue is partly related to:
#8

Add ITK/VTK plugin watcher utility classes

In order for CLI to report progress, the following output is the standard:

<filter-start>
 <filter-name>...</filter-name>
 ...
</filter-start>
<filter-progress>
...

There is in Slicer (Base/CLI) some utility classes that observe ITK and VTK filters to automatically generate such output.
Such classes should be moved in SlicerExecutionModel as conveniency (and be enabled only if ITK_DIR or VTK_DIR are passed).
A generic progress watcher (whose itkPluginFilterWatcher and vtkPluginFilterWatcher should derive from) should also be added.

class SEMProgressWatcher
{
public:
  SEMProgressWatcher(const char* name, const char* comment = 0, ModuleProcessInformation* inf = 0, double fraction = 1.0, double start = 0.0);
  virtual void Start();
  virtual void SetProgress(double progress);
  virtual void End();
  virtual double GetProgress();
protected:
  void ReportStart();
  void ReportEnd();
  void ReportProgress();
};
class itkPluginFilterWatcher: public itkSimpleFilterWatcher, SEMProgressWatcher
{
...
};
class vtkPluginFilterWatcher: public SEMProgressWatcher
{
...
};

SEM add_compiler_export_flags should be removed

loading initial cache file /Shared/johnsonhj/Binaries/Darwin/BT-11/SlicerExecutionModel-prefix/tmp/SlicerExecutionModel-cache-Release.cmake
CMake Deprecation Warning at /usr/local/Cellar/cmake/3.10.1/share/cmake/Modules/GenerateExportHeader.cmake:382 (message):
  The add_compiler_export_flags function is obsolete.  Use the
  CXX_VISIBILITY_PRESET and VISIBILITY_INLINES_HIDDEN target properties
  instead.
Call Stack (most recent call first):
  ModuleDescriptionParser/CMakeLists.txt:154 (add_compiler_export_flags)

find_package(ITK 4.5 COMPONENT) corrupted by SEM

The CMakeLists.txt file below is a simple example that demonstrates that including SEM before ITK causes find_package(ITK COMPONENTS ) to be corrupted.

SlicerExecutionModel hash 865e2a7 does not seem to exhibit this behavior.

cmake_minimum_required(VERSION 3.0)
project(test)

set(ITK_IO_MODULES_USED "")
set(ITK_MODULES_USED
ITKAnisotropicSmoothing
ITKBinaryMathematicalMorphology
ITKCommon
ITKConnectedComponents
ITKCurvatureFlow
ITKDeprecated
ITKDiffusionTensorImage
ITKDisplacementField
ITKDistanceMap
ITKFFT
ITKFastMarching
ITKHDF5
ITKIOBMP
ITKIOBioRad
ITKIODCMTK
ITKIOGDCM
ITKIOGE
ITKIOGIPL
ITKIOImageBase
ITKIOJPEG
ITKIOLSM
ITKIOMeta
ITKIONIFTI
ITKIONRRD
ITKIOPNG
ITKIORAW
MGHIO
ITKIOSpatialObjects
ITKIOStimulate
ITKIOTIFF
ITKIOTransformBase
ITKIOXML
ITKImageAdaptors
ITKImageCompare
ITKImageCompose
ITKImageFeature
ITKImageFilterBase
ITKImageFunction
ITKImageFusion
ITKImageGradient
ITKImageGrid
ITKImageIntensity
ITKImageSources
ITKImageStatistics
ITKLabelMap
ITKLabelVoting
ITKLevelSets
ITKMathematicalMorphology
ITKMesh
ITKMetricsv4
ITKOptimizers
ITKOptimizersv4
ITKPDEDeformableRegistration
ITKQuadEdgeMesh
ITKQuadEdgeMeshFiltering
ITKRegionGrowing
ITKRegistrationCommon
ITKRegistrationMethodsv4
ITKReview
ITKSmoothing
ITKSpatialObjects
ITKStatistics
ITKTestKernel
ITKThresholding
ITKTransform
ITKV3Compatibility
${ITK_VTK_COMPONENTS}
${ITK_IO_MODULES_USED}
)

option(SEMFIRST "Include SEM First" ON)

if(SEMFIRST)

THIS FAILS

find_package(SlicerExecutionModel REQUIRED GenerateCLP)
include(${GenerateCLP_USE_FILE})
include(${SlicerExecutionModel_USE_FILE})
include(${SlicerExecutionModel_CMAKE_DIR}/SEMMacroBuildCLI.cmake)
message(STATUS "YYYY ${ITK_INCLUDE_DIRS}")

find_package(ITK 4.5 COMPONENTS
${ITK_MODULES_USED}
REQUIRED
)
include(${ITK_USE_FILE})
message(STATUS "XXXX ${ITK_INCLUDE_DIRS}")
else()

THIS WORKS

find_package(ITK 4.5 COMPONENTS
${ITK_MODULES_USED}
REQUIRED
)
include(${ITK_USE_FILE})
find_package(SlicerExecutionModel REQUIRED GenerateCLP)
include(${GenerateCLP_USE_FILE})
include(${SlicerExecutionModel_USE_FILE})
include(${SlicerExecutionModel_CMAKE_DIR}/SEMMacroBuildCLI.cmake)
message(STATUS "YYYY ${ITK_INCLUDE_DIRS}")

message(STATUS "XXXX ${ITK_INCLUDE_DIRS}")

endif()

Installation of SlicerExecutionModel

When running the install step of SlicerExecutionModel, only one file is installed:
<CMAKE_INSTALL_PREFIX>/lib/ModuleDescriptionParser/libModuleDescriptionParser.a
It is therefore not possible to install SlicerExecutionModel and use it. It would be great to have a real install step that would install all the necessary files to be able to actually install SlicerExecutionModel.

Add COMPILE_FLAGS argument to SEMMacroBuildCLI

Sometimes it might be useful to disable warnings when compiling a CLI.
The naive manual solution to call set_target_properties(${MODULE_NAME}Lib PROPERTIES COMPILE_FLAGS "-Wno-overloaded-virtual") fails because "-Dmain-=ModuleEntryPoint" is no longer defined.

Error when building GenerateCLPLauncher on latest master

[100%] Building C object GenerateCLP/CMakeFiles/GenerateCLPLauncher.dir/GenerateCLPLauncher.c.o
/Users/zach/dev/covalic-score-build/SlicerExecutionModel-Build/GenerateCLP/GenerateCLPLauncher.c:15:4: error: expected identifier or '('
   "/Users/zach/dev/covalic-score-build/SlicerExecutionModel-Build/ModuleDescriptionParser/bin" CONFIG_DIR_POST \
   ^
In file included from /Users/zach/dev/covalic-score-build/SlicerExecutionModel-Build/GenerateCLP/GenerateCLPLauncher.c:29:
/Users/zach/dev/covalic-score-build/Insight-Build/Modules/ThirdParty/KWSys/src/itksys/SharedForward.h:720:76: error: expected expression
  static const char* search_path_build[] = {KWSYS_SHARED_FORWARD_PATH_BUILD, 0};
                                                                           ^
/Users/zach/dev/covalic-score-build/Insight-Build/Modules/ThirdParty/KWSys/src/itksys/SharedForward.h:721:80: error: expected expression
  static const char* search_path_install[] = {KWSYS_SHARED_FORWARD_PATH_INSTALL, 0};

ping @vovythevov @jcfr

Add support for Temporary directory

Discussion: http://slicer-devel.65872.n3.nabble.com/Temporary-directory-for-CLI-modules-td4035464.html

Reason to reject initial patch from @ prastawa : Patch Slicer/Slicer#400 will be problematic when the CLI is executed directly without Slicer.

Proposal:

  • CLI should always expect the environment variable SEM_TEMPORARY_DIR to be set
  • SEM_TEMPORARY_DIR can be set in three different ways:
    1. Set by reading the value of an other environment variable. This other environment variable would be set configuring SlicerExecutionModel using for example -DSEM_TEMPORARY_DIR_ENVVAR_NAME:STRING=SLICER_TEMPORARY_DIR
    2. Set by reading the value of special parameter named --sem-temporary-dir. If specified, other environment variable would be ignored
    3. If neither (1) or (2) have been set, temporary directory will be set to the operating system default
  • code in charge of reading the other environment variable, or special parameter would be embedded in the CLI thanks to code generated by GenerateCLP

Fix and simplify continuous integration

As of August 13th 2021, all jobs are failing:

image

Source: https://app.circleci.com/pipelines/github/Slicer/SlicerExecutionModel/19/workflows/ed1fad58-f7e9-4df7-8887-ddf82dd7e454

Suggested plan:

  • Remove these obsolete jobs:

    - itk-v4.8.0_use_system_libraries-off
    - itk-v4.10.1_use_system_libraries-off
    - itk-v4.13.0_use_system_libraries-off

  • Update itk-master_use_system_libraries-off docker image

  • Add itk-v5.1.2_use_system_libraries-off and itk-v5.2.1_use_system_libraries-off

For more details:

Error while compiling with ITKv4.9.0

Compilation error when building SlicerExecutionModel in a x86_64 GNU/Linux system.

[  7%] Building CXX object ModuleDescriptionParser/CMakeFiles/ModuleDescriptionParser.dir/ModuleDescriptionParser.cxx.o
In file included from include/ITK-4.9/expat.h:11:0,
                 from SlicerExecutionModel/ModuleDescriptionParser/ModuleDescriptionParser.cxx:24:
include/ITK-4.9/expatDllConfig.h:5:30: fatal error: itk_expat_mangle.h: No such file or directory
compilation terminated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.