GaudiProjectConfig.cmake 54.2 KB
Newer Older
1
2
# - GaudiProject
# Define the macros used by Gaudi-based projects, namely:
Marco Clemencic's avatar
Marco Clemencic committed
3
4
#  gaudi_project(project version) : declare a project with it's version number
#  gaudi_use_project(project version) : declare the dependency on another project
5
6
7
#
# Authors: Pere Mato, Marco Clemencic

8
cmake_minimum_required(VERSION 2.8.5)
9

10
11
# Add the directory containing this file to the modules search path
set(CMAKE_MODULE_PATH ${GaudiProject_DIR} ${CMAKE_MODULE_PATH})
12

13
14
15
16
17
#-------------------------------------------------------------------------------
# Basic configuration
#-------------------------------------------------------------------------------
set(CMAKE_VERBOSE_MAKEFILES OFF)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
18
# Ensure that the include directories added are always taken first.
19
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
20
21
#set(CMAKE_SKIP_BUILD_RPATH TRUE)

22
23
24
25
26
27
find_program(ccache_cmd ccache)
if(ccache_cmd)
  option(CMAKE_USE_CCACHE "Use ccache to speed up compilation." OFF)
  if(CMAKE_USE_CCACHE)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${ccache_cmd})
    message(STATUS "Using ccache for building")
28
  endif()
29
30
31
32
33
34
35
36
37
endif()
find_program(distcc_cmd distcc)
if(distcc_cmd)
  option(CMAKE_USE_DISTCC "Use distcc to speed up compilation." OFF)
  if(CMAKE_USE_DISTCC)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${distcc_cmd})
    message(STATUS "Using distcc for building")
    if(CMAKE_USE_CCACHE)
      message(WARNING "Cannot use distcc and ccache at the same time: using distcc")
38
39
40
    endif()
  endif()
endif()
41
mark_as_advanced(ccache_cmd distcc_cmd)
42

43
44
45
#-------------------------------------------------------------------------------
# Platform transparency
#-------------------------------------------------------------------------------
46
47
48
49
50
51
52
53
if(WIN32)
  set(ld_library_path PATH)
elseif(APPLE)
  set(ld_library_path DYLD_LIBRARY_PATH)
else()
  set(ld_library_path LD_LIBRARY_PATH)
endif()

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
set(lib lib)
set(bin bin)

if(WIN32)
  set(ssuffix .bat)
  set(scomment rem)
else()
  set(ssuffix .csh)
  set(scomment \#)
endif()


#---------------------------------------------------------------------------------------------------
# Programs and utilities needed for the build
#---------------------------------------------------------------------------------------------------
69
include(CMakeParseArguments)
70
71
72
73
74

find_package(PythonInterp)

#--- commands required to build cached variable
# (python scripts are located as such but run through python)
75
set(hints ${CMAKE_SOURCE_DIR}/GaudiPolicy/scripts ${CMAKE_SOURCE_DIR}/GaudiKernel/scripts ${CMAKE_SOURCE_DIR}/Gaudi/scripts)
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

find_program(env_cmd env.py HINTS ${hints})
set(env_cmd ${PYTHON_EXECUTABLE} ${env_cmd})

find_program(merge_cmd merge_files.py HINTS ${hints})
set(merge_cmd ${PYTHON_EXECUTABLE} ${merge_cmd} --no-stamp)

find_program(versheader_cmd createProjVersHeader.py HINTS ${hints})
set(versheader_cmd ${PYTHON_EXECUTABLE} ${versheader_cmd})

find_program(genconfuser_cmd genconfuser.py HINTS ${hints})
set(genconfuser_cmd ${PYTHON_EXECUTABLE} ${genconfuser_cmd})

find_program(zippythondir_cmd ZipPythonDir.py HINTS ${hints})
set(zippythondir_cmd ${PYTHON_EXECUTABLE} ${zippythondir_cmd})

92
93
94
find_program(gaudirun_cmd gaudirun.py HINTS ${hints})
set(gaudirun_cmd ${PYTHON_EXECUTABLE} ${gaudirun_cmd})

95
96
97
98
99
100
101
#-------------------------------------------------------------------------------
# gaudi_project(project version)
#
# Main macro for a Gaudi-based project.
# Each project must call this macro once in the top-level CMakeLists.txt,
# stating the project name and the version in the LHCb format (vXrY[pZ]).
#-------------------------------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
102
macro(gaudi_project project version)
103
  set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
104
  project(${project})
105
106
  #----For some reason this is not set by calling 'project()'
  set(CMAKE_PROJECT_NAME ${project})
107
108

  #--- Define the version of the project - can be used to generate sources,
109
110
  set(CMAKE_PROJECT_VERSION ${version} CACHE STRING "Version of the project")

111
112
113
114
  string(REGEX MATCH "v?([0-9]+)[r.]([0-9]+)([p.]([0-9]+))?" _version ${version})
  set(CMAKE_PROJECT_VERSION_MAJOR ${CMAKE_MATCH_1} CACHE INTERNAL "Major version of project")
  set(CMAKE_PROJECT_VERSION_MINOR ${CMAKE_MATCH_2} CACHE INTERNAL "Minor version of project")
  set(CMAKE_PROJECT_VERSION_PATCH ${CMAKE_MATCH_4} CACHE INTERNAL "Patch version of project")
115

116
  #--- Project Options and Global settings----------------------------------------------------------
117
118
  option(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
  option(BUILD_TESTS "Set to ON to build the tests (libraries and executables)" OFF)
119
  option(HIDE_WARNINGS "Turn on or off options that are used to hide warning messages" ON)
120
  option(USE_EXE_SUFFIX "Add the .exe suffix to executables on Unix systems (like CMT)" ON)
121
  #-------------------------------------------------------------------------------------------------
122

123
  if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
124
    set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/InstallArea/${BINARY_TAG} CACHE PATH
125
126
      "Install path prefix, prepended onto install directories." FORCE )
  endif()
127

128
129
  if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE STRING
130
131
	   "Single build output directory for all executables" FORCE)
  endif()
132
133
  if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE STRING
