ClhepBuildLibrary.cmake 3.34 KB
Newer Older
Lynn Garren's avatar
Lynn Garren committed
1
# Build package libraries.
2
# Build the main CLHEP source code list as we go.
3
4
5
#
# Recommended use:
# clhep_build_library( <package> <source code files> )
Lynn Garren's avatar
Lynn Garren committed
6
# 
7
8

macro (clhep_build_library package )
9
10
  set ( CLHEP_${package}_SOURCES ${ARGN} )
  # build up the source list for CLHEP
Lynn Garren's avatar
Lynn Garren committed
11
12
13
14
15
16
17
  set( CLHEP_${package}_list CACHE INTERNAL "${package} sources" FORCE )
  foreach( file ${ARGN} )
    set( CLHEP_${package}_list ${CLHEP_${package}_list} ${CMAKE_CURRENT_SOURCE_DIR}/${file}
                             CACHE INTERNAL "${package} sources" )
  endforeach(file)
  ##message( STATUS "in ${package}, clheplib source list ${CLHEP_${package}_list}" )
  # check for dependencies
18
19
20
  set ( package_library_list )
  if( ${PACKAGE}_DEPS )
     foreach ( dep ${${PACKAGE}_DEPS} )
Lynn Garren's avatar
Lynn Garren committed
21
        ##message( STATUS "clhep_build_library ${package} will use ${dep}")
22
23
24
	list(APPEND package_library_list ${dep} )
     endforeach()
  endif()
25
26
  ADD_LIBRARY (${package}  SHARED ${CLHEP_${package}_SOURCES})
  ADD_LIBRARY (${package}S STATIC ${CLHEP_${package}_SOURCES})
27
  SET_TARGET_PROPERTIES (${package}
Lynn Garren's avatar
Lynn Garren committed
28
      PROPERTIES OUTPUT_NAME CLHEP-${package}-${VERSION}
29
30
      )
  SET_TARGET_PROPERTIES (${package}S
Lynn Garren's avatar
Lynn Garren committed
31
      PROPERTIES OUTPUT_NAME CLHEP-${package}-${VERSION}
32
33
34
35
36
37
38
39
40
41
42
43
      )
  SET_TARGET_PROPERTIES(${package}  PROPERTIES CLEAN_DIRECT_OUTPUT 1)
  SET_TARGET_PROPERTIES(${package}S PROPERTIES CLEAN_DIRECT_OUTPUT 1)
  target_link_libraries(${package}  ${package_library_list} )
  target_link_libraries(${package}S ${package_library_list} )

  INSTALL (TARGETS ${package} ${package}S
      RUNTIME DESTINATION bin
      LIBRARY DESTINATION lib
      ARCHIVE DESTINATION lib
      ) 
endmacro (clhep_build_library)
Lynn Garren's avatar
Lynn Garren committed
44
45
46
47

macro (clhep_build_libclhep )
  foreach( pkg ${ARGN} )
     ##message( STATUS "${pkg} sources are ${CLHEP_${pkg}_list}" )
48
     list(APPEND CLHEP_DEPS ${LIBRARY_OUTPUT_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}CLHEP-${pkg}-${VERSION}${CMAKE_STATIC_LIBRARY_SUFFIX} )
Lynn Garren's avatar
Lynn Garren committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
     list(APPEND clhep_sources ${CLHEP_${pkg}_list} )
  endforeach()
  ##message( STATUS "clheplib source list ${clhep_sources}" )
  ADD_LIBRARY (CLHEP  SHARED ${clhep_sources})
  ADD_LIBRARY (CLHEPS STATIC ${clhep_sources})
  SET_TARGET_PROPERTIES (CLHEP
      PROPERTIES OUTPUT_NAME CLHEP-${VERSION}
                 CLEAN_DIRECT_OUTPUT 1
      )
  SET_TARGET_PROPERTIES (CLHEPS
      PROPERTIES OUTPUT_NAME CLHEP-${VERSION}
                 CLEAN_DIRECT_OUTPUT 1
      )

  INSTALL (TARGETS CLHEP CLHEPS
      RUNTIME DESTINATION bin
      LIBRARY DESTINATION lib
      ARCHIVE DESTINATION lib
      ) 
68
69
70
71
72
73
74
75
76

  # create the symbolic links
  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/clhep_static_symlink 
             "exec_program(${CMAKE_COMMAND} ARGS -E chdir ${CMAKE_INSTALL_PREFIX}/lib; ${CMAKE_COMMAND} ARGS -E create_symlink ${CMAKE_STATIC_LIBRARY_PREFIX}CLHEP-${VERSION}${CMAKE_STATIC_LIBRARY_SUFFIX} ${CMAKE_STATIC_LIBRARY_PREFIX}CLHEP${CMAKE_STATIC_LIBRARY_SUFFIX} )" )
  INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/clhep_static_symlink )
  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/clhep_shared_symlink 
             "exec_program(${CMAKE_COMMAND} ARGS -E chdir ${CMAKE_INSTALL_PREFIX}/lib; ${CMAKE_COMMAND} ARGS -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}CLHEP-${VERSION}${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_SHARED_LIBRARY_PREFIX}CLHEP${CMAKE_SHARED_LIBRARY_SUFFIX} )" )
  INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/clhep_shared_symlink )

Lynn Garren's avatar
Lynn Garren committed
77
endmacro (clhep_build_libclhep )