GaudiProjectConfig.cmake 61.8 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

find_package(PythonInterp)

73
74
75
76
77
78
79
#-------------------------------------------------------------------------------
# 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
80
macro(gaudi_project project version)
81
  set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
82
  project(${project})
83
84
  #----For some reason this is not set by calling 'project()'
  set(CMAKE_PROJECT_NAME ${project})
85
86

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

89
90
91
92
  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")
93

94
  #--- Project Options and Global settings----------------------------------------------------------
95
96
  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)
97
  option(HIDE_WARNINGS "Turn on or off options that are used to hide warning messages" ON)
98
  option(USE_EXE_SUFFIX "Add the .exe suffix to executables on Unix systems (like CMT)" ON)
99
  #-------------------------------------------------------------------------------------------------
100

101
  if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
102
    set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/InstallArea/${BINARY_TAG} CACHE PATH
103
104
      "Install path prefix, prepended onto install directories." FORCE )
  endif()
105

106
107
  if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
    set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE STRING
108
109
	   "Single build output directory for all executables" FORCE)
  endif()
110
111
  if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
    set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE STRING
112
113
	   "Single build output directory for all libraries" FORCE)
  endif()
114

115
116
117
118
  set(env_xml ${CMAKE_BINARY_DIR}/${project}Environment.xml
      CACHE STRING "path to the XML file for the environment")
  mark_as_advanced(env_xml)

119
  if(BUILD_TESTS)
120
121
    enable_testing()
  endif()
122

123
124
125
126
127
128
129
130
131
  #--- Find subdirectories
  message(STATUS "Looking for local directories...")
  # Locate packages
  gaudi_get_packages(packages)
  message(STATUS "Found:")
  foreach(package ${packages})
    message(STATUS "  ${package}")
  endforeach()

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
  # List of all known packages, including those exported by other projects
  set(known_packages ${packages})
  #message(STATUS "known_packages (initial) ${known_packages}")

  # paths where to locate scripts and executables
  # Note: it's a bit a duplicate of the one used in gaudi_external_project_environment
  #       but we need it here because the other one is meant to include also
  #       the external libraries requyired by the subdirectories.
  set(binary_paths)

  # Note: the indirection is needed because we are in a macro and not in a function
  #       but the variable 'PROJECT_USES' is propagated in the exports.
  set(PROJECT_USES ${ARGN})
  # we proceed only if we do have extra arguments
  if(PROJECT_USES)
    list(GET PROJECT_USES 0 el)
    if(NOT el STREQUAL "USE")
      message(FATAL_ERROR "Wrong argument ${el}: expected 'USE'")
    else()
      list(REMOVE_AT PROJECT_USES 0)
      _gaudi_use_other_projects(${PROJECT_USES})
153
154
155
156
157
    endif()
  endif()

  #--- commands required to build cached variable
  # (python scripts are located as such but run through python)
158
  set(binary_paths ${CMAKE_SOURCE_DIR}/GaudiPolicy/scripts ${CMAKE_SOURCE_DIR}/GaudiKernel/scripts ${CMAKE_SOURCE_DIR}/Gaudi/scripts ${binary_paths})
159

160
  find_program(env_cmd env.py PATHS ${binary_paths})
161
162
  set(env_cmd ${PYTHON_EXECUTABLE} ${env_cmd})

163
  find_program(merge_cmd merge_files.py PATHS ${binary_paths})
164
165
  set(merge_cmd ${PYTHON_EXECUTABLE} ${merge_cmd} --no-stamp)

166
  find_program(versheader_cmd createProjVersHeader.py PATHS ${binary_paths})
167
168
  set(versheader_cmd ${PYTHON_EXECUTABLE} ${versheader_cmd})

169
  find_program(genconfuser_cmd genconfuser.py PATHS ${binary_paths})
170
171
  set(genconfuser_cmd ${PYTHON_EXECUTABLE} ${genconfuser_cmd})

172
  find_program(zippythondir_cmd ZipPythonDir.py PATHS ${binary_paths})
173
174
  set(zippythondir_cmd ${PYTHON_EXECUTABLE} ${zippythondir_cmd})

175
  find_program(gaudirun_cmd gaudirun.py PATHS ${binary_paths})
176
177
  set(gaudirun_cmd ${PYTHON_EXECUTABLE} ${gaudirun_cmd})

