CMakeLists.txt 4.14 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 7
#        [-DCMAKE_CXX_FLAGS=...]
#        [-DCLHEP_BUILD_CXXSTD="-std=c++NN"] (use specified c++ extension)
8
#        [-DCLHEP_SINGLE_THREAD=ON] (disable multi threading)
9
#        [-DCLHEP_DEBUG_MESSAGES=ON] (see more verbose output)
10
#        [-DCLHEP_BUILD_DOCS=ON]
11
#        [-DLIB_SUFFIX=64]
12 13 14 15 16
#        /path/to/source
#  make
#  make test
#  make install
#
Lynn Garren's avatar
Lynn Garren committed
17 18 19
# mac i386:   -DCMAKE_CXX_FLAGS="-m32" -DCMAKE_OSX_ARCHITECTURES="i386"
# mac x86_64: -DCMAKE_CXX_FLAGS="-m64" -DCMAKE_OSX_ARCHITECTURES="x86_64"
#
20 21 22
# Use -DLIB_SUFFIX=64 to install the libraries in a lib64 subdirectory
# instead of the default lib subdirectory.  
#
23 24 25 26
# The default CLHEP build type is CMAKE_BUILD_TYPE=RelWithDebInfo,
# which matches the default CLHEP autoconf flags
#------------------------------------------------------------------------------

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

Lynn Garren's avatar
Lynn Garren committed
31 32
# use cmake 3.2 or later
cmake_minimum_required(VERSION 3.2)
33
# Project setup
Lynn Garren's avatar
Lynn Garren committed
34
project(CLHEP VERSION 2.3.4.0)
35 36
# - needed for (temporary) back compatibility
set(VERSION ${PROJECT_VERSION})
Lynn Garren's avatar
Lynn Garren committed
37

38 39 40 41
set(CMAKE_MODULE_PATH 
      ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules 
      ${CMAKE_MODULE_PATH}
      )
42

43 44 45 46
# enable use of LIB_SUFFIX
include(ClhepVariables)
clhep_lib_suffix()

47
# CLHEP custom modules
48 49 50
include(ClhepCopyHeaders)
include(ClhepBuildTest)
include(ClhepBuildLibrary)
Lynn Garren's avatar
Lynn Garren committed
51
include(CheckFunctionExists)
52
include(ClhepToolchain)
53 54 55 56 57

ENABLE_TESTING()

# include search path
include_directories ("${PROJECT_BINARY_DIR}")
Lynn Garren's avatar
Lynn Garren committed
58
# add CLHEP/Random to search path so we find gaussTables.cdat
59
include_directories ("${PROJECT_SOURCE_DIR}/Random")
60

61 62 63
# 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)
64 65 66

# set our preferred compiler flags
clhep_set_compiler_flags()
67

Lynn Garren's avatar
Lynn Garren committed
68 69
# the main CLHEP config script
clhep_config()
70

Lynn Garren's avatar
Lynn Garren committed
71 72
# check for required functions
CHECK_FUNCTION_EXISTS(drand48 found_drand48)
73

Lynn Garren's avatar
Lynn Garren committed
74
# all the packages
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
set( CLHEP_subdirs
        Units
	Utility
	Vector
	Evaluator
	GenericFunctions
	Geometry
        Random
	Matrix
	RandomObjects
	Cast
	RefCount
	Exceptions
	)

Lynn Garren's avatar
Lynn Garren committed
90
# The Units and Utility packages are just headers.
91 92 93 94 95 96 97 98 99 100 101 102 103
set( CLHEP_libraries
       Vector
       Evaluator
       GenericFunctions
       Geometry
       Random
       Matrix
       RandomObjects
       Cast
       RefCount
       Exceptions
       )

Lynn Garren's avatar
Lynn Garren committed
104
clhep_copy_headers( ${CLHEP_subdirs} )
105

Lynn Garren's avatar
Lynn Garren committed
106 107 108 109 110 111 112 113 114 115 116 117 118
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)

119
# libCLHEP.a and libCLHEP.so
Lynn Garren's avatar
Lynn Garren committed
120
clhep_build_libclhep( ${CLHEP_libraries} )
121 122 123

# provide tools for other packages to include CLHEP easily
clhep_toolchain()
124

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
# - Build docucumentation if required
if(CLHEP_BUILD_DOCS)
  message(STATUS "Enabled build and install of documents")
  # Build Doxygen
  # Require 1.8.8 or better to allow use of MD file as mainpage
  find_package(Doxygen 1.8.8 REQUIRED)
  configure_file(doxygen.conf.in "${PROJECT_BINARY_DIR}/doxygen.conf" @ONLY)
  add_custom_command(
    OUTPUT "${PROJECT_BINARY_DIR}/Doxygen/html/index.html"
    COMMAND ${DOXYGEN_EXECUTABLE} "${PROJECT_BINARY_DIR}/doxygen.conf"
    WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
    DEPENDS
    "${PROJECT_BINARY_DIR}/doxygen.conf"
    CLHEP
    "${PROJECT_SOURCE_DIR}/README.md"
    COMMENT "Generating Doxygen docs for CLHEP"
    )
  add_custom_target(doc ALL DEPENDS "${PROJECT_BINARY_DIR}/Doxygen/html/index.html")

  install(DIRECTORY ${PROJECT_BINARY_DIR}/Doxygen
    DESTINATION "share/doc/CLHEP"
    )
endif()

149 150
# Custom Packaging
include(ClhepPackaging)