Fixed install target
[u/mrichter/AliRoot.git] / cmake / ALICE_CMake.cmake
index 9424bef..996f60e 100644 (file)
@@ -327,7 +327,6 @@ macro(ALICE_BuildPackage)
       message(STATUS "No dictionary generated for ${PACKAGE}")  
     endif(lib)
   endif(WITHDICT)
-  
   if(PS OR PCS OR PFS)
     if(lib)
       ALICE_BuildLibrary()
@@ -335,6 +334,8 @@ macro(ALICE_BuildPackage)
       ALICE_BuildExecutable()
     endif(lib)
   endif(PS OR PCS OR PFS)
+  ALICE_BuildPAR()
+  ALICE_CheckModule()
 
 endmacro(ALICE_BuildPackage)
 
@@ -359,9 +360,9 @@ macro(ALICE_BuildModule)
       get_property(EXCLUDEPACKAGE TARGET ${PACKAGE} PROPERTY EXCLUDE_FROM_ALL) 
       if(NOT EXCLUDEPACKAGE)
         install(TARGETS ${PACKAGE} 
-                RUNTIME DESTINATION bin
-                LIBRARY DESTINATION lib
-                ARCHIVE DESTINATION bin)
+                RUNTIME DESTINATION bin/tgt_${ALICE_TARGET}
+                LIBRARY DESTINATION lib/tgt_${ALICE_TARGET}
+                ARCHIVE DESTINATION bin/tgt_${ALICE_TARGET})
       endif(NOT EXCLUDEPACKAGE)
   endforeach(PACKAGEFILE)
 
@@ -429,6 +430,7 @@ macro(ALICE_BuildLibrary)
   include_directories(${CMAKE_INCLUDE_EXPORT_DIRECTORY})
   
   add_library(${PACKAGE} SHARED ${PCS} ${PFS} ${PS} ${PDS})
+  set_target_properties(${PACKAGE} PROPERTIES SUFFIX .so)  
   
 
   if(PELIBS OR SHLIB)
@@ -500,7 +502,7 @@ macro(ALICE_BuildExecutable)
 
 # AliMDC
 # ------------------------------
-  if(PACKAGE STREQUAL "alimdc")
+  if(PACKAGE STREQUAL "alimdc" AND GENERATEPACKAGES)
 
     add_executable(${PACKAGE}-static ${PFS} ${PCS} ${PS} ${PDS})
     set_target_properties(${PACKAGE}-static PROPERTIES OUTPUT_NAME alimdca)
@@ -508,15 +510,35 @@ macro(ALICE_BuildExecutable)
                         COMMAND rm -rf ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libAliMDC.a
                        COMMAND rm -rf junkmdc
                        COMMAND mkdir junkmdc && cd junkmdc && ar x ../libRAWDatabase.a && ar x ../libMDC.a && ar x ../libESD.a && ar x ../libSTEERBase.a && ar r ../libAliMDC.a *.o && cd .. && rm -rf junkmdc
-                       DEPENDS 
                        WORKING_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
+    add_custom_target( root-static-libs 
+                       COMMAND make static
+                      WORKING_DIRECTORY ${ROOTSYS} )
+                      
     add_dependencies(libAliMDC RAWDatabase-static STEERBase-static MDC-static ESD-static)
-    add_dependencies(${PACKAGE}-static libAliMDC)
+    add_dependencies(${PACKAGE}-static libAliMDC root-static-libs)
     target_link_libraries(${PACKAGE}-static ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libAliMDC.a ${ROOTLIBDIR}/libRoot.a ${ROOTLIBDIR}/libfreetype.a ${ROOTLIBDIR}/libpcre.a -pthread -ldl -lcurses)
-                       
-
 