134
135
	   "Single build output directory for all libraries" FORCE)
  endif()
136

137
138
139
140
  set(env_xml ${CMAKE_BINARY_DIR}/${project}Environment.xml
      CACHE STRING "path to the XML file for the environment")
  mark_as_advanced(env_xml)

141
  if(BUILD_TESTS)
142
143
    enable_testing()
  endif()
144

145
  # FIXME: external tools need to be found independently of the project
146
  if(CMAKE_PROJECT_NAME STREQUAL Gaudi)
147
148
149
150
151
152
153
    if (NOT USE_EXE_SUFFIX)
      set(genconf_cmd ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genconf)
      set(genwindef_cmd ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genwindef)
    else()
      set(genconf_cmd ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genconf.exe)
      set(genwindef_cmd ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genwindef.exe)
    endif()
154
  else()
155
156
157
158
159
160
161
    if (NOT USE_EXE_SUFFIX)
      set(genconf_cmd ${GAUDI_binaryarea}/bin/genconf.exe)
      set(genwindef_cmd ${GAUDI_binaryarea}/bin/genwindef.exe)
    else()
      set(genconf_cmd ${GAUDI_binaryarea}/bin/genconf.exe)
      set(genwindef_cmd ${GAUDI_binaryarea}/bin/genwindef.exe)
    endif()
162
163
164
    set(GAUDI_SOURCE_DIR ${GAUDI_installation})
  endif()

165
  #--- Project Installations------------------------------------------------------------------------
166
  install(DIRECTORY cmake/ DESTINATION cmake
167
168
                           FILES_MATCHING PATTERN "*.cmake"
                           PATTERN ".svn" EXCLUDE )
Marco Clemencic's avatar
Marco Clemencic committed
169
  install(PROGRAMS cmake/testwrap.sh cmake/testwrap.csh cmake/testwrap.bat cmake/genCMake.py cmake/env.py DESTINATION scripts)
170

171
  #--- Global actions for the project
Marco Clemencic's avatar
Marco Clemencic committed
172
  include(GaudiBuildFlags)
173
  gaudi_project_version_header()
174

175
  #--- Find and collect settings for subdirectories
176
  message(STATUS "Looking for local directories...")
177
  # Locate packages
Marco Clemencic's avatar
Marco Clemencic committed
178
  gaudi_get_packages(packages)
179
180
181
182
183
  message(STATUS "Found:")
  foreach(package ${packages})
    message(STATUS "  ${package}")
  endforeach()

184
  set(library_path)
185
186
  # Take into account the dependencies between local subdirectories before
  # adding them to the build.
187
  gaudi_sort_subdirectories(packages)
188
  # Add all subdirectories to the project build.
189
  foreach(package ${packages})
190
    message(STATUS "Adding directory ${package}")
191
192
193
    add_subdirectory(${package})
  endforeach()

194
195
196
197
198
199
200
201
202
203
204
205
206
  #--- Special global targets for merging files.
  gaudi_merge_files(ConfDB python ${CMAKE_PROJECT_NAME}_merged_confDb.py)
  gaudi_merge_files(Rootmap lib ${CMAKE_PROJECT_NAME}.rootmap)
  gaudi_merge_files(DictRootmap lib ${CMAKE_PROJECT_NAME}Dict.rootmap)

  # FIXME: it is not possible to produce the file python.zip at installation time
  # because of http://public.kitware.com/Bug/view.php?id=8438
  # install(CODE "execute_process(COMMAND  ${zippythondir_cmd} ${CMAKE_INSTALL_PREFIX}/python)")
  add_custom_target(python.zip
                    COMMAND ${zippythondir_cmd} ${CMAKE_INSTALL_PREFIX}/python
                    COMMENT "Zipping Python modules")

  #--- Prepare environment configuration
207
  message(STATUS "Preparing environment configuration:")
208
209
210
211
212
  set(project_environment)

  # - collect environment from externals
  gaudi_external_project_environment()

213
  message(STATUS "  environment for local subdirectories")
214
215
216
217
218
219
  # - collect internal environment
  #   - project root (for relocatability)
  string(TOUPPER ${project} _proj)
  set(project_environment ${project_environment} SET ${_proj}_PROJECT_ROOT ${CMAKE_SOURCE_DIR})
  #   - 'packages' roots (backward compatibility)
  foreach(package ${packages})
220
    message(STATUS "    ${package}")
221
222
223
224
225
226
227
228
229
230
    get_filename_component(_pack ${package} NAME)
    string(TOUPPER ${_pack} _pack)
    set(project_environment ${project_environment} SET ${_pack}ROOT \${${_proj}_PROJECT_ROOT}/${package})
  endforeach()
  #   - 'packages' environments
  foreach(package ${packages})
    get_property(_pack_env DIRECTORY ${package} PROPERTY ENVIRONMENT)
    set(project_environment ${project_environment} ${_pack_env})
  endforeach()

231
  message(STATUS "  environment for the project")
232
233
  #   - installation dirs
  set(project_environment ${project_environment}
234
        PREPEND PATH \${${_proj}_PROJECT_ROOT}/InstallArea/${BINARY_TAG}/scripts
235
236
237
238
239
240
        PREPEND PATH \${${_proj}_PROJECT_ROOT}/InstallArea/${BINARY_TAG}/bin
        PREPEND LD_LIBRARY_PATH \${${_proj}_PROJECT_ROOT}/InstallArea/${BINARY_TAG}/lib
        PREPEND PYTHONPATH \${${_proj}_PROJECT_ROOT}/InstallArea/${BINARY_TAG}/python
        PREPEND PYTHONPATH \${${_proj}_PROJECT_ROOT}/InstallArea/${BINARY_TAG}/python/lib-dynload)

  # - produce environment XML description
241
242
  gaudi_generate_env_conf(${env_xml} ${project_environment})
  install(FILES ${env_xml} DESTINATION .)
243

244
  #--- Generate config files to be imported by other projects.
245
246
247
  gaudi_generate_project_config_version_file()
  gaudi_generate_project_config_file()
  gaudi_generate_project_platform_config_file()
248

249

250
  #--- CPack configuration