178
179
  # genconf is special because it must be known before we actually declare the
  # target in GaudiKernel/src/Util (because we need to be dynamic and agnostic).
180
181
182
  if(TARGET genconf)
    get_target_property(genconf_cmd genconf IMPORTED_LOCATION)
  else()
183
184
185
186
187
    if (NOT USE_EXE_SUFFIX)
      set(genconf_cmd ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genconf)
    else()
      set(genconf_cmd ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genconf.exe)
    endif()
188
  endif()
189
  # same as genconf (but it might never be built because it's needed only on WIN32)
190
191
  if(TARGET genwindef)
    get_target_property(genwindef_cmd genwindef IMPORTED_LOCATION)
192
  else()
193
    if (NOT USE_EXE_SUFFIX)
194
      set(genwindef_cmd ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genwindef)
195
    else()
196
      set(genwindef_cmd ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/genwindef.exe)
197
    endif()
198
199
  endif()

200
  #--- Project Installations------------------------------------------------------------------------
201
  install(DIRECTORY cmake/ DESTINATION cmake
202
203
                           FILES_MATCHING PATTERN "*.cmake"
                           PATTERN ".svn" EXCLUDE )
204
  install(PROGRAMS cmake/testwrap.sh cmake/testwrap.csh cmake/testwrap.bat cmake/genCMake.py cmake/env.py DESTINATION scripts OPTIONAL)
205

206
  #--- Global actions for the project
Marco Clemencic's avatar
Marco Clemencic committed
207
  include(GaudiBuildFlags)
208
  gaudi_project_version_header()
209

210
  #--- Collect settings for subdirectories
211
  set(library_path)
212
213
  # Take into account the dependencies between local subdirectories before
  # adding them to the build.
214
  gaudi_sort_subdirectories(packages)
215
  # Add all subdirectories to the project build.
216
  foreach(package ${packages})
217
    message(STATUS "Adding directory ${package}")
218
219
220
    add_subdirectory(${package})
  endforeach()

221
222
223
224
225
226
227
228
229
230
231
232
233
  #--- 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
234
  message(STATUS "Preparing environment configuration:")
235
236
237
238
239
  set(project_environment)

  # - collect environment from externals
  gaudi_external_project_environment()

240
  message(STATUS "  environment for local subdirectories")
241
242
243
244
245
246
  # - 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})
247
    message(STATUS "    ${package}")
248
249
250
251
252
253
254
255
256
257
    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()

258
  message(STATUS "  environment for the project")
