Tuesday, April 17, 2018

Running Examples

Trying to get all the examples to work, from ITKWikiExamples-master download.

Trying -DCMAKE_CXX_FLAGS=-std=c++11 flag with example

ccmake -DCMAKE_CXX_FLAGS=-std=c++11 ../../WatershedImageFilter/

Following instructions on how to build an example from
https://itk.org/ITKExamples/Documentation/Build/index.html#build-individual-examples
Following to the t, where itk is installed.  But no test file was found.
Using the flag ccmake -DCMAKE_CXX_FLAGS=-std=c++11 .. in this attempt

Made master-cpopy of all examples.  Going to try running: ccmake -DCMAKE_CXX_FLAGS=-std=c++11 ../ to see if it will work.  Then to build the project, according the the website used: ccmake -DCMAKE_CXX_FLAGS=-std=c++11 -build . . In the bin folder, running ctest -V gives errors while running CTest.
    Going to redo the build project, and run make after doing so. cmake --build 17:29:53 - 17:53:56
run ctest -V got some kind of output!!!


master-flag for using ccmake with the visibility flag.  added set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall") to the CMakeLists.txt got this idea from this github link.  master-flag going to use the commands the tutorial lists. cmake --build . 17:51:25 - 18:12:11


==========================

After doing make install with itk and vtk.  Getting files and instruction from this wiki. This time, building into example-build folder using ITKWikiExamples-master as the 'original' files ccmake -DCMAKE_CXX_FLAGS=-std=c++11 ../ITKWikiExamples-master/.  in the example-build folder, run make 20:31:38 - 20:52:20


Format keeper

Watershed links

Nicer looking site with blue border
https://itk.org/ITKExamples/src/Segmentation/Watersheds/SegmentWithWatershedImageFilter/Documentation.html

itk informaiton, linked from above
https://itk.org/Doxygen/html/classitk_1_1WatershedImageFilter.html

public wiki files, includes how to run the file
https://itk.org/Wiki/ITK/Examples/Segmentation/WatershedImageFilter



itk examples run

Copy .cxx file and CMakeLists.txt.  Setup bin folder, cmake the source and build. In terminal, get to bin folder, use make then./ the executable file.

Directions for how to run includes things on superbuild to link itk and vtk:
https://itk.org/Wiki/ITK/Examples/Instructions/ForUsers#Build_all_of_the_examples


Tried and work:
HelloWorld gave the expected output given on the website.


Installing itk again notes

My notes as I install itk again. Hopefully, this will make sense to me down the line.  A lot of the links were given to me to use as reference from Peter.
https://itk.org/Wiki/ITK/Complete_Setup

Getting sources
Already downloaded sources for itk and vtk.  Used git to get a clone of vtkdata 
On second thought. I'm going to start from scratch, following the steps from the tutorial.  The first step, get cvs. *side note* Might not need cvs for the itk and vtk download.  For the latest itk version, one should just download it from the website directly.

There is a homebrew formula for cvs! brew install cvs (still need to find a way to remove unbrewed dylibs... at a later date).   Followed the create a repository part of this site, to initiate cvs.

To make things simpler, going to follow the directions and commands listed on the complete setup page.

Checking out insight 00:55:17 - 00:56:20
Getting insight documentation 00:56:20 - 01:03:32
Getting demo applications 01:04:20 - 01:04:34

Checking out vtk 01:05:19 - 01:06:26
Getting VTKData 01:07:14 - 01:08:17

Getting CWWidgets 01:09:01 - 01:09:20


Compiling the sources
Had to get itk copy from the downloaded stuff from the original attempt (cmake -DCMAKE_CXX_FLAGS=-std=c++11 ../Insight) 01:14:13 - 01:20:19
     Didn't have to hit c or g.  Seems like the configure and generating was done automatically.
make 01:26:46 - 04:20:00
Used the wrong command above.  Use ccmake command instead. Turned on BUILD_EXAMPLES and Module_ITKVtkGlue. 12:03:05 - 12:11:44 make 12:12:06 - 12:59:05
After class 4/17 ran make install 20:09:46 - 20:11:36