-  endif(PACKAGE STREQUAL "alimdc")
+    install(TARGETS ${PACKAGE}-static RUNTIME DESTINATION bin/tgt_${ALICE_TARGET} COMPONENT MDC)
+    install(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libAliMDC.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libAliMDC.a ${ROOTLIBDIR}/libRoot.a ${ROOTLIBDIR}/libfreetype.a ${ROOTLIBDIR}/libpcre.a DESTINATION lib/tgt_${ALICE_TARGET} COMPONENT MDC)
+    install(FILES ${PROJECT_SOURCE_DIR}/RAW/mdc.h DESTINATION include COMPONENT MDC)
+    set(CPACK_RPM_PACKAGE_SUMMARY "AliMDC static libraries")
+    set(CPACK_RPM_PACKAGE_NAME "alimdc")
+    set(CPACK_RPM_PACKAGE_VERSION "${ALIMDCVERSION}")
+    set(CPACK_RPM_PACKAGE_RELEASE "${ALIMDCRELEASE}")
+    set(CPACK_RPM_PACKAGE_LICENSE "Copyright: CERN ALICE Off-line Group")
+    set(CPACK_RPM_PACKAGE_VENDOR "ALICE Core Off-line Group")
+    set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "AliMDC static libraries")
+    set(CPACK_RPM_PACKAGE_GROUP "Applications/Alice")
+    set(CPACK_RPM_PACKAGE_REQUIRES "glibc")
+    set(CPACK_PACKAGE_VERSION "1.0.0")
+    set(CPACK_PACKAGE_VERSION_MAJOR "1")
+    set(CPACK_PACKAGE_VERSION_MINOR "0")
+    set(CPACK_PACKAGE_VERSION_PATCH "0")
+    set(CPACK_PACKAGE_INSTALL_DIRECTORY "/opt/")
+    add_component_package(MDC alimdc-rpm)
+
+  endif(PACKAGE STREQUAL "alimdc" AND GENERATEPACKAGES)
 
   list(FIND EXCLUDEMODULES ${MODULE} RESULT)
   if(NOT RESULT STREQUAL "-1")
@@ -554,3 +576,45 @@ macro(ALICE_GenerateLinkDef)
   endforeach(class)
   file (APPEND ${PDAL} "#endif\n")
 endmacro(ALICE_GenerateLinkDef)
+
+macro(ALICE_BuildPAR)
+  if(EXISTS ${ALICE_ROOT}/${MODULE}/PROOF-INF.${PACKAGE})
+    set(PARSRCS)
+    foreach(file ${SRCS} ${HDRS} ${FSRCS} ${DHDR})
+      get_filename_component(srcdir ${file} PATH)
+      add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${file}-par                         
+                         COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${srcdir}
+                         COMMAND cp -pR ${file} ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${file}
+                         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
+      list(APPEND PARSRCS ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/${file}-par)
+    endforeach(file ${SRCS} ${HDRS} ${FSRCS} ${DHDR})
+    
+    add_custom_target(${PACKAGE}.par
+                      COMMAND sed -e 's/include .\(ROOTSYS\)\\/test\\/Makefile.arch/include Makefile.arch/\; s/PACKAGE = .*/PACKAGE = ${PACKAGE}/' < Makefile > ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/Makefile
+                      COMMAND cp -pR ${ROOTSYS}/test/Makefile.arch ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/Makefile.arch
+                      COMMAND cp -pR PROOF-INF.${PACKAGE} ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}/PROOF-INF
+                      COMMAND cp -pR lib${PACKAGE}.pkg ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}
+                      COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_BINARY_DIR} tar --exclude=.svn -czhf ${CMAKE_BINARY_DIR}/${PACKAGE}.par ${PACKAGE}
+                      COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE}
+                      COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "${PACKAGE}.par has been created in ${CMAKE_BINARY_DIR}"
+                      DEPENDS ${PARSRCS} 
+                      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
+
+
+    add_dependencies(par-all ${PACKAGE}.par)
+    add_dependencies(${MODULE}-par-all ${PACKAGE}.par)
+
+    add_custom_target(test-${PACKAGE}.par
+                      COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red --bold "The file ${PACKAGE}.par is now being tested, in case of an error check in par-tmp/${PACKAGE}."
+                      COMMAND ${CMAKE_COMMAND} -E make_directory par-tmp
+                      COMMAND ${CMAKE_COMMAND} -E chdir par-tmp tar xfz ../${PACKAGE}.par && ${CMAKE_COMMAND} -E chdir par-tmp/${PACKAGE} PROOF-INF/BUILD.sh
+                      COMMAND ${CMAKE_COMMAND} -E remove_directory par-tmp
+                      COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --green --bold "${PACKAGE}.par testing succeeded"
+                      WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
+
+    add_dependencies(test-par-all test-${PACKAGE}.par)
+    add_dependencies(test-${MODULE}-par-all test-${PACKAGE}.par)
+
+  endif(EXISTS ${ALICE_ROOT}/${MODULE}/PROOF-INF.${PACKAGE})
+endmacro(ALICE_BuildPAR)
+