File: external_code.html

package info (click to toggle)
openms 1.11.1-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 436,688 kB
  • ctags: 150,907
  • sloc: cpp: 387,126; xml: 71,547; python: 7,764; ansic: 2,626; php: 2,499; sql: 737; ruby: 342; sh: 325; makefile: 128
file content (122 lines) | stat: -rw-r--r-- 10,316 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<HTML>
<HEAD>
<TITLE>External Code using OpenMS</TITLE>
<LINK HREF="doxygen.css" REL="stylesheet" TYPE="text/css">
<LINK HREF="style_ini.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<A href="index.html">Home</A> &nbsp;&middot;
<A href="classes.html">Classes</A> &nbsp;&middot;
<A href="annotated.html">Annotated Classes</A> &nbsp;&middot;
<A href="modules.html">Modules</A> &nbsp;&middot;
<A href="functions_func.html">Members</A> &nbsp;&middot;
<A href="namespaces.html">Namespaces</A> &nbsp;&middot;
<A href="pages.html">Related Pages</A>
<HR style="height:1px; border:none; border-top:1px solid #c0c0c0;">
<!-- Generated by Doxygen 1.8.5 -->
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">External Code using <a class="el" href="namespaceOpenMS.html" title="Main OpenMS namespace. ">OpenMS</a> </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>If OpenMS' TOPP and UTILS tools are not enough in a certain scenario, you can either request a change to OpenMS, if you feel this functionality is useful for others as well, or modify/extend OpenMS privately. For the latter, there are multiple ways to do this: You can modify the developer version of OpenMS by changing existing tools or adding new ones. Or you use an <b>External Project</b> to write a new tool, while not touching OpenMS itself (see below on how to do that). Once you've finished your new tool, and it only needs to run on the development machine, you're done. If you want to ship it to a new client machine, see <a class="el" href="external_code.html#development_external_ship">Shipping your external code to a new machine</a> .</p>
<h1><a class="anchor" id="development_external"></a>
Compiling external code</h1>
<p>It is very easy to set up an environment to write your own programs using OpenMS. Make sure you downloaded and installed the source package of OpenMS/TOPP properly. Note that you cannot use the 'install' target when working with the development version of OpenMS - it must be built and used within the build tree. <br/>
 <br/>
</p>
<p>All important compiler settings and preprocessor definitions along with the OpenMS library will be available to you. The most important variables are: </p>
<ul>
<li>
OPENMS_INCLUDE_DIRS - all include directories containing OpenMS headers </li>
<li>
OPENMS_ADDCXX_FLAGS - preprocessor macros we require written as (-DMACRO1 -DMACRO2) etc </li>
<li>
OPENMS_DEFINITIONS - compiler flags (e.g. to disable certain compiler warnings) </li>
</ul>
<p>and the OpenMS target itself (which you can link against). <br/>
 The example that follows will be explained in details:</p>