251
  set(CPACK_PACKAGE_NAME ${project})
252
  foreach(t MAJOR MINOR PATCH)
253
    set(CPACK_PACKAGE_VERSION_${t} ${CMAKE_PROJECT_VERSION_${t}})
254
255
256
257
258
259
260
  endforeach()
  set(CPACK_SYSTEM_NAME ${BINARY_TAG})

  set(CPACK_GENERATOR TGZ)

  include(CPack)

261
262
endmacro()

263
264
265
266
267
268
269
#-------------------------------------------------------------------------------
# include_package_directories(Package1 [Package2 ...])
#
# Adde the include directories of each package to the include directories.
#-------------------------------------------------------------------------------
function(include_package_directories)
  foreach(package ${ARGN})
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
    # we need to ensure that the user can call this function also for directories
    if(IS_DIRECTORY ${package})
      include_directories(${package})
    else()
      # ensure that the current directory knows about the package
      find_package(${package} QUIET)
      set(to_incl)
      string(TOUPPER ${package} _pack_upper)
      if(${_pack_upper}_FOUND OR ${package}_FOUND)
        # Handle some special cases first, then try for package uppercase (DIRS and DIR)
        # If the package is found, add INCLUDE_DIRS or (if not defined) INCLUDE_DIR.
        # If none of the two is defined, do not add anything.
        if(${package} STREQUAL PythonLibs)
          set(to_incl PYTHON_INCLUDE_DIRS)
        elseif(${_pack_upper}_INCLUDE_DIRS)
          set(to_incl ${_pack_upper}_INCLUDE_DIRS)
        elseif(${_pack_upper}_INCLUDE_DIR)
          set(to_incl ${_pack_upper}_INCLUDE_DIR)
        elseif(${package}_INCLUDE_DIRS)
          set(to_incl ${package}_INCLUDE_DIRS)
        endif()
        # Include the directories
        include_directories(${${to_incl}})
293
294
295
296
297
      endif()
    endif()
  endforeach()
endfunction()

298
299
300
301
302
303
304
#-------------------------------------------------------------------------------
# gaudi_sort_subdirectories
#-------------------------------------------------------------------------------
# NO-OP function used by gaudi_sort_subdirectories
function(require)
endfunction()
# helper macros to collect the required subdirs
305
macro(__visit__ _p)
306
  if(NOT __${_p}_visited__)
307
308
309
310
    set(__${_p}_visited__ 1)
    #---list all dependent packages-----
    if( EXISTS ${CMAKE_SOURCE_DIR}/${_p}/CMakeLists.txt)
      file(READ ${CMAKE_SOURCE_DIR}/${_p}/CMakeLists.txt file_contents)
311
312
313
314
315
316
317
      string(REGEX MATCHALL "require *\\(([^)]+)\\)" vars ${file_contents})
      foreach(var ${vars})
        string(REGEX REPLACE "require *\\(([^)]+)\\)" "\\1" __p ${var})
        separate_arguments(__p)
        foreach(___p ${__p})
           __visit__(${___p})
        endforeach()
318
319
320
      endforeach()
      set(out_packages ${out_packages} ${_p})
    endif()
321
  endif()
322
endmacro()
323
324
# Actual function
function(gaudi_sort_subdirectories var)
325
  set(out_packages)
326
  set(in_packages ${${var}})
327
328
329
330
331
332
  foreach(p ${in_packages})
    __visit__(${p})
  endforeach()
  set(${var} ${out_packages} PARENT_SCOPE)
endfunction()

333
#-------------------------------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
334
335
336
337
# gaudi_get_packages
#
# Find all the CMakeLists.txt files in the sub-directories and add their
# directories to the variable.
338
#-------------------------------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
339
340
function(gaudi_get_packages var)
  set(packages)
341
  file(GLOB_RECURSE cmakelist_files RELATIVE ${CMAKE_SOURCE_DIR} CMakeLists.txt)
Marco Clemencic's avatar
Marco Clemencic committed
342
  foreach(file ${cmakelist_files})
343
344
345
    # ignore the source directory itself
    if(NOT path STREQUAL CMakeLists.txt)
      get_filename_component(package ${file} PATH)
346
347
348
349
      SET(packages ${packages} ${package})
    endif()
  endforeach()
  set(${var} ${packages} PARENT_SCOPE)
350
endfunction()
351

352
353
354
355
356
357
358
359
360
361
#-------------------------------------------------------------------------------
# gaudi_get_package_name(VAR)
#
# Set the variable VAR to the current "package" (subdirectory) name.
#-------------------------------------------------------------------------------
macro(gaudi_get_package_name VAR)
  # By convention, the package is the name of the source directory.
  get_filename_component(${VAR} ${CMAKE_CURRENT_SOURCE_DIR} NAME)
endmacro()

362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
#-------------------------------------------------------------------------------
# gaudi_resolve_link_libraries(variable lib_or_package1 lib_or_package2 ...)
#
# Translate the package names in a list of link library options into the
# corresponding library options.
# Example:
#
#  find_package(Boost COMPONENTS filesystem regex)
#  find_package(ROOT COMPONENTS RIO)
#  gaudi_resolve_link_libraries(LIBS Boost ROOT)
#  ...
#  target_link_libraries(XYZ ${LIBS})
#
# Note: this function is more useful in wrappers to add_library etc, like
#       gaudi_add_library
#-------------------------------------------------------------------------------
function(gaudi_resolve_link_libraries variable)
  set(collected)
  foreach(package ${ARGN})
    # check if it is an actual library or a target first
    if(TARGET ${package} OR EXISTS ${package})
      set(collected ${collected} ${package})
    else()
      # it must be an available package
      string(TOUPPER ${package} _pack_upper)
      # The case of CMAKE_DL_LIBS is more special than others
      if(${_pack_upper}_FOUND OR ${package}_FOUND)
        # Handle some special cases first, then try for PACKAGE_LIBRARIES
        # otherwise fall back on Package_LIBRARIES.
        if(${package} STREQUAL PythonLibs)
          set(collected ${collected} ${PYTHON_LIBRARIES})
        elseif(${_pack_upper}_LIBRARIES)
          set(collected ${collected} ${${_pack_upper}_LIBRARIES})
        else()
          set(collected ${collected} ${${package}_LIBRARIES})
        endif()
      else()
        # if it's not a package, we just add it as it is... there are a lot of special cases
        set(collected ${collected} ${package})
      endif()
    endif()
  endforeach()
  set(${variable} ${collected} PARENT_SCOPE)