259
260
  #   - installation dirs
  set(project_environment ${project_environment}
261
        PREPEND PATH \${${_proj}_PROJECT_ROOT}/InstallArea/${BINARY_TAG}/scripts
262
263
264
265
266
267
        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
268
269
  gaudi_generate_env_conf(${env_xml} ${project_environment})
  install(FILES ${env_xml} DESTINATION .)
270

271
  #--- Generate config files to be imported by other projects.
272
273
274
  gaudi_generate_project_config_version_file()
  gaudi_generate_project_config_file()
  gaudi_generate_project_platform_config_file()
275
  gaudi_generate_exports(${packages})
276

277
  #--- CPack configuration
278
  set(CPACK_PACKAGE_NAME ${project})
279
  foreach(t MAJOR MINOR PATCH)
280
    set(CPACK_PACKAGE_VERSION_${t} ${CMAKE_PROJECT_VERSION_${t}})
281
282
283
284
285
286
287
  endforeach()
  set(CPACK_SYSTEM_NAME ${BINARY_TAG})

  set(CPACK_GENERATOR TGZ)

  include(CPack)

288
289
endmacro()

290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
#-------------------------------------------------------------------------------
# _gaudi_use_other_projects([project version [project version]...])
#
# Internal macro implementing the handline of the "USE" option.
# (improve readability)
#-------------------------------------------------------------------------------
macro(_gaudi_use_other_projects)
  message(STATUS "Looking for projects:")

  # this is neede because of the way variable expansion works in macros
  set(ARGN_ ${ARGN})
  while(ARGN_)
    list(LENGTH ARGN_ len)
    if(len LESS 2)
      message(FATAL_ERROR "Wrong number of arguments to USE option")
    endif()
    list(GET ARGN_ 0 other_project)
    list(GET ARGN_ 1 other_project_version)
    list(REMOVE_AT ARGN_ 0 1)

    string(REGEX MATCH "v?([0-9]+)[r.]([0-9]+)([p.]([0-9]+))?" _version ${other_project_version})

    set(other_project_cmake_version ${CMAKE_MATCH_1}.${CMAKE_MATCH_2})
    if(NOT CMAKE_MATCH_4 STREQUAL "")
      set(other_project_cmake_version ${other_project_cmake_version}.${CMAKE_MATCH_4})
    endif()

    if(NOT ${other_project}_FOUND)
      find_package(${other_project} ${other_project_cmake_version} HINTS ..)
      if(${other_project}_FOUND)
        message(STATUS "  found ${other_project} ${${other_project}_VERSION} ${${other_project}_DIR}")
321
322
323
324
325
326
327
328
329
330
331
332
333
        if(NOT heptools_version STREQUAL ${other_project}_heptools_version)
          if(${other_project}_heptools_version)
            set(hint_message "with the option '-DCMAKE_TOOLCHAIN_FILE=.../heptools-${${other_project}_heptools_version}.cmake'")
          else()
            set(hint_message "without the option '-DCMAKE_TOOLCHAIN_FILE=...'")
          endif()
          message(FATAL_ERROR "Incompatible versions of heptools toolchains:
  ${CMAKE_PROJECT_NAME} -> ${heptools_version}
  ${other_project} ${${other_project}_VERSION} -> ${${other_project}_heptools_version}

  You need to call cmake ${hint_message}
")
        endif()
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
        include_directories(${${other_project}_INCLUDE_DIRS})
        set(binary_paths ${${other_project}_BINARY_PATH})
        foreach(exported ${${other_project}_EXPORTED_SUBDIRS})
          list(FIND known_packages ${exported} is_needed)
          if(is_needed LESS 0)
            list(APPEND known_packages ${exported})
            message(STATUS "    importing ${exported}")
            get_filename_component(exported ${exported} NAME)
            include(${exported}Export)
          endif()
        endforeach()
        if(${other_project}_USES)
          list(INSERT ARGN_ 0 ${${other_project}_USES})
        endif()
      endif()
Marco Clemencic's avatar
Marco Clemencic committed
349
      #message(STATUS "know_packages (after ${other_project}) ${known_packages}")
350
351
352
353
354
    endif()

  endwhile()
endmacro()

355
356
357
358
359
360
#-------------------------------------------------------------------------------
# include_package_directories(Package1 [Package2 ...])
#
# Adde the include directories of each package to the include directories.
#-------------------------------------------------------------------------------
function(include_package_directories)
361
  #message(STATUS "include_package_directories(${ARGN})")
362
  foreach(package ${ARGN})
363
    # we need to ensure that the user can call this function also for directories
364
365
366
367
368
369
370
371
    if(TARGET ${package})
      get_target_property(to_incl ${package} SOURCE_DIR)
      if(to_incl)
        #message(STATUS "include_package_directories2 include_directories(${to_incl})")
        include_directories(${to_incl})
      endif()
    elseif(IS_DIRECTORY ${package})
      #message(STATUS "include_package_directories1 include_directories(${package})")
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
      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
392
        #message(STATUS "include_package_directories3 include_directories(${${to_incl}})")
393
        include_directories(${${to_incl}})
394
395
396
397
398
      endif()
    endif()
  endforeach()
endfunction()

399
400
401
402
403
404
405
#-------------------------------------------------------------------------------
# gaudi_sort_subdirectories
#-------------------------------------------------------------------------------
# NO-OP function used by gaudi_sort_subdirectories
function(require)
endfunction()
# helper macros to collect the required subdirs
406
macro(__visit__ _p)
407
  if(NOT __${_p}_visited__)
408
409
410
411
    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)
412
413
414
415
416
417
418
      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()
419
420
421
      endforeach()
      set(out_packages ${out_packages} ${_p})
    endif()
422
  endif()
423
endmacro()
424
425
# Actual function
function(gaudi_sort_subdirectories var)
426
  set(out_packages)
427
  set(in_packages ${${var}})
428
429
430
431
432
433
  foreach(p ${in_packages})
    __visit__(${p})
  endforeach()
  set(${var} ${out_packages} PARENT_SCOPE)
endfunction()

434
#-------------------------------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
435
436
437
438
# gaudi_get_packages
#
# Find all the CMakeLists.txt files in the sub-directories and add their
# directories to the variable.
439
#-------------------------------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
440
441
function(gaudi_get_packages var)
  set(packages)
442
  file(GLOB_RECURSE cmakelist_files RELATIVE ${CMAKE_SOURCE_DIR} CMakeLists.txt)
Marco Clemencic's avatar
Marco Clemencic committed
443
  foreach(file ${cmakelist_files})
444
445
446
    # ignore the source directory itself
    if(NOT path STREQUAL CMakeLists.txt)
      get_filename_component(package ${file} PATH)
447
448
449
450
      SET(packages ${packages} ${package})
    endif()
  endforeach()
  set(${var} ${packages} PARENT_SCOPE)
451
endfunction()
452

453
454
455
456
457
458
459
460
461
462
#-------------------------------------------------------------------------------
# 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()

463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
#-------------------------------------------------------------------------------
# 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
483
484
485
486
487
488
489
490
    if(TARGET ${package})
      set(collected ${collected} ${package})
      get_target_property(libs ${package} REQUIRED_LIBRARIES)
      if(libs)
        gaudi_resolve_link_libraries(libs ${libs})
        set(collected ${collected} ${libs})
      endif()
    elseif(EXISTS ${package})
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
      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()
512
  list(REMOVE_DUPLICATES collected)
513
514
515
516
  set(${variable} ${collected} PARENT_SCOPE)
endfunction()

#-------------------------------------------------------------------------------
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
# 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).
556
#-------------------------------------------------------------------------------
557
558
559
function(gaudi_merge_files merge_tgt dest filename)
  gaudi_global_target_get_info(Merged${merge_tgt} deps parts)
  if(parts)
560
    # create the targets
561
    set(output ${CMAKE_BINARY_DIR}/${dest}/${filename})
562
    add_custom_command(OUTPUT ${output}
563
                       COMMAND ${merge_cmd} ${parts} ${output}
564
                       DEPENDS ${parts})
565
    add_custom_target(Merged${merge_tgt} ALL DEPENDS ${output})
566
    # prepare the high level dependencies
567
    add_dependencies(Merged${merge_tgt} ${deps})
568
    # install rule for the merged DB
569
    install(FILES ${output} DESTINATION ${dest})
570
571
  endif()
endfunction()
572
573

#---------------------------------------------------------------------------------------------------
574
575
576
577
# gaudi_generate_configurables(library)
#
# Internal function. Add the targets needed to produce the configurables for a
# module (component library).
578
579
580
#
# Note: see gaudi_install_python_modules for a description of how conflicts
#       between the installations of __init__.py are solved.
581
#---------------------------------------------------------------------------------------------------
582
583
584
585
586
587
function(gaudi_generate_configurables library)
  gaudi_get_package_name(package)

  # set(library_preload)  # TODO....

  # Prepare the build directory
588
589
  set(outdir ${CMAKE_CURRENT_BINARY_DIR}/genConf/${package})
  file(MAKE_DIRECTORY ${outdir})
590
591

  # Python classes used for the various component types.
592
593
594
595
596
597
  set(confModuleName GaudiKernel.Proxy)
  set(confDefaultName Configurable.DefaultName)
  set(confAlgorithm ConfigurableAlgorithm)
  set(confAlgTool ConfigurableAlgTool)
  set(confAuditor ConfigurableAuditor)
  set(confService ConfigurableService)
598

599
600
  add_custom_command(
    OUTPUT ${outdir}/${library}_confDb.py ${outdir}/${library}Conf.py ${outdir}/__init__.py
601
    COMMAND ${env_cmd}
602
                  -p ${ld_library_path}=.
603
                  -p ${ld_library_path}=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
604
                  --xml ${env_xml}
605
606
607
608
609
610
611
612
613
614
              ${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)
615
  # Add dependencies on GaudiSvc and the genconf executable if they have to be built in the current project
616
  add_dependencies(${library}Conf genconf GaudiCoreSvc)
617
  # Notify the project level target
618
  gaudi_merge_files_append(ConfDB ${library}Conf ${outdir}/${library}_confDb.py)
619
  #----Installation details-------------------------------------------------------
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
  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})