<div class="fragment"><div class="line"><span class="preprocessor">### example CMakeLists.txt to develop programs using OpenMS</span></div>
<div class="line"><span class="preprocessor"></span>project(<span class="stringliteral">&quot;Main&quot;</span>)</div>
<div class="line">cmake_minimum_required(VERSION 2.6)</div>
<div class="line"></div>
<div class="line"><span class="preprocessor">## list all your executables here (a corresponding .C file should exist, e.g. Main.C)</span></div>
<div class="line"><span class="preprocessor"></span>set(my_executables</div>
<div class="line">  Main</div>
<div class="line">)</div>
<div class="line"></div>
<div class="line"><span class="preprocessor">## list all classes here, which are required by your executables</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">## (all these classes will be linked into a library)</span></div>
<div class="line"><span class="preprocessor"></span>set(my_sources</div>
<div class="line">  ExampleLibraryFile.C</div>
<div class="line">)</div>
<div class="line"></div>
<div class="line"><span class="preprocessor">## find OpenMS configuration and register target &quot;OpenMS&quot; (our library)</span></div>
<div class="line"><span class="preprocessor"></span>find_package(OpenMS)</div>
<div class="line"><span class="preprocessor">## if the above fails you can try:</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#find_package(OpenMS PATHS &quot;&lt;/c/path/to/OpenMS&gt;/cmake&quot;)</span></div>
<div class="line"><span class="preprocessor"></span></div>
<div class="line"><span class="preprocessor"># check whether the OpenMS package was found</span></div>
<div class="line"><span class="preprocessor"></span><span class="keywordflow">if</span> (OpenMS_FOUND)</div>
<div class="line"></div>
<div class="line"><span class="preprocessor">  ## include directories for OpenMS headers (and contrib)</span></div>
<div class="line"><span class="preprocessor"></span>  include_directories(${OPENMS_INCLUDE_DIRS})</div>
<div class="line"></div>
<div class="line">  </div>
<div class="line">  ## append precompiler macros and compiler flags specific to OpenMS</div>
<div class="line">  ## Warning: <span class="keyword">this</span> could be harmful to your project. Check <span class="keyword">this</span> <span class="keywordflow">if</span> problems occur.</div>
<div class="line">  ## Also, use <span class="keyword">this</span> to add your own compiler flags, e.g. <span class="keywordflow">for</span> OpenMP support.</div>
<div class="line">  ## e.g. <span class="keywordflow">for</span> Visual Studio use /openmp</div>
<div class="line">  ## set(CMAKE_CXX_FLAGS <span class="stringliteral">&quot;${CMAKE_CXX_FLAGS} ${OPENMS_ADDCXX_FLAGS} /openmp&quot;</span>)</div>
<div class="line">  set(CMAKE_CXX_FLAGS <span class="stringliteral">&quot;${CMAKE_CXX_FLAGS} ${OPENMS_ADDCXX_FLAGS}&quot;</span>)</div>
<div class="line">  add_definitions(${OPENMS_DEFINITIONS})</div>
<div class="line">  </div>
<div class="line">  ## library with additional classes from above</div>
<div class="line">  add_library(my_custom_lib STATIC ${my_sources})</div>
<div class="line">  </div>
<div class="line">  ## add targets <span class="keywordflow">for</span> the executables</div>
<div class="line">  <span class="keywordflow">foreach</span>(i ${my_executables})</div>
<div class="line">    add_executable(${i} ${i}.C)</div>
<div class="line">    ## link executables against OpenMS</div>
<div class="line">  target_link_libraries(${i} OpenMS my_custom_lib)</div>
<div class="line">  endforeach(i)</div>
<div class="line"></div>
<div class="line">  </div>
<div class="line">else(OpenMS_FOUND)</div>
<div class="line">  message(FATAL_ERROR &quot;OpenMSConfig.cmake file not found!&quot;)</div>
<div class="line">endif(OpenMS_FOUND)</div>
</div><!-- fragment --><p>The command <em>project</em> defines the name of the project - the name is only of interest of you're working in an IDE or want to export this project's targets. To compile your program just append it to the <em>my_executables</em> list. If you also use object files (classes which do not contain a main program), append them to the <em>my_sources</em> list. In the next step CMake creates a statically linked library of the object files, listed in <em>my_sources</em>. This simple CMakeLists.txt example can be extended to also build shared libraries, include other external libraries and so on.</p>
<p>An example external project can be found in <em>OpenMS/share/OpenMS/examples/external_code</em>. Copy these files to a separate directory and use CMake to configure it (here as an in-source build). </p>
<div class="fragment"><div class="line">cd &lt;path_to_external_project&gt;</div>
<div class="line">cmake -G <span class="stringliteral">&quot;&lt;generator&gt;&quot;</span> .</div>
</div><!-- fragment --><p>For more information visit the website of cmake at cmake.org and consult the documentation. <br/>
 <b>Have fun coding with OpenMS!</b></p>
<h1><a class="anchor" id="development_external_ship"></a>
Shipping your external code to a new machine</h1>
<p>If you've modified OpenMS itself and not used an external project you can just use our installer scripts, to build your own OpenMS installer for your platform (see our internal FAQ which is build using "make doc_internal") and ship that to a client machine.</p>
<p>If you've used an external project and have a new executable (+ an optional new library), you can use the installer approach as well, and manually copy the new executable to the TOPP/UTILS binary directory (e.g. on Windows this could be <em>c:/program</em> files/OpenMS/bin, on Linux it could be <em>/bin</em>.</p>
<p>If you do NOT use the installer, you can copy all required files manually, plus a few extra steps - see below. What needs to be done is a little platform dependent, thus very cumbersome to explain. You should look at the cmake installer scripts, to see whats required (for Mac and Linux see <em>OpenMS/cmake/package*</em>.cmake, for Windows see <em><a href="https://open-ms.svn.sourceforge.net/svnroot/open-ms/win_installer/OpenMS_installer.nsi">https://open-ms.svn.sourceforge.net/svnroot/open-ms/win_installer/OpenMS_installer.nsi</a></em> ). <br/>
 In short: </p>
<ul>
<li>
copy the OpenMS/share/OpenMS directory to the client machine (e.g. &lt;client/my_dir&gt;/share) and set the environment variable <em>OPENMS_DATA_PATH</em> to this directory </li>
<li>
copy the OpenMS library (OpenMS.dll for Windows or OpenMS.so/.dylib for Linux/Mac) to &lt;client/my_dir&gt;/bin </li>
<li>
copy all Qt4 libraries to the client &lt;client/my_dir&gt;/bin or on Linux/Mac make sure you have installed the Qt4 package </li>
<li>
[Windows only] copy Xerces dll (see contrib/lib) to &lt;client/my_dir&gt;/bin </li>
<li>
[Windows only] install the VS redistributable package (see Microsoft Homepage) on the client machine which corresponds to the VS version that was used to compile your code (use the correct redist package! , i.e. architecture 32|64bit, VS version, VS Service Pack version). If you choose the wrong redistributable package, you will get "Application failed to initialize properly..." error messages. </li>
</ul>
</div></div><!-- contents -->
<HR style="height:1px; border:none; border-top:1px solid #c0c0c0;">
<TABLE width="100%" border="0">
<TR>
<TD><font color="#c0c0c0">OpenMS / TOPP release 1.11.1</font></TD>
<TD align="right"><font color="#c0c0c0">Documentation generated on Thu Nov 14 2013 11:19:25 using doxygen 1.8.5</font></TD>
</TR>
</TABLE>
</BODY>
</HTML>