endfunction()

#-------------------------------------------------------------------------------
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# gaudi_global_target_append(global_target local_target file1 [file2 ...])
# (macro)
#
# Adds local files as sources for the global target 'global_target' making it
# depend on the local target 'local_target'.
#-------------------------------------------------------------------------------
macro(gaudi_global_target_append global_target local_target)
  set_property(GLOBAL APPEND PROPERTY ${global_target}_SOURCES ${ARGN})
  set_property(GLOBAL APPEND PROPERTY ${global_target}_DEPENDS ${local_target})
endmacro()

#-------------------------------------------------------------------------------
# gaudi_global_target_get_info(global_target local_targets_var files_var)
# (macro)
#
# Put the information to configure the global target 'global_target' in the
# two variables local_targets_var and files_var.
#-------------------------------------------------------------------------------
macro(gaudi_global_target_get_info global_target local_targets_var files_var)
  get_property(${files_var} GLOBAL PROPERTY ${global_target}_SOURCES)
  get_property(${local_targets_var} GLOBAL PROPERTY ${global_target}_DEPENDS)
endmacro()


#-------------------------------------------------------------------------------
# gaudi_merge_files_append(merge_tgt local_target file1 [file2 ...])
#
# Add files to be included in the merge target 'merge_tgt', using 'local_target'
# as dependency trigger.
#-------------------------------------------------------------------------------
function(gaudi_merge_files_append merge_tgt local_target)
  gaudi_global_target_append(Merged${merge_tgt} ${local_target} ${ARGN})
endfunction()

#-------------------------------------------------------------------------------
# gaudi_merge_files(merge_tgt dest filename)
#
# Create a global target Merged${merge_tgt} that takes input files and dependencies
# from the packages (declared with gaudi_merge_files_append).
447
#-------------------------------------------------------------------------------
448
449
450
function(gaudi_merge_files merge_tgt dest filename)
  gaudi_global_target_get_info(Merged${merge_tgt} deps parts)
  if(parts)
451
    # create the targets
452
    set(output ${CMAKE_BINARY_DIR}/${dest}/${filename})
453
    add_custom_command(OUTPUT ${output}
454
                       COMMAND ${merge_cmd} ${parts} ${output}
455
                       DEPENDS ${parts})
456
    add_custom_target(Merged${merge_tgt} ALL DEPENDS ${output})
457
    # prepare the high level dependencies
458
    add_dependencies(Merged${merge_tgt} ${deps})
459
    # install rule for the merged DB
460
    install(FILES ${output} DESTINATION ${dest})
461
462
  endif()
endfunction()
463
464

#---------------------------------------------------------------------------------------------------
465
466
467
468
# gaudi_generate_configurables(library)
#
# Internal function. Add the targets needed to produce the configurables for a
# module (component library).
469
470
471
#
# Note: see gaudi_install_python_modules for a description of how conflicts
#       between the installations of __init__.py are solved.
472
#---------------------------------------------------------------------------------------------------
473
474
475
476
477
478
function(gaudi_generate_configurables library)
  gaudi_get_package_name(package)

  # set(library_preload)  # TODO....

  # Prepare the build directory
479
480
  set(outdir ${CMAKE_CURRENT_BINARY_DIR}/genConf/${package})
  file(MAKE_DIRECTORY ${outdir})
481
482

  # Python classes used for the various component types.
483
484
485
486
487
488
  set(confModuleName GaudiKernel.Proxy)
  set(confDefaultName Configurable.DefaultName)
  set(confAlgorithm ConfigurableAlgorithm)
  set(confAlgTool ConfigurableAlgTool)
  set(confAuditor ConfigurableAuditor)
  set(confService ConfigurableService)
489

490
491
  add_custom_command(
    OUTPUT ${outdir}/${library}_confDb.py ${outdir}/${library}Conf.py ${outdir}/__init__.py
492
    COMMAND ${env_cmd}
493
                  -p ${ld_library_path}=.
494
                  -p ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
495
                  --xml ${env_xml}
496
497
498
499
500
501
502
503
504
505
              ${genconf_cmd} ${library_preload} -o ${outdir} -p ${package}
                --configurable-module=${confModuleName}
                --configurable-default-name=${confDefaultName}
                --configurable-algorithm=${confAlgorithm}
                --configurable-algtool=${confAlgTool}
                --configurable-auditor=${confAuditor}
                --configurable-service=${confService}
                -i ${library}
    DEPENDS ${library})
  add_custom_target(${library}Conf ALL DEPENDS ${outdir}/${library}_confDb.py)
506
  # Add dependencies on GaudiSvc and the genconf executable if they have to be built in the current project
507
  add_dependencies(${library}Conf genconf GaudiCoreSvc)
508
  # Notify the project level target
509
  gaudi_merge_files_append(ConfDB ${library}Conf ${outdir}/${library}_confDb.py)
510
  #----Installation details-------------------------------------------------------
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
  install(FILES ${outdir}/${library}_confDb.py ${outdir}/${library}Conf.py
          DESTINATION python/${package})

  # Check if we need to install our __init__.py (i.e. it is not already installed
  # with the python modules).
  # Note: no need to do anything if we already have configurables
  get_property(has_configurables DIRECTORY PROPERTY has_configurables)
  if(NOT has_configurables)
    get_property(python_modules DIRECTORY PROPERTY has_python_modules)
    list(FIND python_modules ${package} got_pkg_module)
    if(got_pkg_module LESS 0)
      # we need to install our __init__.py
      install(FILES ${outdir}/__init__.py DESTINATION python/${package})
    endif()
  endif()

  # Property used to synchronize the installation of Python modules between
  # gaudi_generate_configurables and gaudi_install_python_modules.
  set_property(DIRECTORY APPEND PROPERTY has_configurables ${library})
530
531
532
533
534
535
endfunction()

define_property(DIRECTORY
                PROPERTY CONFIGURABLE_USER_MODULES
                BRIEF_DOCS "ConfigurableUser modules"
                FULL_DOCS "List of Python modules containing ConfigurableUser specializations (default <package>/Config, 'None' to disable)." )
536
537
538
#---------------------------------------------------------------------------------------------------
# gaudi_generate_confuserdb([DEPENDS target1 target2])
#
539
540
541
542
543
# Generate entries in the configurables database for ConfigurableUser specializations.
# By default, the python module supposed to contain ConfigurableUser's is <package>.Config,
# but different (or more) modules can be specified with the directory property
# CONFIGURABLE_USER_MODULES. If that property is set to None, there will be no
# search for ConfigurableUser's.
544
545
#---------------------------------------------------------------------------------------------------
function(gaudi_generate_confuserdb)
546
  gaudi_get_package_name(package)
547
548
549
  get_directory_property(modules CONFIGURABLE_USER_MODULES)
  if( NOT (modules STREQUAL "None") ) # ConfUser enabled
    set(outdir ${CMAKE_CURRENT_BINARY_DIR}/genConf/${package})
550

551
    # get the optional dependencies from argument and properties
552
    CMAKE_PARSE_ARGUMENTS(ARG "" "" "DEPENDS" ${arguments})
553
    get_directory_property(PROPERTY_DEPENDS CONFIGURABLE_USER_DEPENDS)
554
555
556
557

    # TODO: this re-runs the genconfuser every time
    #       we have to force it because we cannot define the dependencies
    #       correctly (on the Python files)
558
559
560
561
562
    add_custom_target(${package}ConfUserDB ALL
                      DEPENDS ${outdir}/${package}_user_confDb.py)
    if(${ARG_DEPENDS} ${PROPERTY_DEPENDS})
      add_dependencies(${package}ConfUserDB ${ARG_DEPENDS} ${PROPERTY_DEPENDS})
    endif()
563
564
565
566
567
    add_custom_command(
      OUTPUT ${outdir}/${package}_user_confDb.py
      COMMAND ${env_cmd}
                    -p PYTHONPATH=${CMAKE_SOURCE_DIR}/GaudiKernel/python
                    -p PYTHONPATH=${CMAKE_SOURCE_DIR}/Gaudi/python
568
                    --xml ${env_xml}
569
                ${genconfuser_cmd}
570
571
572
                  -r ${CMAKE_CURRENT_SOURCE_DIR}/python
                  -o ${outdir}/${package}_user_confDb.py
                  ${package} ${modules})
573
574
    install(FILES ${outdir}/${package}_user_confDb.py
            DESTINATION python/${package})
575
    gaudi_merge_files_append(ConfDB ${package}ConfUserDB ${outdir}/${package}_user_confDb.py)
576
577
578
  endif()
endfunction()

579
#-------------------------------------------------------------------------------
580
# gaudi_get_required_include_dirs(<output> <libraries>)
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
#
# Get the include directories required by the linker libraries specified
# and prepend them to the output variable.
#-------------------------------------------------------------------------------
function(gaudi_get_required_include_dirs output)
  set(collected)
  foreach(lib ${ARGN})
    set(req)
    if(TARGET ${lib})
      get_property(req TARGET ${lib} PROPERTY REQUIRED_INCLUDE_DIRS)
      if(req)
        list(APPEND collected ${req})
      endif()
    endif()
  endforeach()
  if(collected)
    set(${output} ${collected} ${${output}} PARENT_SCOPE)
  endif()
endfunction()

601
#-------------------------------------------------------------------------------
602
# gaudi_get_required_library_dirs(<output> <libraries>)
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
#
# Get the library directories required by the linker libraries specified
# and prepend them to the output variable.
#-------------------------------------------------------------------------------
function(gaudi_get_required_library_dirs output)
  set(collected)
  foreach(lib ${ARGN})
    set(req)
    if(EXISTS ${lib})
      get_filename_component(req ${lib} PATH)
      if(req)
        list(APPEND collected ${req})
      endif()
      # FIXME: we should handle the inherited targets
      # (but it's not mandatory because they where already handled)
    endif()
  endforeach()
  if(collected)
    set(${output} ${collected} ${${output}} PARENT_SCOPE)
  endif()
endfunction()

Marco Clemencic's avatar
Marco Clemencic committed
625
626
627
628
629
630
631
632
633
634
#-------------------------------------------------------------------------------
# gaudi_expand_sources(<variable> source_pattern1 source_pattern2 ...)
#
# Get the library directories required by the linker libraries specified
# and prepend them to the output variable.
#-------------------------------------------------------------------------------
macro(gaudi_expand_sources VAR)
  #message(STATUS "Expand ${ARGN} in ${VAR}")
  set(${VAR})
  foreach(fp ${ARGN})
635
636
    file(GLOB files src/${fp})
    if(files)
Marco Clemencic's avatar
Marco Clemencic committed
637
      set(${VAR} ${${VAR}} ${files})
638
    else()
Marco Clemencic's avatar
Marco Clemencic committed
639
      set(${VAR} ${${VAR}} ${fp})
640
641
    endif()
  endforeach()
Marco Clemencic's avatar
Marco Clemencic committed
642
643
644
  #message(STATUS "  result: ${${VAR}}")
endmacro()

645
646
647
648
#-------------------------------------------------------------------------------
# gaudi_common_add_build(sources...
#                 LINK_LIBRARIES library1 package2 ...
#                 INCLUDE_DIRS dir1 package2 ...)
Marco Clemencic's avatar
Marco Clemencic committed
649
#
650
651
652
653
# Internal. Helper macro to factor out the common code to configure a buildable
# target (library, module, dictionary...)
#-------------------------------------------------------------------------------
macro(gaudi_common_add_build)
Marco Clemencic's avatar
Marco Clemencic committed
654
  CMAKE_PARSE_ARGUMENTS(ARG "" "" "LIBRARIES;LINK_LIBRARIES;INCLUDE_DIRS" ${ARGN})