639
640
641
642
643
644
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)." )
645
646
647
#---------------------------------------------------------------------------------------------------
# gaudi_generate_confuserdb([DEPENDS target1 target2])
#
648
649
650
651
652
# 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.
653
654
#---------------------------------------------------------------------------------------------------
function(gaudi_generate_confuserdb)
655
  gaudi_get_package_name(package)
656
657
658
  get_directory_property(modules CONFIGURABLE_USER_MODULES)
  if( NOT (modules STREQUAL "None") ) # ConfUser enabled
    set(outdir ${CMAKE_CURRENT_BINARY_DIR}/genConf/${package})
659

660
    # get the optional dependencies from argument and properties
661
    CMAKE_PARSE_ARGUMENTS(ARG "" "" "DEPENDS" ${arguments})
662
    get_directory_property(PROPERTY_DEPENDS CONFIGURABLE_USER_DEPENDS)
663
664
665
666

    # TODO: this re-runs the genconfuser every time
    #       we have to force it because we cannot define the dependencies
    #       correctly (on the Python files)
667
668
669
670
671
    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()
672
673
674
675
676
    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
677
                    --xml ${env_xml}
678
                ${genconfuser_cmd}
679
680
681
                  -r ${CMAKE_CURRENT_SOURCE_DIR}/python
                  -o ${outdir}/${package}_user_confDb.py
                  ${package} ${modules})
