aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt65
1 files changed, 65 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..46aca8b
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,65 @@
+#----------------------------------------------------------------------------
+# Setup the project
+cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
+project(G4BeamTest)
+
+#----------------------------------------------------------------------------
+# Find Geant4 package, activating all available UI and Vis drivers by default
+# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
+# to build a batch mode only executable
+#
+option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
+if(WITH_GEANT4_UIVIS)
+ find_package(Geant4 REQUIRED ui_all vis_all)
+else()
+ find_package(Geant4 REQUIRED)
+endif()
+
+#----------------------------------------------------------------------------
+# Setup Geant4 include directories and compile definitions
+#
+include(${Geant4_USE_FILE})
+
+#----------------------------------------------------------------------------
+# Locate sources and headers for this project
+#
+include_directories(${PROJECT_SOURCE_DIR}/include
+ ${Geant4_INCLUDE_DIR})
+file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cxx)
+file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.h)
+
+#----------------------------------------------------------------------------
+# Add the executable, and link it to the Geant4 libraries
+#
+add_executable(G4BeamTest G4BeamTest.cc ${sources} ${headers})
+target_link_libraries(G4BeamTest ${Geant4_LIBRARIES} )
+
+#----------------------------------------------------------------------------
+# Copy all scripts to the build directory, i.e. the directory in which we
+# build G4BeamTest. This is so that we can run the executable directly because it
+# relies on these scripts being in the current working directory.
+#
+set(G4BeamTest_SCRIPTS
+ G4BeamTest.out
+ G4BeamTest.in
+ optPhoton.mac
+ gui.mac
+ icons.mac
+ run.png
+ vis.mac
+ )
+
+foreach(_script ${G4BeamTest_SCRIPTS})
+ configure_file(
+ ${PROJECT_SOURCE_DIR}/${_script}
+ ${PROJECT_BINARY_DIR}/${_script}
+ COPYONLY
+ )
+endforeach()
+
+#----------------------------------------------------------------------------
+# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
+#
+install(TARGETS G4BeamTest DESTINATION bin)
+
+