655
  # obsolete option
Marco Clemencic's avatar
Marco Clemencic committed
656
657
658
659
660
  if(ARG_LIBRARIES)
    message(WARNING "Deprecated option 'LIBRARY', use 'LINK_LIBRARIES' instead")
    set(ARG_LINK_LIBRARIES ${ARG_LINK_LIBRARIES} ${ARG_LIBRARIES})
  endif()

661
662
  gaudi_resolve_link_libraries(ARG_LINK_LIBRARIES ${ARG_LINK_LIBRARIES})

Marco Clemencic's avatar
Marco Clemencic committed
663
  # find the sources
664
  gaudi_expand_sources(srcs ${ARG_UNPARSED_ARGUMENTS})
665

666
  # get the inherited include directories
Marco Clemencic's avatar
Marco Clemencic committed
667
  gaudi_get_required_include_dirs(ARG_INCLUDE_DIRS ${ARG_LINK_LIBRARIES})
668
669

  # add the package includes to the current list
Marco Clemencic's avatar
Marco Clemencic committed
670
  include_package_directories(${ARG_INCLUDE_DIRS})
671

672
  # get the library dirs required to get the libraries we use
Marco Clemencic's avatar
Marco Clemencic committed
673
  gaudi_get_required_library_dirs(lib_path ${ARG_LINK_LIBRARIES})
674
  set_property(GLOBAL APPEND PROPERTY LIBRARY_PATH ${lib_path})
675
676
677
678
679
680
endmacro()

#---------------------------------------------------------------------------------------------------
# gaudi_add_library(<name>
#                   source1 source2 ...
#                   LINK_LIBRARIES library1 library2 ...
681
682
#                   INCLUDE_DIRS dir1 package2 ...
#                   [NO_PUBLIC_HEADERS | PUBLIC_HEADERS dir1 dir2 ...])
683
684
685
686
687
688
#
# Extension of standard CMake 'add_library' command.
# Create a library from the specified sources (glob patterns are allowed), linking
# it with the libraries specified and adding the include directories to the search path.
#---------------------------------------------------------------------------------------------------
function(gaudi_add_library library)
689
690
691
692
  # this function uses an extra option: 'PUBLIC_HEADERS'
  CMAKE_PARSE_ARGUMENTS(ARG "NO_PUBLIC_HEADERS" "" "LIBRARIES;LINK_LIBRARIES;INCLUDE_DIRS;PUBLIC_HEADERS" ${ARGN})
  gaudi_common_add_build(${ARG_UNPARSED_ARGUMENTS} LIBRARIES ${ARG_LIBRARIES} LINK_LIBRARIES ${ARG_LINK_LIBRARIES} INCLUDE_DIRS ${ARG_INCLUDE_DIRS})

693
  gaudi_get_package_name(package)
694
  if(NOT ARG_NO_PUBLIC_HEADERS AND NOT ARG_PUBLIC_HEADERS)
695
    message(WARNING "Library ${library} (in ${package}) does not declare PUBLIC_HEADERS. Use the option NO_PUBLIC_HEADERS if it is intended.")
696
  endif()
697

698
  if(WIN32)
699
	add_library( ${library}-arc STATIC EXCLUDE_FROM_ALL ${srcs})
700
    set_target_properties(${library}-arc PROPERTIES COMPILE_DEFINITIONS GAUDI_LINKER_LIBRARY)
701
702
    add_custom_command(
      OUTPUT ${library}.def
703
	  COMMAND ${genwindef_cmd} -o ${library}.def -l ${library} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${library}-arc.lib
704
705
706
707
	  DEPENDS ${library}-arc genwindef)
	#---Needed to create a dummy source file to please Windows IDE builds with the manifest
	file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/${library}.cpp "// empty file\n" )
    add_library( ${library} SHARED ${library}.cpp ${library}.def)
Marco Clemencic's avatar
Marco Clemencic committed
708
709
    target_link_libraries(${library} ${library}-arc ${ARG_LINK_LIBRARIES})
    set_target_properties(${library} PROPERTIES LINK_INTERFACE_LIBRARIES "${ARG_LINK_LIBRARIES}" )
710
  else()
711
    add_library(${library} ${srcs})
712
    set_target_properties(${library} PROPERTIES COMPILE_DEFINITIONS GAUDI_LINKER_LIBRARY)
Marco Clemencic's avatar
Marco Clemencic committed
713
    target_link_libraries(${library} ${ARG_LINK_LIBRARIES})
714
  endif()
715
716

  # Declare that the used headers are needed by the libraries linked against this one
Marco Clemencic's avatar
Marco Clemencic committed
717
  set_property(TARGET ${library} PROPERTY REQUIRED_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} ${ARG_INCLUDE_DIRS})
718
  set_property(GLOBAL APPEND PROPERTY LINKER_LIBRARIES ${library})
719

720
721
722
723
  if(TARGET ${library}Obj2doth)
    add_dependencies( ${library} ${library}Obj2doth)
  endif()
  #----Installation details-------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
724
  install(TARGETS ${library} EXPORT ${CMAKE_PROJECT_NAME}Exports DESTINATION  ${lib})
725
  gaudi_install_headers(${ARG_PUBLIC_HEADERS})
Marco Clemencic's avatar
Marco Clemencic committed
726
  install(EXPORT ${CMAKE_PROJECT_NAME}Exports DESTINATION cmake)
727
728
endfunction()

Marco Clemencic's avatar
Marco Clemencic committed
729
730
731
732
733
734
# Backward compatibility macro
macro(gaudi_linker_library)
  message(WARNING "Deprecated function 'gaudi_linker_library', use 'gaudi_add_library' instead")
  gaudi_add_library(${ARGN})
endmacro()

735
#---------------------------------------------------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
736
#---gaudi_add_module(<name> source1 source2 ... LINK_LIBRARIES library1 library2 ...)
737
#---------------------------------------------------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
738
function(gaudi_add_module library)
739
  gaudi_common_add_build(${ARGN})
740

741
  add_library(${library} MODULE ${srcs})