682
683
    install(FILES ${outdir}/${package}_user_confDb.py
            DESTINATION python/${package})
684
    gaudi_merge_files_append(ConfDB ${package}ConfUserDB ${outdir}/${package}_user_confDb.py)
685
686
687
  endif()
endfunction()

688
#-------------------------------------------------------------------------------
689
# gaudi_get_required_include_dirs(<output> <libraries>)
690
691
692
693
694
695
696
697
698
#
# 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})
699
      list(APPEND collected ${lib})
700
701
702
703
704
705
706
      get_property(req TARGET ${lib} PROPERTY REQUIRED_INCLUDE_DIRS)
      if(req)
        list(APPEND collected ${req})
      endif()
    endif()
  endforeach()
  if(collected)
707
708
709
    set(collected ${collected} ${${output}})
    list(REMOVE_DUPLICATES collected)
    set(${output} ${collected} PARENT_SCOPE)
710
711
712
  endif()
endfunction()

713
#-------------------------------------------------------------------------------
714
# gaudi_get_required_library_dirs(<output> <libraries>)
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
#
# 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
737
738
739
740
741
742
743
744
745
746
#-------------------------------------------------------------------------------
# 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})
747
748
    file(GLOB files src/${fp})
    if(files)
Marco Clemencic's avatar
Marco Clemencic committed
749
      set(${VAR} ${${VAR}} ${files})
750
    else()
Marco Clemencic's avatar
Marco Clemencic committed
751
      set(${VAR} ${${VAR}} ${fp})
752
753
    endif()
  endforeach()
Marco Clemencic's avatar
Marco Clemencic committed
754
755
756
  #message(STATUS "  result: ${${VAR}}")
endmacro()

757
758
759
760
#-------------------------------------------------------------------------------
# gaudi_common_add_build(sources...
#                 LINK_LIBRARIES library1 package2 ...
#                 INCLUDE_DIRS dir1 package2 ...)
Marco Clemencic's avatar
Marco Clemencic committed
761
#
762
763
764
765
# 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
766
  CMAKE_PARSE_ARGUMENTS(ARG "" "" "LIBRARIES;LINK_LIBRARIES;INCLUDE_DIRS" ${ARGN})
767
  # obsolete option
Marco Clemencic's avatar
Marco Clemencic committed
768
769
770
771
772
  if(ARG_LIBRARIES)
    message(WARNING "Deprecated option 'LIBRARY', use 'LINK_LIBRARIES' instead")
    set(ARG_LINK_LIBRARIES ${ARG_LINK_LIBRARIES} ${ARG_LIBRARIES})
  endif()

773
774
  gaudi_resolve_link_libraries(ARG_LINK_LIBRARIES ${ARG_LINK_LIBRARIES})

Marco Clemencic's avatar
Marco Clemencic committed
775
  # find the sources
776
  gaudi_expand_sources(srcs ${ARG_UNPARSED_ARGUMENTS})
777

778
  #message(STATUS "gaudi_common_add_build ${ARG_LINK_LIBRARIES}")
779
  # get the inherited include directories
Marco Clemencic's avatar
Marco Clemencic committed
780
  gaudi_get_required_include_dirs(ARG_INCLUDE_DIRS ${ARG_LINK_LIBRARIES})
781

782
  #message(STATUS "gaudi_common_add_build ${ARG_INCLUDE_DIRS}")
