Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkSetupCPack.cmake
Go to the documentation of this file.
1 #
2 # First, set the generator variable
3 #
4 if(NOT CPACK_GENERATOR)
5  if(WIN32)
6  find_program(NSIS_MAKENSIS NAMES makensis
7  PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]
8  DOC "Where is makensis.exe located"
9  )
10 
11  if(NOT NSIS_MAKENSIS)
12  set(CPACK_GENERATOR ZIP)
13  else()
14  set(CPACK_GENERATOR "NSIS;ZIP")
15 
16  endif(NOT NSIS_MAKENSIS)
17  else()
18  if(APPLE)
19  set(CPACK_GENERATOR DragNDrop)
20  else()
21  set(CPACK_GENERATOR TGZ)
22  endif()
23  endif()
24 endif(NOT CPACK_GENERATOR)
25 
26 # Set Redistributable information for windows
27 if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
30  set(CPACK_VISUAL_STUDIO_VERSION_MAJOR "${VISUAL_STUDIO_VERSION_MAJOR}")
31  set(CPACK_VISUAL_STUDIO_PRODUCT_NAME "${VISUAL_STUDIO_PRODUCT_NAME}")
32  set(CPACK_LIBRARY_ARCHITECTURE "${CMAKE_LIBRARY_ARCHITECTURE}")
33 
34  # Visual Studio 2017 already comes with redistributable installers.
35  # Try to find the right one.
36 
37  set(vswhere "$ENV{PROGRAMFILES\(X86\)}\\Microsoft Visual Studio\\Installer\\vswhere.exe")
38 
39  if(EXISTS ${vswhere})
40  execute_process(COMMAND ${vswhere} -latest -property installationPath
41  OUTPUT_VARIABLE installationPath
42  OUTPUT_STRIP_TRAILING_WHITESPACE)
43  file(TO_CMAKE_PATH "${installationPath}" installationPath)
44  set(redistPath "${installationPath}/VC/Redist/MSVC")
45  file(GLOB redistPath "${installationPath}/VC/Redist/MSVC/*")
46  list(LENGTH redistPath length)
47  if(length EQUAL 1)
48  if(CMAKE_SIZEOF_VOID_P EQUAL 8)
49  set(redistPath "${redistPath}/vc_redist.x64.exe")
50  else()
51  set(redistPath "${redistPath}/vc_redist.x86.exe")
52  endif()
53  if(EXISTS ${redistPath})
54  set(CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE ${redistPath} CACHE FILEPATH "Path to the appropriate Microsoft Visual Studio Redistributable")
55  endif()
56  endif()
57  endif()
58 
59  if(NOT DEFINED CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE)
60  set(CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE "" CACHE FILEPATH "Path to the appropriate Microsoft Visual Studio Redistributable")
61  endif()
62 endif()
63 
64 if(EXISTS ${CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE} )
65  install(PROGRAMS ${CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE}
66  DESTINATION thirdpartyinstallers)
67 
68  get_filename_component(CPACK_REDISTRIBUTABLE_FILE_NAME ${CMAKE_${CPACK_VISUAL_STUDIO_PRODUCT_NAME}_REDISTRIBUTABLE} NAME )
69 endif()
70 
71 # On windows set default install directory appropriately for 32 and 64 bit
72 # installers if not already set
73 if(WIN32 AND NOT CPACK_NSIS_INSTALL_ROOT)
74  if(CMAKE_CL_64)
75  set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES64")
76  else()
77  set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
78  endif()
79 endif()
80 
81 # By default, do not warn when built on machines using only VS Express
82 if(NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS)
83  set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
84 endif()
85 
86 # include required mfc libraries
87 include(InstallRequiredSystemLibraries)
88 
89 set(CPACK_PACKAGE_NAME "MITK")
90 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Medical Imaging Interaction Toolkit")
91 set(CPACK_PACKAGE_VENDOR "German Cancer Research Center (DKFZ)")
92 set(CPACK_PACKAGE_DESCRIPTION_FILE "${MITK_SOURCE_DIR}/LICENSE")
93 set(CPACK_RESOURCE_FILE_LICENSE "${MITK_SOURCE_DIR}/LICENSE")
94 
95 set(CPACK_PACKAGE_VERSION_MAJOR ${MITK_REVISION_DESC})
96 string(REPLACE " [local changes]" "-local_changes" CPACK_PACKAGE_VERSION_MAJOR "${CPACK_PACKAGE_VERSION_MAJOR}")
97 
98 # tell cpack to strip all debug symbols from all files
99 set(CPACK_STRIP_FILES ON)
100 
101 # set version
102 if(NOT CPACK_PACKAGE_VERSION_MAJOR)
103  set(CPACK_PACKAGE_VERSION_MAJOR ${MITK_VERSION_MAJOR})
104  set(CPACK_PACKAGE_VERSION_MINOR ${MITK_VERSION_MINOR})
105  set(CPACK_PACKAGE_VERSION_PATCH ${MITK_VERSION_PATCH})
106  set(CPACK_PACKAGE_VERSION "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}")
107 else()
108  set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR})
109 endif()
110 
111 # determine possible system specific extension
112 set(CPACK_PACKAGE_ARCH "unkown-architecture")
113 
114 if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
115  if(CMAKE_CL_64)
116  set(CPACK_PACKAGE_ARCH "windows-x86_64")
117  elseif(WIN32)
118  set(CPACK_PACKAGE_ARCH "windows-x86")
119  endif()
120 endif()
121 
122 if(${CMAKE_SYSTEM_NAME} MATCHES Linux)
123  if(${CMAKE_SYSTEM_PROCESSOR} MATCHES i686)
124  set(CPACK_PACKAGE_ARCH "linux-x86")
125  elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES x86_64)
126  if(${CMAKE_CXX_FLAGS} MATCHES " -m32 ")
127  set(CPACK_PACKAGE_ARCH "linux-x86")
128  else()
129  set(CPACK_PACKAGE_ARCH "linux-x86_64")
130  endif()
131  else()
132  set(CPACK_PACKAGE_ARCH "linux")
133  endif()
134 endif()
135 
136 if(${CMAKE_SYSTEM_NAME} MATCHES Darwin)
137  set(CPACK_PACKAGE_ARCH "macos-x86_64")
138 endif()
139 
140 set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_ARCH}")
141 
142 
143 
mitkFunctionGetMSVCVersion()