742
  target_link_libraries(${library} ${ROOT_Reflex_LIBRARY} ${ARG_LINK_LIBRARIES})
743

744
  gaudi_generate_rootmap(${library})
745
  gaudi_generate_configurables(${library})
746

747
748
  set_property(GLOBAL APPEND PROPERTY COMPONENT_LIBRARIES ${library})

749
750
751
752
  #----Installation details-------------------------------------------------------
  install(TARGETS ${library} LIBRARY DESTINATION ${lib})
endfunction()

Marco Clemencic's avatar
Marco Clemencic committed
753
754
755
756
757
# Backward compatibility macro
macro(gaudi_component_library)
  message(WARNING "Deprecated function 'gaudi_component_library', use 'gaudi_add_module' instead")
  gaudi_add_module(${ARGN})
endmacro()
758

759
#-------------------------------------------------------------------------------
760
761
762
763
# gaudi_add_dictionary(dictionary header selection
#                      LINK_LIBRARIES ...
#                      INCLUDE_DIRS ...
#                      OPTIONS ...)
764
765
766
767
768
#
# Find all the CMakeLists.txt files in the sub-directories and add their
# directories to the variable.
#-------------------------------------------------------------------------------
function(gaudi_add_dictionary dictionary header selection)
769
770
771
  # this function uses an extra option: 'OPTIONS'
  CMAKE_PARSE_ARGUMENTS(ARG "" "" "LIBRARIES;LINK_LIBRARIES;INCLUDE_DIRS;OPTIONS" ${ARGN})
  gaudi_common_add_build(${ARG_UNPARSED_ARGUMENTS} LIBRARIES ${ARG_LIBRARIES} LINK_LIBRARIES ${ARG_LINK_LIBRARIES} INCLUDE_DIRS ${ARG_INCLUDE_DIRS})
772
773
774
775
776

  reflex_dictionary(${dictionary} ${header} ${selection} LINK_LIBRARIES ${ARG_LINK_LIBRARIES} OPTIONS ${ARG_OPTIONS})

  # Notify the project level target
  get_property(rootmapname TARGET ${dictionary}Gen PROPERTY ROOTMAPFILE)
777
  gaudi_merge_files_append(DictRootmap ${dictionary}Gen ${CMAKE_CURRENT_BINARY_DIR}/${rootmapname})
778
779
780
781
782

  #----Installation details-------------------------------------------------------
  install(TARGETS ${dictionary}Dict LIBRARY DESTINATION ${lib})
endfunction()

783
#---------------------------------------------------------------------------------------------------
784
785
786
787
788
789
# gaudi_add_python_module(name
#                         sources ...
#                         LINK_LIBRARIES ...
#                         INCLUDE_DIRS ...)
#
# Build a binary python module from the given sources.
790
#---------------------------------------------------------------------------------------------------
791
function(gaudi_add_python_module module)
792
  gaudi_common_add_build(${ARGN})
793

794
795
796
797
  # require Python libraries
  find_package(PythonLibs QUIET REQUIRED)

  add_library(${module} MODULE ${srcs})
798
  if(win32)
799
    set_target_properties(${module} PROPERTIES SUFFIX .pyd PREFIX "")
800
  else()
801
    set_target_properties(${module} PROPERTIES SUFFIX .so PREFIX "")
802
  endif()
Marco Clemencic's avatar
Marco Clemencic committed
803
  target_link_libraries(${module} ${PYTHON_LIBRARIES} ${ARG_LINK_LIBRARIES})
804

805
806
807
808
809
  #----Installation details-------------------------------------------------------
  install(TARGETS ${module} LIBRARY DESTINATION python/lib-dynload)
endfunction()

#---------------------------------------------------------------------------------------------------
810
811
812
813
814
815
816
817
# gaudi_add_executable(<name>
#                      source1 source2 ...
#                      LINK_LIBRARIES library1 library2 ...
#                      INCLUDE_DIRS dir1 package2 ...)
#
# Extension of standard CMake 'add_executable' command.
# Create a library from the specified sources (glob patterns are allowed), linking
# it with the libraries specified and adding the include directories to the search path.
818
#---------------------------------------------------------------------------------------------------
819
function(gaudi_add_executable executable)
820
  gaudi_common_add_build(${ARGN})
821

822
  add_executable(${executable} ${srcs})
823
  target_link_libraries(${executable} ${ARG_LINK_LIBRARIES})
824

825
826
827
  if (USE_EXE_SUFFIX)
    set_target_properties(${executable} PROPERTIES SUFFIX .exe)
  endif()
828

829
  #----Installation details-------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
830
831
832
  install(TARGETS ${executable} EXPORT ${CMAKE_PROJECT_NAME}Exports RUNTIME DESTINATION ${bin})
  install(EXPORT ${CMAKE_PROJECT_NAME}Exports DESTINATION cmake)

833
834
835
endfunction()

#---------------------------------------------------------------------------------------------------
836
837
838
839
840
841
842
# gaudi_add_unit_test(<name>
#                     source1 source2 ...
#                     LINK_LIBRARIES library1 library2 ...
#                     INCLUDE_DIRS dir1 package2 ...)
#
# Special version of gaudi_add_executable which automatically adds the dependency
# on CppUnit.
843
#---------------------------------------------------------------------------------------------------
844
function(gaudi_add_unit_test executable)
845
  if(BUILD_TESTS)
846
847
848
849
850
851
852
853
    gaudi_common_add_build(${ARGN})

    find_package(CppUnit QUIET REQUIRED)

    gaudi_add_executable(${executable} ${srcs}
                         LINK_LIBRARIES ${ARG_LINK_LIBRARIES} CppUnit
                         INCLUDE_DIRS ${ARG_INCLUDE_DIRS} CppUnit)

854
855
    gaudi_get_package_name(package)

856
    get_target_property(exec_suffix ${executable} SUFFIX)
857
858
859
860
861
862
863
864
    if(NOT exec_suffix)
      set(exec_suffix)
    endif()
    add_test(${package}.${executable}
             ${env_cmd}
                 -p ${ld_library_path}=.
                 -p ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
                 -p PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
865
                 --xml ${env_xml}
866
               ${executable}${exec_suffix})