783
  # add the package includes to the current list
Marco Clemencic's avatar
Marco Clemencic committed
784
  include_package_directories(${ARG_INCLUDE_DIRS})
785

786
  #message(STATUS "gaudi_common_add_build ARG_LINK_LIBRARIES ${ARG_LINK_LIBRARIES}")
787
  # get the library dirs required to get the libraries we use
Marco Clemencic's avatar
Marco Clemencic committed
788
  gaudi_get_required_library_dirs(lib_path ${ARG_LINK_LIBRARIES})
789
  set_property(GLOBAL APPEND PROPERTY LIBRARY_PATH ${lib_path})
790
791
792
793
794
795
endmacro()

#---------------------------------------------------------------------------------------------------
# gaudi_add_library(<name>
#                   source1 source2 ...
#                   LINK_LIBRARIES library1 library2 ...
796
797
#                   INCLUDE_DIRS dir1 package2 ...
#                   [NO_PUBLIC_HEADERS | PUBLIC_HEADERS dir1 dir2 ...])
798
799
800
801
802
803
#
# 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)
804
805
806
807
  # 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})

808
  gaudi_get_package_name(package)
809
  if(NOT ARG_NO_PUBLIC_HEADERS AND NOT ARG_PUBLIC_HEADERS)
810
    message(WARNING "Library ${library} (in ${package}) does not declare PUBLIC_HEADERS. Use the option NO_PUBLIC_HEADERS if it is intended.")
811
  endif()
812

813
  if(WIN32)
814
	add_library( ${library}-arc STATIC EXCLUDE_FROM_ALL ${srcs})
815
    set_target_properties(${library}-arc PROPERTIES COMPILE_DEFINITIONS GAUDI_LINKER_LIBRARY)
816
817
    add_custom_command(
      OUTPUT ${library}.def
818
	  COMMAND ${genwindef_cmd} -o ${library}.def -l ${library} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${library}-arc.lib
819
820
821
822
	  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
823
824
    target_link_libraries(${library} ${library}-arc ${ARG_LINK_LIBRARIES})
    set_target_properties(${library} PROPERTIES LINK_INTERFACE_LIBRARIES "${ARG_LINK_LIBRARIES}" )
825
  else()
826
    add_library(${library} ${srcs})
827
    set_target_properties(${library} PROPERTIES COMPILE_DEFINITIONS GAUDI_LINKER_LIBRARY)
Marco Clemencic's avatar
Marco Clemencic committed
828
    target_link_libraries(${library} ${ARG_LINK_LIBRARIES})
829
  endif()
830
831

  # Declare that the used headers are needed by the libraries linked against this one
832
833
834
835
  set_target_properties(${library} PROPERTIES
    SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
    REQUIRED_INCLUDE_DIRS "${ARG_INCLUDE_DIRS}"
    REQUIRED_LIBRARIES "${ARG_LINK_LIBRARIES}")
836
  set_property(GLOBAL APPEND PROPERTY LINKER_LIBRARIES ${library})
837

838
839
840
841
  if(TARGET ${library}Obj2doth)
    add_dependencies( ${library} ${library}Obj2doth)
  endif()
  #----Installation details-------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
842
  install(TARGETS ${library} EXPORT ${CMAKE_PROJECT_NAME}Exports DESTINATION  ${lib})
843
  gaudi_export(LIBRARY ${library})
844
  gaudi_install_headers(${ARG_PUBLIC_HEADERS})
Marco Clemencic's avatar
Marco Clemencic committed
845
  install(EXPORT ${CMAKE_PROJECT_NAME}Exports DESTINATION cmake)
846
847
endfunction()

Marco Clemencic's avatar
Marco Clemencic committed
848
849
850
851
852
853
# Backward compatibility macro
macro(gaudi_linker_library)
  message(WARNING "Deprecated function 'gaudi_linker_library', use 'gaudi_add_library' instead")
  gaudi_add_library(${ARGN})
endmacro()

854
#---------------------------------------------------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
855
#---gaudi_add_module(<name> source1 source2 ... LINK_LIBRARIES library1 library2 ...)
856
#---------------------------------------------------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
857
function(gaudi_add_module library)
858
  gaudi_common_add_build(${ARGN})
859

860
  add_library(${library} MODULE ${srcs})
861
  target_link_libraries(${library} ${ROOT_Reflex_LIBRARY} ${ARG_LINK_LIBRARIES})
862

863
  gaudi_generate_rootmap(${library})
864
  gaudi_generate_configurables(${library})
865

866
867
  set_property(GLOBAL APPEND PROPERTY COMPONENT_LIBRARIES ${library})

868
869
870
871
  #----Installation details-------------------------------------------------------
  install(TARGETS ${library} LIBRARY DESTINATION ${lib})
endfunction()

Marco Clemencic's avatar
Marco Clemencic committed
872
873
874
875
876
# Backward compatibility macro
macro(gaudi_component_library)
  message(WARNING "Deprecated function 'gaudi_component_library', use 'gaudi_add_module' instead")
  gaudi_add_module(${ARGN})
endmacro()
877

878
#-------------------------------------------------------------------------------
879
880
881
882
# gaudi_add_dictionary(dictionary header selection
#                      LINK_LIBRARIES ...
#                      INCLUDE_DIRS ...
#                      OPTIONS ...)
883
884
885
886
887
#
# Find all the CMakeLists.txt files in the sub-directories and add their
# directories to the variable.
#-------------------------------------------------------------------------------
function(gaudi_add_dictionary dictionary header selection)
888
889
890
  # 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})
891
892
893
894
895

  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)
