How to use CMAKE to build a program and dcmtk at the same time

Compilation and installation of DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
Mario
Posts: 10
Joined: Fri, 2010-11-05, 07:22

How to use CMAKE to build a program and dcmtk at the same time

#1 Post by Mario »

Greetings,

I need to ship my application as source code. Is there a way to build the application and DCMTK at the same time without precompiling DCMTK? I can't provide precompiled binary because i do not know on which system it will be done.
I tried to include DCMTK's CMakeLists.txt in my application's CMakeLists.txt using add_subdirectory but, include paths are all wrong.

Any idea?

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#2 Post by Michael Onken »

Hi,

I think it should possible though I never tried. But other projects do that, like CommonTK.

What kind of errors you get? Include path while compiling DCMTK or after that, compiling the part that contains your own project? The latter would be easier to explain. Maybe you could give some more details.

Best regards,
Michael

Mario
Posts: 10
Joined: Fri, 2010-11-05, 07:22

#3 Post by Mario »

In my CmakeLists.txt I use add_subdirectory(dcmtk) with dcmtk be the subdirectory with the dcmtk's source tree. It compiles fine (all modules) but, when i try to use dcmtk in my program i get this problem: as an example #include "dcmtk/dcmimgle/dcmimage.h" do not exists because it point to the dcmtk source tree in which this header is located in dcmtk/dcmimgle/include/dcmtk/dcmimgle/. I know i could rewrite all headers include to mach this new layout but i'd like to use the same header layout as the precompiled library.

Thank you for your time and sorry for my poor english.

Mario

Michael Onken
DCMTK Developer
Posts: 2048
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

#4 Post by Michael Onken »

Hi Mario,

no problem, your English is just fine to understand.

Right, one possibility would be to change all the #include directives. However, the better possibility is if you

1) Either also call the INSTALL target to a directory that you specify as CMAKE_INSTALL_PREFIX for DCMTK, or
2) you add all DCMTK include directories that reside in the DCMTK source tree (e.g. c:\src\dcmtk\oflog\include c:\src\dcmtk\ofstd\include c:\src\dcmtk\dcmdata\include... and so on).

Both possibilities are much easier than changing all #includes in your source. Whether 1) is possible depends on how you build your source code (Unix, windows, Visual Studio or NMake, ...). So maybe 2) is most easy to do.

Also, for linking your application later on, you have to add all the directories to the linker input, where CMake puts the compiled DCMTK libaries.

Best regards
Michael

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest