CMakeLists.txt 3.85 KB
Newer Older
1
2
3
4
#------------------------------------------------------------------------------
# Top Level CMakeLists.txt for CLHEP
#  cmake [-DCMAKE_INSTALL_PREFIX=/install/path] 
#        [-DCMAKE_BUILD_TYPE=Debug|Release|RelWithDebInfo|MinSizeRel]
Lynn Garren's avatar
Lynn Garren committed
5
#        [-DCMAKE_C_COMPILER=...] [-DCMAKE_CXX_COMPILER=...]
Lynn Garren's avatar
Lynn Garren committed
6
#        [-DCLHEP_BUILD_CXXSTD=ON] (c++11 extensions and thread support)
7
#        [-DCLHEP_BUILD_CXXSTD="-std=c++NN"] (use specified c++ extension and thread support)
8
#        [-DCLHEP_DEBUG_MESSAGES=ON] (see more verbose output)
9
#        [-DCLHEP_BUILD_DOCS=ON]
10
#        [-DLIB_SUFFIX=64]
11
12
13
14
15
#        /path/to/source
#  make
#  make test
#  make install
#
Lynn Garren's avatar
Lynn Garren committed
16
17
18
# mac i386:   -DCMAKE_CXX_FLAGS="-m32" -DCMAKE_OSX_ARCHITECTURES="i386"
# mac x86_64: -DCMAKE_CXX_FLAGS="-m64" -DCMAKE_OSX_ARCHITECTURES="x86_64"
#
19
20
21
# Use -DLIB_SUFFIX=64 to install the libraries in a lib64 subdirectory
# instead of the default lib subdirectory.  
#
22
23
24
25
# The default CLHEP build type is CMAKE_BUILD_TYPE=RelWithDebInfo,
# which matches the default CLHEP autoconf flags
#------------------------------------------------------------------------------

26
27
28
29
# Ensure out of source build before anything else
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/ClhepOutOfSourceBuild.cmake)
clhep_ensure_out_of_source_build()

30
# use cmake 2.6 or later
31
32
cmake_minimum_required(VERSION 2.6)

33
34
# project name
project(CLHEP)
Lynn Garren's avatar
Lynn Garren committed
35
set( VERSION 2.3.0.0 )
36

Lynn Garren's avatar
Lynn Garren committed
37
38
39
40
41
42
# If Policy CMP0042 exists, use OLD to prefer the use of install names
# instead of the new @rpath default. 
if(POLICY CMP0042)
  cmake_policy(SET CMP0042 OLD)
endif()

43
44
45
46
set(CMAKE_MODULE_PATH 
      ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules 
      ${CMAKE_MODULE_PATH}
      )
47

48
49
50
51
52
53
# CLHEP_BUILD_DOCS is OFF (false) by default
option(CLHEP_BUILD_DOCS "Build and install CLHEP documentation" OFF)
if(CLHEP_BUILD_DOCS)
  # backwards compatibility variable
  set(build_docs ON)
  message(STATUS "Enabled build and install of documents")
54
endif()
55

56
57
58
59
# enable use of LIB_SUFFIX
include(ClhepVariables)
clhep_lib_suffix()

60
# CLHEP custom modules
61
62
63
include(ClhepCopyHeaders)
include(ClhepBuildTest)
include(ClhepBuildLibrary)
Lynn Garren's avatar
Lynn Garren committed
64
include(CheckFunctionExists)
65
include(ClhepToolchain)
66
67
68

# because we want to move these libraries about,
# do not embed full path in shared libraries or executables
69
set(CMAKE_SKIP_RPATH)
70
71
72
73
74

ENABLE_TESTING()

# include search path
include_directories ("${PROJECT_BINARY_DIR}")
Lynn Garren's avatar
Lynn Garren committed
75
76
# add CLHEP/Random to search path so we find gaussTables.cdat
include_directories ("${CMAKE_SOURCE_DIR}/Random")
77

78
79
80
# Put all library build products in standard locations under build tree
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
81
82
83

# define common flags
set( CMAKE_INCLUDE_PATH  ${CLHEP_BINARY_DIR} )
84

85
86
# set our preferred compiler flags
clhep_set_compiler_flags()
87

Lynn Garren's avatar
Lynn Garren committed
88
89
# the main CLHEP config script
clhep_config()
90

Lynn Garren's avatar
Lynn Garren committed
91
92
# check for required functions
CHECK_FUNCTION_EXISTS(drand48 found_drand48)
93

Lynn Garren's avatar
Lynn Garren committed
94
# all the packages
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
set( CLHEP_subdirs
        Units
	Utility
	Vector
	Evaluator
	GenericFunctions
	Geometry
        Random
	Matrix
	RandomObjects
	Cast
	RefCount
	Exceptions
	)

Lynn Garren's avatar
Lynn Garren committed
110
# The Units and Utility packages are just headers.
111
112
113
114
115
116
117
118
119
120
121
122
123
set( CLHEP_libraries
       Vector
       Evaluator
       GenericFunctions
       Geometry
       Random
       Matrix
       RandomObjects
       Cast
       RefCount
       Exceptions
       )

Lynn Garren's avatar
Lynn Garren committed
124
clhep_copy_headers( ${CLHEP_subdirs} )
125

Lynn Garren's avatar
Lynn Garren committed
126
127
128
129
130
131
132
133
134
135
136
137
138
add_subdirectory(Units)
add_subdirectory(Utility) 
add_subdirectory(Vector) 
add_subdirectory(Evaluator) 
add_subdirectory(GenericFunctions) 
add_subdirectory(Geometry) 
add_subdirectory(Random) 
add_subdirectory(Matrix) 
add_subdirectory(RandomObjects) 
add_subdirectory(Cast) 
add_subdirectory(RefCount) 
add_subdirectory(Exceptions)

139
# libCLHEP.a and libCLHEP.so
Lynn Garren's avatar
Lynn Garren committed
140
clhep_build_libclhep( ${CLHEP_libraries} )
141
142
143

# provide tools for other packages to include CLHEP easily
clhep_toolchain()
144
145
146

# Custom Packaging
include(ClhepPackaging)