896
  gaudi_merge_files_append(DictRootmap ${dictionary}Gen ${CMAKE_CURRENT_BINARY_DIR}/${rootmapname})
897
898
899
900
901

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

902
#---------------------------------------------------------------------------------------------------
903
904
905
906
907
908
# gaudi_add_python_module(name
#                         sources ...
#                         LINK_LIBRARIES ...
#                         INCLUDE_DIRS ...)
#
# Build a binary python module from the given sources.
909
#---------------------------------------------------------------------------------------------------
910
function(gaudi_add_python_module module)
911
  gaudi_common_add_build(${ARGN})
912

913
914
915
916
  # require Python libraries
  find_package(PythonLibs QUIET REQUIRED)

  add_library(${module} MODULE ${srcs})
917
  if(win32)
918
    set_target_properties(${module} PROPERTIES SUFFIX .pyd PREFIX "")
919
  else()
920
    set_target_properties(${module} PROPERTIES SUFFIX .so PREFIX "")
921
  endif()
Marco Clemencic's avatar
Marco Clemencic committed
922
  target_link_libraries(${module} ${PYTHON_LIBRARIES} ${ARG_LINK_LIBRARIES})
923

924
925
926
927
928
  #----Installation details-------------------------------------------------------
  install(TARGETS ${module} LIBRARY DESTINATION python/lib-dynload)
endfunction()

#---------------------------------------------------------------------------------------------------
929
930
931
932
933
934
935
936
# 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.
937
#---------------------------------------------------------------------------------------------------
938
function(gaudi_add_executable executable)
939
  gaudi_common_add_build(${ARGN})
940

941
  add_executable(${executable} ${srcs})
942
  target_link_libraries(${executable} ${ARG_LINK_LIBRARIES})
943

944
945
946
  if (USE_EXE_SUFFIX)
    set_target_properties(${executable} PROPERTIES SUFFIX .exe)
  endif()
947

948
  #----Installation details-------------------------------------------------------
Marco Clemencic's avatar
Marco Clemencic committed
949
950
  install(TARGETS ${executable} EXPORT ${CMAKE_PROJECT_NAME}Exports RUNTIME DESTINATION ${bin})
  install(EXPORT ${CMAKE_PROJECT_NAME}Exports DESTINATION cmake)
951
  gaudi_export(EXECUTABLE ${executable})
Marco Clemencic's avatar
Marco Clemencic committed
952

953
954
955
endfunction()

#---------------------------------------------------------------------------------------------------
956
957
958
959
960
961
962
# 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.
963
#---------------------------------------------------------------------------------------------------
964
function(gaudi_add_unit_test executable)
965
  if(BUILD_TESTS)
966
967
968
969
970
971
972
973
    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)

974
975
    gaudi_get_package_name(package)

976
    get_target_property(exec_suffix ${executable} SUFFIX)
977
978
979
980
981
982
983
984
    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}
985
                 --xml ${env_xml}
986
               ${executable}${exec_suffix})
987
988
989
  endif()
endfunction()

990
991
992
993
994
995
996
997
998
999
1000
#-------------------------------------------------------------------------------
# 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)

For faster browsing, not all history is shown. View entire blame