File: ClhepBuildTest.cmake

package info (click to toggle)
clhep 2.1.4.1%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,012 kB
  • sloc: cpp: 50,094; sh: 6,694; makefile: 2,694; perl: 28
file content (71 lines) | stat: -rw-r--r-- 2,579 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Create the tests
#
# clhep_test( testname 
#                [LIBS] <library_list>
#                [DEPENDS] <another_testname>
#                [SIMPLE] - this test does not require a shell script
#                [FAIL] - test is epected to fail
#                [NOLIB] - no library dependencies
#            )
# testname is the base name of the .cc file
#
# if the test requires running a shell script:
#   clhep_test( testname )
# testname is the base name of the .cc and .sh.in file
#
include(ClhepParseArgs)


macro( clhep_test testname )
  clhep_parse_args( CTST "LIBS;DEPENDS" "SIMPLE;FAIL;NOLIB" ${ARGN})

  # automake/autoconf variables for ${testname}.sh.in 
  set(srcdir ${CMAKE_CURRENT_SOURCE_DIR})
  set(builddir ${CMAKE_CURRENT_BINARY_DIR})

  if( CTST_NOLIB )
    set(package_library_list)
  else()
    set( package_library_list ${PACKAGE}S)
    #set( package_library_list ${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}CLHEP-${PACKAGE}-${VERSION}${CMAKE_STATIC_LIBRARY_SUFFIX} )
  endif()

  if( ${PACKAGE}_DEPS )
     foreach ( dep ${${PACKAGE}_DEPS} )
        ##message( STATUS "clhep_test ${testname} will use ${dep}")
	list(APPEND package_library_list ${PACKAGE}S)
	#list(APPEND package_library_list  ${PROJECT_BINARY_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}CLHEP-${dep}-${VERSION}${CMAKE_STATIC_LIBRARY_SUFFIX} )
     endforeach()
  endif()

  link_libraries( ${package_library_list} )
  ##message( STATUS "building ${testname} from ${CMAKE_CURRENT_SOURCE_DIR} in ${CMAKE_CURRENT_BINARY_DIR}" )

  ADD_EXECUTABLE(${testname} ${testname}.cc)

  if( CTST_SIMPLE )
    add_test( ${testname} ${CMAKE_CURRENT_BINARY_DIR}/${testname} )
    if( CTST_FAIL )
      set_tests_properties( ${testname} PROPERTIES WILL_FAIL TRUE )
    endif()
    if( CTST_DEPENDS )
      set_tests_properties( ${testname} PROPERTIES DEPENDS ${CTST_DEPENDS} )
      #message(STATUS "clhep_test: ${testname} depends on ${CTST_DEPENDS}")
    endif( CTST_DEPENDS )
  else()
    if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
      message( STATUS "skipping ${testname}.sh on ${CMAKE_SYSTEM_NAME}")
    else()
      configure_file( ${testname}.sh.in 
                      ${CMAKE_CURRENT_BINARY_DIR}/${testname}.sh  @ONLY )
      add_test( ${testname}.sh ${CMAKE_CURRENT_BINARY_DIR}/${testname}.sh )
      if( CTST_FAIL )
        set_tests_properties( ${testname}.sh PROPERTIES WILL_FAIL TRUE )
      endif()
      if( CTST_DEPENDS )
	add_custom_target(check COMMAND ${testname} DEPENDS ${CTST_DEPENDS} )
      endif( CTST_DEPENDS )
    endif()
  endif()
  
endmacro( clhep_test )