867
868
869
  endif()
endfunction()

870
871
872
873
874
875
876
877
878
879
880
881
#-------------------------------------------------------------------------------
# gaudi_add_test(<name>
#                [FRAMEWORK options1 options2 ...|QMTEST|COMMAND cmd args ...]
#                [ENVIRONMENT variable=value ...])
#
#-------------------------------------------------------------------------------
function(gaudi_add_test name)
  CMAKE_PARSE_ARGUMENTS(ARG "QMTEST" "" "ENVIRONMENT;FRAMEWORK;COMMAND" ${ARGN})

  gaudi_get_package_name(package)

  if(ARG_QMTEST)
882
    find_package(QMTest QUIET)
883
884
885
886
887
888
889
890
891
892
    set(ARG_ENVIRONMENT ${ARG_ENVIRONMENT}
                        QMTESTLOCALDIR=${CMAKE_CURRENT_SOURCE_DIR}/tests/qmtest
                        QMTESTRESULTS=${CMAKE_CURRENT_BINARY_DIR}/tests/qmtest/results.qmr
                        QMTESTRESULTSDIR=${CMAKE_CURRENT_BINARY_DIR}/tests/qmtest)
    set(cmdline run_qmtest.py ${package})

  elseif(ARG_FRAMEWORK)
    foreach(optfile  ${ARG_FRAMEWORK})
      if(IS_ABSOLUTE ${optfile})
        set(optfiles ${optfiles} ${optfile})
893
      else()
894
        set(optfiles ${optfiles} ${CMAKE_CURRENT_SOURCE_DIR}/${optfile})
895
896
      endif()
    endforeach()
897
    set(cmdline ${gaudirun_cmd} ${optfiles})
898

899
900
901
902
903
  elseif(ARG_COMMAND)
    set(cmdline ${ARG_COMMAND})

  else()
    message(FATAL_ERROR "Type of test '${name}' not declared")
904
905
  endif()

906
907
908
909
910
911
912
913
914
915
916
917
918
919
  foreach(var ${ARG_ENVIRONMENT})
    set(extra_env ${extra_env} -s ${var})
  endforeach()

  add_test(${package}.${name}
           ${env_cmd}
               ${extra_env}
               -p ${ld_library_path}=.
               -p ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
               -p PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}

               -p QMTEST_CLASS_PATH=${CMAKE_SOURCE_DIR}/GaudiPolicy/qmtest_classes
               -s GAUDI_QMTEST_HTML_OUTPUT=${CMAKE_BINARY_DIR}/test_results

920
               --xml ${env_xml}
921
922
               ${cmdline})
endfunction()
923

924
#---------------------------------------------------------------------------------------------------
925
926
927
928
# gaudi_install_headers(dir1 dir2 ...)
#
# Install the declared directories in the 'include' directory.
# To be used in case the header files do not have a library.
929
#---------------------------------------------------------------------------------------------------
930
931
932
function(gaudi_install_headers)
  foreach(hdr_dir ${ARGN})
    install(DIRECTORY ${hdr_dir}
933
934
935
            DESTINATION include
            FILES_MATCHING
              PATTERN "*.h"
936
              PATTERN "*.icpp")
937
938
939
  endforeach()
endfunction()

940
941
942
943
944
945
946
#-------------------------------------------------------------------------------
# gaudi_install_python_modules()
#
# Declare that the subdirectory needs to install python modules.
# The hierarchy of directories and  files in the python directory will be
# installed.  If the first level of directories do not contain __init__.py, a
# warning is issued and an empty one will be installed.
947
948
949
950
951
#
# Note: We need to avoid conflicts with the automatic generated __init__.py for
#       configurables (gaudi_generate_configurables)
#       There are 2 cases:
#       * install_python called before genconf
952
953
#         we fill the list of modules to tell genconf not to install its dummy
#         version
954
955
956
#       * genconf called before install_python
#         we install on top of the one installed by genconf
# FIXME: it should be cleaner
957
958
#-------------------------------------------------------------------------------
function(gaudi_install_python_modules)
959
960
961
  install(DIRECTORY python/
          DESTINATION python
          FILES_MATCHING PATTERN "*.py")
962
963
964
965
966
967
  # check for the presence of the __init__.py's and install them if needed
  file(GLOB sub-dir RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} python/*)
  foreach(dir ${sub-dir})
    if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir} AND NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/__init__.py)
      message(WARNING "The file ${dir}/__ini__.py is missing. I shall install an empty one.")
      if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/__init__.py)
968
        file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/__init__.py "# Empty file generated automatically\n")
969
970
971
972
      endif()
      install(FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py
              DESTINATION ${CMAKE_INSTALL_PREFIX}/${dir})
    endif()
973
974
975
    # Add the Python module name to the list of provided ones.
    get_filename_component(modname ${dir} NAME)
    set_property(DIRECTORY APPEND PROPERTY has_python_modules ${modname})
976
  endforeach()
977
  gaudi_generate_confuserdb() # if there are Python modules, there may be ConfigurableUser's
978
979
980
endfunction()

#---------------------------------------------------------------------------------------------------
981
982
983
# gaudi_install_scripts()
#
# Declare that the package needs to install the content of the 'scripts' directory.
984
#---------------------------------------------------------------------------------------------------
985
function(gaudi_install_scripts)
986
987
988
989
990
  install(DIRECTORY scripts/ DESTINATION scripts
          FILE_PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
                           GROUP_EXECUTE GROUP_READ
          PATTERN ".svn" EXCLUDE
          PATTERN "*~" EXCLUDE
991
          PATTERN "*.pyc" EXCLUDE)
992
993
994
endfunction()

#---------------------------------------------------------------------------------------------------
995
# gaudi_install_joboptions(<files...>)
996
997
#
# Install the specified options files in the directory 'jobOptions/<package>'.
998
#---------------------------------------------------------------------------------------------------
999
function(gaudi_install_joboptions)
1000
  gaudi_get_package_name(package)
For faster browsing, not all history is shown. View entire blame