Message: Re: How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Note Re: How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu 

Forum: Installation and Configuration
Re: None How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu (Fada Guan)
Date: 21 May, 2012
From: Ben Morgan <Ben Morgan>

On Sun, 20 May 2012 23:33:48 GMT, Fada Guan wrote:
> Dear All:
> 
> I have installed Geant4.9.5.p01 using cmake on Windows7 and ubuntu, and
> I can successfully compile and execute the examples.
> 
> I have installed root on Windows7 and ubuntu. Now, I want to use root in
> my geant4 application.
> 
> 1,if I do not use cmake, but use traditional makefile, I can apply root
> in my application and produce root files. However, if I use cmake, even
> though the root can be found by cmake, but actually, root-related
> headers take no effect in one application, which means no root files are
> produced.
> 
> 2, on Windows7, I don't know how to set the parameters to make root
> effective in one Geant4 application.

To use any non-Geant4 package (say, "FOO") through CMake, the best way is to locate a suitable FindFOO.cmake module (see the CMake Wiki entry for details). CMake provide quite a few already, so check those first, although ROOT isn't one of them. For ROOT, one is available via their FAQs (see the Can I integrate ROOT into my CMake build? entry).

To integrate a FindFOO.cmake module that isn't supplied by CMake into your project, copy it into your source tree, say under a directory cmake/. Then in your CMakeLists.txt, add the lines:

# This allows CMake to find your module
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

# Find FOO
find_package(FOO)

# Add FOOs header paths
include_directories(${FOO_INCLUDE_DIRS})

# Build your executable
add_executable(MyExe MyExe.cpp)

# Link executable to FOO libraries
target_link_libraries(MyExe ${FOO_LIBRARIES})

This assumes that the FindFOO.cmake module sets the FOO_INCLUDE_DIRS and FOO_LIBRARIES variables, but any good one should do so and that for ROOT does as far as I'm aware.

The above should also work cross-platform.

Cheers,

Ben.

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu   (Fada Guan - 22 May, 2012)
(_ Note: Re: How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu   (Ben Morgan - 22 May, 2012)
(_ None: Re: How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu   (Fada Guan - 23 May, 2012)
(_ None: Re: How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu   (Ben Morgan - 24 May, 2012)
(_ None: Re: How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu   (Fada Guan - 24 May, 2012)
(_ None: Re: How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu   (Fada Guan - 25 May, 2012)
 Add Message Add Message
to: "Re: How can we use root in Geant4.9.5 with cmake on Windows7 or ubuntu"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]