Vtk used ccmake.  Marked BUILD_EXAMPLES, VTK_WRAP_TCL, Module_vtk_TestingCore, and Module_vtk_TestingRendering on.  I was not able to find VTK_USE_HYBRID. Seems like use hybrid was necessary for older versions. Decided to turn off VTK_WRAP_TCL, since ccmake kept telling me it has been deprecated. 14:46:23 - 12:52:52 A lot of the time, it was waiting for me.
Don't forget to run make!!!
After class 4/17 ran make install 20:11:48 - 20:12:26


From video: itk: BUILD_EXAMPLES, Module_ITKVtkGlue on. vtk: BUILD_EXAMPLES, (build_testing unchecked), (ignore missing modules) Module_vtk_TextingCore, Module_vtk_TestingRendering.

InsightApplications
The cvs version is an old version.  Looks like this just has a bunch of examples, so I'm going to try skipping it for now. Moving on...

KWWidgets
Need to set VTK_WRAP_TCL to on...
Going back to turn that back on. But when that is turned on, vtk doesn't like it. So back to reconfiguring vtk.  15:05:07 - 15:09:42
making vtk again 15:24:46 - 16:00:13

Skipping to running examples

Monday, April 16, 2018

Quick CMake Tutorial

Tutorial link

Notes:
Uses a single script to generate build scripts.  The first command in the root CMakeLists.txt is the minimum required CMake version, cmake_minimum_required(VERSION x.x.x). This is automatically done on CLion (the website this tutorial is from).  CMakeLists.txt should be in the root directory of all project-related files for CLion.
After the minimum required version, define the name of the project. A project is a collection of files that are somehow related.
You can create text variables by using the set() command.  To refer to the variable later on, enclose it in round braces prepended by a dollar sign. Ex:  set a variable MY_VAR with the value "hello" -> set (MY_VAR "hello")  set(OTHER_VAR "${MY_VAR} world!")
Header search paths let the compiler know where to search for headers.  The compiler starts searching in several predefined locations, based on the OS, and the user can specify further directories using include_directories(). Users can control the order of inclusion of the directories by using BEFORE and AFTER keywords. 
Can enable a particular language standard by using CMAKE_CXX_VARIABLE, which can also set up additional complier-related settings using CMAKE_CXX_FLAGS
Build targets define an executable or library that the CMake scrip helps build. One script can have more than one build target.  To create an executable binary, use add_executable() command.  Can build a library instead.  There are 3 kinds of library one can build.  STATIC a static library that gets embedded into the executable that decides to use it.  SHARED builds a shared library (.so or .dll depending on OS). MODULE builds a plugin library.  Don't need to link against, but it can load dynamically at runtime.
To include libraries, one needs to instruct the compiler to find the desired library and its components using find_package. In the example below, component1 and component2 are the required/mandatory components for a project, and opt_component is optional. Next, one needs to link an executable to the located library using target_link_libraries. 

Stopped at "Using Boost"

CMakeLists.txt (growing as I read through the site):
// specify minimum cMake version requirement
cmake_minimum_required(VERSION x.x.x)
// define name of project
project(MyProject)
// set example
set (MY_VAR "hello")
set (OTHER_VAR "${MY_VAR} world!")
// specifying header search paths
include_directories( ${MY_SOURCE_DIR}/src )
     // MY_SOURCE_DIR is the desired directory
// setting language standard
set(CMAKE_CXX_STANDARD 11) // enable c++11 standard
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall")
     //telling the compiler to show all compiler errors/warnings.  To get latest versions of the compiler, use -std=c++1y, -std=c++1z, etc. 
add_executable (my_executable my_source1.cpp my_source2.cpp)
     // my_executable is the target name, *.cpp are the source files needed to make the executable
add_library (my_library STATIC|SHARED|MODULE my_surce.cpp)
     // to build a library instead
find_package (my_library COMPONENTS REQUIRED component1 component2 OPTIONAL_COMPONENTS opt_component)
target_link_libraries (my_target my_library another_library)
     // target_link_libraries() should be placed after add_executable() command

placeholder