CMakeLists.txt 5.11 KB
Newer Older
mato's avatar
mato committed
1
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
2
project(LCGSoft C CXX Fortran)
3

4
5
6
# Global configuration number
set (GLOBAL_REVISION_NUM "")

7
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake/modules)
8
9
10
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) # Default to a Release build
  set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build [Release MinSizeRel Debug RelWithDebInfo]" FORCE)
endif()
11

12
13
14
#---Definition options and teir default values ------------------------------------------------------------------------
set(LCG_INSTALL_POLICY separate CACHE STRING "'separate' or 'join' installation of packages")
set(LCG_SAFE_INSTALL   OFF      CACHE BOOL "Ensure that no overwites occurs at the installation area of packages")
15
16
17
18
19
if (VALIDATION)
  set(LCG_IGNORE         "pythia8;pythia6;agile;rivet;herwig++"       CACHE STRING "List of packages to be ignored from LCG_INSTALL_PREFIX (';' separated)")
else()
  set(LCG_IGNORE         ""       CACHE STRING "List of packages to be ignored from LCG_INSTALL_PREFIX (';' separated)")
endif()
20
set(LCG_INSTALL_PREFIX ""       CACHE PATH "Existing LCG installation path prefix.")
21
set(LCG_TARBALL_INSTALL   ON   CACHE BOOL "Turn ON/OFF creation/installation of tarballs")
22
set(VALIDATION         OFF      CACHE BOOL "Enable validation settings.")
23
set(POST_INSTALL         ON      CACHE BOOL "Enable validation settings.")
24
set(STRIP_RPATH         ON      CACHE BOOL "Strip RPATH from binaries.")
glatyshe's avatar
glatyshe committed
25
string(REPLACE " " ";" LCG_IGNORE "${LCG_IGNORE}")
mato's avatar
mato committed
26

27
#---Report the values of the options-----------------------------------------------------------------------------------
glatyshe's avatar
glatyshe committed
28
29
30
31
32
message(STATUS "Target installation prefix             : ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Existing LCG installations             : ${LCG_INSTALL_PREFIX}")
message(STATUS "Safe installation                      : ${LCG_SAFE_INSTALL}")
message(STATUS "Source and binary tarball installation : ${LCG_TARBALL_INSTALL}")
message(STATUS "Validation mode                        : ${VALIDATION}")
33
message(STATUS "Preparing .post-install.sh scripts     : ${POST_INSTALL}")
34
message(STATUS "Stripping RPATH from binaries          : ${STRIP_RPATH}")
mato's avatar
mato committed
35
message(STATUS "Ignored packages from LCG installation : ${LCG_IGNORE}")
mato's avatar
mato committed
36

37
include(${CMAKE_SOURCE_DIR}/toolchain.cmake)
38
include(lcgsoft-macros)
mato's avatar
mato committed
39

40
#---Define Global variables--------------------------------------------------------------------------------------------
41
42
43
find_program(env_cmd NAMES env)
mark_as_advanced(env_cmd)
set(EXEC ${env_cmd})
glatyshe's avatar
glatyshe committed
44
set(MAKE ${CMAKE_SOURCE_DIR}/cmake/scripts/make_verbose $(MAKE))
45
set(LOCKFILE ${CMAKE_SOURCE_DIR}/cmake/scripts/lockfile.py)
46

47
48
49
50
string(TOUPPER "${CMAKE_BUILD_TYPE}" _build_type_upper)
if (_build_type_upper)
  set (_flag_suffix "_${_build_type_upper}")
endif()
51
message (STATUS "LCG_CPP11                              : ${LCG_CPP11}")
52
message (STATUS "LCG_CPP1Y                              : ${LCG_CPP1Y}")
53
message (STATUS "LCG_CPP14                              : ${LCG_CPP14}")
54
message (STATUS "Common compiler flags: ")
glatyshe's avatar
glatyshe committed
55
56
57
foreach (_compiler C CXX Fortran)
    message(STATUS "  ${_compiler} : ${CMAKE_${_compiler}_FLAGS${_flag_suffix}}")
    set (${_compiler}_FLAGS "${CMAKE_${_compiler}_FLAGS${_flag_suffix}}")
58
59
endforeach()

60
61
62
63
64
65
66
# defines LIBRDIR variable to be either lib or lib64
set(LIBDIR_DEFAULT lib)
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CROSSCOMPILING AND NOT EXISTS "/etc/debian_version")
  if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
    set(LIBDIR_DEFAULT lib64)
  endif()
endif()
67

68
#---Enable (the defintion) of tests by default-------------------------------------------------------------------------
69
70
enable_testing()
include(CTest)
71

72
set(TESTLOGDIR "${PROJECT_BINARY_DIR}/tests")
73
74
75
76
if(NOT "$ENV{CXXFLAGS}" STREQUAL "")
  set(libtoolpatch CXX=$ENV{CXX}\ $ENV{CXXFLAGS})
endif()

glatyshe's avatar
glatyshe committed
77
78
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/timestamps)

79
add_subdirectory(externals)
80
add_subdirectory(gridexternals)
mato's avatar
mato committed
81
add_subdirectory(projects)
hegner's avatar
hegner committed
82
add_subdirectory(pyexternals)
83
add_subdirectory(generators)
84

85
86
if (VALIDATION)
  add_custom_target(validation.pre_builds DEPENDS rivet ROOT lhapdf Python HepMC agile cmaketools)
glatyshe's avatar
glatyshe committed
87
  add_custom_target(validation.pre_tests COMMAND ctest -R lhapdf6sets.download COMMAND ctest -R rivet-tests.genser-prepare_references COMMAND ctest -R rivet-tests.genser-buildanalysis DEPENDS validation.pre_builds)
88
89
90
91
92
93
94
95
96
97
98
99
100
  foreach(pkg sherpa pythia8 pythia6 herwig herwig++)
    set (_deplist)
    foreach(v ${${pkg}_native_version})
      add_custom_target(validation.${pkg}-${v} COMMAND ${CMAKE_SOURCE_DIR}/generators/validation/run.sh ${pkg} ${v} DEPENDS ${pkg}-${v} validation.pre_tests)
      list (APPEND _deplist validation.${pkg}-${v})
    endforeach()
    add_custom_target(validation.${pkg} DEPENDS ${_deplist})
    list(APPEND _depglobal validation.${pkg})
  endforeach()
  add_custom_target(validation DEPENDS ${_depglobal})
  add_custom_target(validation.publish COMMAND ${CMAKE_SOURCE_DIR}/generators/validation/publish.sh)
endif()

Dmitri Konstantinov's avatar
Dmitri Konstantinov committed
101
102
if ( LCG_INSTALL_PREFIX STREQUAL "/afs/cern.ch/sw/lcg/releases")
  message(WARNING "Due to internal circular dependency pyanalysis and pytools subpackages will be built again")
Grigorii Latyshev's avatar
Grigorii Latyshev committed
103
104
105
endif()


106
LCG_create_dependency_files()
Grigorii Latyshev's avatar
Grigorii Latyshev committed
107
file(WRITE ${CMAKE_BINARY_DIR}/fail-logs.txt "")