"Fossies" - the Fresh Open Source Software Archive

Member "VeraCrypt_1.24-Update6/src/Build/CMakeLists.txt" (11 Mar 2020, 14237 Bytes) of package /linux/misc/VeraCrypt_1.24-Update6.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 1.24-Update5_vs_1.24-Update6.

    1 # - Minimum CMake version
    2 cmake_minimum_required(VERSION 2.8.0)
    3 
    4 # - Obligatory parameters
    5 #		-DVERACRYPT_BUILD_DIR 	: folder that contains 'usr' folder
    6 #		-DNOGUI					: TRUE if building 'Console' version, 'FALSE' if building 'GUI' version
    7 if ( NOT DEFINED VERACRYPT_BUILD_DIR )
    8 	MESSAGE(FATAL_ERROR "VERACRYPT_BUILD_DIR variable MUST BE set to the path of the folder which contains 'usr' folder")
    9 elseif ( NOT DEFINED NOGUI )
   10 	MESSAGE(FATAL_ERROR "NOGUI variable MUST BE set to TRUE if building 'Console' version, 'FALSE' otherwise")
   11 endif()
   12 
   13 # - Set version of the package
   14 set( FULL_VERSION 		"1.24-Update6" )
   15 set( VERSION 			"1.24.15" )
   16 set( RELEASE 			"1" )
   17 
   18 # - Set PROJECT_NAME and CONFLICT_PACKAGE values
   19 if (NOGUI)
   20 	set( PROJECT_NAME 		"veracrypt-console" )
   21 	set( CONFLICT_PACKAGE	"veracrypt" )
   22 else()
   23 	set( PROJECT_NAME 		"veracrypt" )
   24 	set( CONFLICT_PACKAGE	"veracrypt-console" )
   25 endif()
   26 project(${PROJECT_NAME})
   27 
   28 # - Check whether 'Tcdefs.h' and 'License.txt' exist
   29 if(NOT EXISTS "$ENV{SOURCEPATH}/Common/Tcdefs.h")
   30 	MESSAGE(FATAL_ERROR "Tcdefs.h does not exist.")
   31 elseif(NOT EXISTS "$ENV{SOURCEPATH}/License.txt")
   32 	MESSAGE(FATAL_ERROR "License.txt does not exist.")
   33 endif()
   34 
   35 # - Detect build system bitness
   36 #	The following variable will be set
   37 #		$SUFFIX					32			64
   38 #		$CMAKE_SYSTEM_NAME		Windows		Linux	Darwin
   39 # 	N.B : 
   40 #		To build for 32-bit under 64-bit, set 'CMAKE_SIZEOF_VOID_P' to '4'
   41 if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
   42 
   43 	#	Build System is under 64-bit arch
   44 	set (SUFFIX "64")
   45 	MESSAGE(STATUS "Build System = ${CMAKE_SYSTEM_NAME} - Bitness : 64-bit - Compiler : ${CMAKE_CXX_COMPILER_ID}")
   46 	
   47 elseif( CMAKE_SIZEOF_VOID_P EQUAL 4 )
   48 
   49 	#	Build System is under 32-bit arch
   50 	set (SUFFIX "32")
   51 	MESSAGE(STATUS "Build System = ${CMAKE_SYSTEM_NAME} - Bitness : 32-bit - Compiler : ${CMAKE_CXX_COMPILER_ID}")
   52 	
   53 else( )
   54 
   55 	MESSAGE(FATAL_ERROR "Could not detect system bitness")
   56 	
   57 endif( )
   58 
   59 # - Detect OSX, CentOS, Debian, Ubuntu or openSUSE platform of the build system
   60 #   The following variable(s) will be set
   61 #   	$PLATFORM						Debian		Ubuntu 		CentOS		openSUSE (TODO)
   62 #   	$PLATFORM_VERSION	
   63 #										9.x 		16.04		7.X			42.3
   64 #										10.X		18.04		8.X			15.0
   65 #										...			...			...			...
   66 # 		$DISTRO_NAME					${PLATFORM}-${PLATFORM_VERSION}
   67 if ( UNIX )
   68 
   69 	# /etc/debian_version exists for both Debian and Ubuntu
   70 	if(EXISTS "/etc/debian_version")
   71 	
   72 		set ( PLATFORM "Debian" )
   73 	
   74 		# Read lsb-release to get flavour name and flavour release version (only supported one for now is Ubuntu)
   75 		if(EXISTS "/etc/lsb-release")		
   76 			
   77 			file(READ "/etc/lsb-release" LSB_RELEASE_ID)
   78 			string(REGEX MATCH "DISTRIB_ID=([a-zA-Z0-9 /\\.]+)" _ ${LSB_RELEASE_ID})
   79 			set(FULL_FLAVOUR ${CMAKE_MATCH_1})
   80 			
   81 			if (FULL_FLAVOUR MATCHES "^.*Ubuntu.*$")
   82 			
   83 				set ( PLATFORM "Ubuntu" )
   84 			
   85 				file(READ "/etc/lsb-release" UBUNTU_RELEASE)
   86 				string(REGEX MATCH "DISTRIB_RELEASE=([0-9 /\\.]+)" _ ${UBUNTU_RELEASE})
   87 				set(PLATFORM_VERSION ${CMAKE_MATCH_1})
   88 				
   89 			else()
   90 			
   91 				file(READ "/etc/debian_version" DEBIAN_RELEASE)
   92 				string(REGEX MATCH "([0-9]+\\.[0-9]+)" _ ${DEBIAN_RELEASE})
   93 				set(PLATFORM_VERSION ${CMAKE_MATCH_1})
   94 				
   95 			endif()
   96 			
   97 		# Get debian release version
   98 		elseif(EXISTS "/etc/debian_version")
   99 			
  100 			file(READ "/etc/debian_version" DEBIAN_RELEASE)
  101 			string(REGEX MATCH "([0-9]+\\.[0-9]+)" _ ${DEBIAN_RELEASE})
  102 			set(PLATFORM_VERSION ${CMAKE_MATCH_1})
  103 			
  104 		endif()
  105 	
  106 	# Get centos release version
  107 	elseif(EXISTS "/etc/centos-release")	
  108 	
  109 		set ( PLATFORM "CentOS" )
  110 		
  111 		file(READ "/etc/centos-release" CENTOS_RELEASE)
  112 		string(REGEX MATCH "release ([0-9 /\\.]+)" _ ${CENTOS_RELEASE})
  113         set(PLATFORM_VERSION ${CMAKE_MATCH_1})
  114 	
  115 	# Only if distribution uses systemd and if all previous files didn't exist
  116 	# i.e OpenSUSE
  117 	elseif(EXISTS "/etc/os-release")	
  118 	
  119 		file(READ "/etc/os-release" OS_RELEASE_NAME)
  120 		string(REGEX MATCH "NAME=\"([a-zA-Z0-9 /\\.]+)\"" _ ${OS_RELEASE_NAME})
  121 		set(FULL_PLATFORM ${CMAKE_MATCH_1})
  122 		
  123 		if (FULL_PLATFORM MATCHES "^.*openSUSE.*$")
  124 			set ( PLATFORM "openSUSE" )
  125 		elseif ( FULL_PLATFORM MATCHES "^.*Ubuntu.*$")
  126 			set ( PLATFORM "Ubuntu" )
  127 		elseif ( FULL_PLATFORM MATCHES "^.*Debian.*$")
  128 			set ( PLATFORM "Debian" )
  129 		elseif ( FULL_PLATFORM MATCHES "^.*CentOS.*$" )
  130 			set ( PLATFORM "CentOS" )
  131 		endif ( )
  132 		
  133 		# Get ditribution release version
  134 		file(READ "/etc/os-release" OS_RELEASE)
  135 		string(REGEX MATCH "VERSION=\"([a-zA-Z0-9 /\\.]+)\"" _ ${OS_RELEASE})
  136 		set(PLATFORM_VERSION ${CMAKE_MATCH_1})
  137 		
  138 	endif()
  139 
  140 endif ( )
  141 string(REGEX REPLACE " $" "" PLATFORM_VERSION "${PLATFORM_VERSION}")	# Trim the last trailing whitespace
  142 set ( DISTRO_NAME ${PLATFORM}-${PLATFORM_VERSION} )
  143 MESSAGE ( STATUS "Platform = ${PLATFORM}" )
  144 MESSAGE ( STATUS "Platform Version = ${PLATFORM_VERSION}" )
  145 MESSAGE ( STATUS "Distribution name = ${DISTRO_NAME}" )
  146 
  147 # - Detect the architecture under OSX, Debian, CentOS and OpenSUSE platforms
  148 #	The following variable will be set
  149 #		$ARCHITECTURE
  150 if ( PLATFORM STREQUAL "Debian" OR PLATFORM STREQUAL "Ubuntu" )
  151 
  152 	# There is no such thing as i686 architecture on debian, i386 is to be used instead
  153 	# dpkg --print-architecture
  154 	find_program(DPKG_CMD dpkg)
  155 	if(NOT DPKG_CMD)
  156 		# Cannot find dpkg in path
  157 		# Try best guess following SUFFIX value calculated from CMAKE_SIZEOF_VOID_P
  158 		if (SUFFIX STREQUAL "32")
  159 			SET(ARCHITECTURE i386)
  160 		elseif (SUFFIX STREQUAL "64")
  161 			SET(ARCHITECTURE amd64)
  162 		endif()
  163 	else( )
  164 		execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
  165 	endif( )
  166 	
  167 elseif ( ( PLATFORM STREQUAL "CentOS" ) OR ( PLATFORM STREQUAL "openSUSE" ) )
  168 
  169 	execute_process(COMMAND arch OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
  170 	
  171 else ()
  172 
  173 	MESSAGE(FATAL_ERROR "Unrecognized / unsupported distribution")
  174 	
  175 endif ( )
  176 MESSAGE ( STATUS "Architecture = ${ARCHITECTURE}" )
  177 
  178 # - Create installation folder directory at install time
  179 #	This won't lead to the files being actually installed (in CMAKE_INSTALL_PREFIX)
  180 #	unless "cmake --build . --target install" is executed, which is not the case here.
  181 # 	
  182 #	Doing things like the following
  183 #		-	install(DIRECTORY 	${VERACRYPT_BUILD_DIR}/usr DESTINATION /)
  184 #		-	install(DIRECTORY 	${VERACRYPT_BUILD_DIR}/usr/bin DESTINATION /usr)
  185 #	lead to conflicts despite the usage of CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
  186 #	because install() forces CpackRPM to create the DESTINATION folders.
  187 #
  188 #	We fix this by installing ALL directories inside '/usr' in '.', and setting 
  189 #	CPACK_PACKAGING_INSTALL_PREFIX to '/usr'.
  190 #	This way, during the packaging, 'bin' and 'share' folders will be installed 
  191 #	inside '${CPACK_PACKAGE_DIRECTORY}/_CPack_Packages/<system_name>/DEB,RPM/${CPACK_PACKAGE_NAME}/${CPACK_PACKAGING_INSTALL_PREFIX}'.
  192 #
  193 #	Also, we use USE_SOURCE_PERMISSIONS to save the permissions
  194 install(DIRECTORY 	${VERACRYPT_BUILD_DIR}/usr/bin
  195 		DESTINATION .
  196 		USE_SOURCE_PERMISSIONS)
  197 install(DIRECTORY 	${VERACRYPT_BUILD_DIR}/usr/share
  198 		DESTINATION .
  199 		USE_SOURCE_PERMISSIONS)
  200 set(CPACK_PACKAGING_INSTALL_PREFIX "/usr")
  201 
  202 # For packaging 
  203 # CPack will first install into ${CPACK_PACKAGE_DIRECTORY}/_CPack_Packages/<system_name>/DEB,RPM/${CPACK_PACKAGE_NAME}/${CPACK_PACKAGING_INSTALL_PREFIX}
  204 # See https://gitlab.kitware.com/cmake/community/wikis/doc/cpack/PackageGenerators
  205 # See https://cmake.org/cmake/help/latest/cpack_gen/deb.html
  206 # See https://cmake.org/cmake/help/latest/cpack_gen/rpm.html
  207 #
  208 
  209 # Installation scripts should be provided in this order
  210 # 	PREINST;POSTINST;PRERM;POSTRM
  211 
  212 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Packaging)	# creates the Packaging directory under build directory when CMake generates the build system
  213 
  214 set( VENDOR "IDRIX" )
  215 set( LICENSE "VeraCrypt License" )
  216 set( CONTACT "VeraCrypt Team <veracrypt@idrix.fr>" )
  217 set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Disk encryption with strong security based on TrueCrypt." )
  218 set( CPACK_PACKAGE_DESCRIPTION "This package contains binaries for VeraCrypt, a disk encryption with strong security based on TrueCrypt." )
  219 set( CPACK_PACKAGE_NAME 			${PROJECT_NAME} )
  220 set( CPACK_PACKAGE_VERSION 			${VERSION} )
  221 set( CPACK_PACKAGE_RELEASE 			${RELEASE} )
  222 set( CPACK_PACKAGE_VENDOR 			${VENDOR} )
  223 set( CPACK_PACKAGE_LICENSE 			${LICENSE} )
  224 set( CPACK_RESOURCE_FILE_LICENSE 	"$ENV{SOURCEPATH}/License.txt")
  225 set( CPACK_PACKAGE_CONTACT 			${CONTACT} )	
  226 set( CPACK_PACKAGE_FILE_NAME 		${CPACK_PACKAGE_NAME}-${FULL_VERSION}-${DISTRO_NAME}-${ARCHITECTURE} )
  227 set( CPACK_PACKAGE_CHECKSUM 		SHA256 )
  228 set( CPACK_PACKAGE_RELOCATABLE 		"OFF")																						# Disable package relocation (especially for rpm)
  229 set( CPACK_PACKAGE_DIRECTORY 		${CMAKE_CURRENT_BINARY_DIR}/Packaging )
  230 
  231 if ( ( PLATFORM STREQUAL "Debian" ) OR ( PLATFORM STREQUAL "Ubuntu" ) )
  232 	
  233 	# Debian control script(s)
  234 	file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Packaging/debian-control)
  235 	configure_file(		${CMAKE_CURRENT_SOURCE_DIR}/Packaging/debian-control/prerm 		${CMAKE_CURRENT_BINARY_DIR}/Packaging/debian-control/prerm)
  236 	set( DEBIAN_PRERM 	${CMAKE_CURRENT_BINARY_DIR}/Packaging/debian-control/prerm)
  237 	
  238 	set( CPACK_GENERATOR 					"DEB" )																				# mandatory
  239 	set( CPACK_DEBIAN_PACKAGE_NAME 			${CPACK_PACKAGE_NAME}  )															# mandatory
  240 	set( CPACK_DEBIAN_FILE_NAME 			${CPACK_PACKAGE_FILE_NAME}.deb )													# mandatory
  241 	set( CPACK_DEBIAN_PACKAGE_VERSION 		${CPACK_PACKAGE_VERSION} )															# mandatory
  242 	set( CPACK_DEBIAN_PACKAGE_RELEASE 		${CPACK_PACKAGE_RELEASE} )
  243 	set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE 	${ARCHITECTURE} )																	# mandatory
  244 	
  245 	if (NOGUI)
  246 		# Link against statically built wxWidgets so that we don't depend on any GTK library
  247 		set( CPACK_DEBIAN_PACKAGE_DEPENDS 		"libfuse2, dmsetup, sudo" )
  248 	else ()
  249 		# Link against gtk3 version of wxWidgets if >= Debian 10 or >= Ubuntu 18.04
  250 		# Otherwise, link against gtk2 version of wxWidgets
  251 		if ( ( ( PLATFORM STREQUAL "Debian" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "10" ) ) 
  252 			OR ( ( PLATFORM STREQUAL "Ubuntu" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "18.04" ) ) )
  253 			
  254 			set( CPACK_DEBIAN_PACKAGE_DEPENDS 		"libwxgtk3.0-gtk3-0v5, libfuse2, dmsetup, sudo" )										
  255 			
  256 		else ()
  257 			# Link against statically built wxWidgets on Ubuntu 14.04 and older, and Debian 8 and older
  258 			if ( ( ( PLATFORM STREQUAL "Debian" ) AND ( PLATFORM_VERSION VERSION_LESS_EQUAL "8" ) ) 
  259 				OR ( ( PLATFORM STREQUAL "Ubuntu" ) AND ( PLATFORM_VERSION VERSION_LESS_EQUAL "14.04" ) ) )
  260 				set( CPACK_DEBIAN_PACKAGE_DEPENDS 		"libgtk2.0-0, libfuse2, dmsetup, sudo" )
  261 			else ()
  262 				set( CPACK_DEBIAN_PACKAGE_DEPENDS 		"libwxgtk3.0-0v5, libfuse2, dmsetup, sudo" )
  263 			endif ()
  264 			
  265 		endif()
  266 	endif()
  267 
  268 	set( CPACK_DEBIAN_PACKAGE_MAINTAINER 	${CONTACT} )																		# mandatory
  269 	set( CPACK_DEBIAN_PACKAGE_DESCRIPTION 	${CPACK_PACKAGE_DESCRIPTION_SUMMARY} )												# mandatory
  270 	set( CPACK_DEBIAN_ARCHIVE_TYPE 			"gnutar")																			# mandatory
  271 	set( CPACK_DEBIAN_COMPRESSION_TYPE 		"gzip")																				# mandatory
  272 	set( CPACK_DEBIAN_PACKAGE_PRIORITY 		"optional" )																		# mandatory
  273 	set( CPACK_DEBIAN_PACKAGE_SECTION 		"libs" )		 																	# recommended, Section relative to Debian sections (https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections)
  274 	set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA 	${DEBIAN_PREINST};${DEBIAN_POSTINST};${DEBIAN_PRERM};${DEBIAN_POSTRM})
  275 	set(CPACK_DEBIAN_PACKAGE_CONFLICTS 		"${CONFLICT_PACKAGE}")
  276 	
  277 elseif ( ( PLATFORM STREQUAL "CentOS" ) OR ( PLATFORM STREQUAL "openSUSE" ) )
  278 	
  279 	# RPM control script(s)
  280 	file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Packaging/rpm-control)
  281 	configure_file(	${CMAKE_CURRENT_SOURCE_DIR}/Packaging/rpm-control/prerm.sh 		${CMAKE_CURRENT_BINARY_DIR}/Packaging/rpm-control/prerm.sh)
  282 	set( RPM_PRERM 	${CMAKE_CURRENT_BINARY_DIR}/Packaging/rpm-control/prerm.sh)
  283 	
  284 	set( CPACK_GENERATOR 				"RPM" )																					# mandatory
  285 	set( CPACK_RPM_PACKAGE_SUMMARY 		${CPACK_PACKAGE_SUMMARY} )																# mandatory
  286 	set( CPACK_RPM_PACKAGE_DESCRIPTION 	${CPACK_PACKAGE_DESCRIPTION} )															# mandatory
  287 	set( CPACK_RPM_PACKAGE_NAME 		${CPACK_PACKAGE_NAME} )																	# mandatory
  288 	set( CPACK_RPM_FILE_NAME 			${CPACK_PACKAGE_FILE_NAME}.rpm )														# mandatory
  289 	set( CPACK_RPM_PACKAGE_VERSION 		${CPACK_PACKAGE_VERSION} )																# mandatory
  290 	set( CPACK_RPM_PACKAGE_ARCHITECTURE ${ARCHITECTURE} )																		# mandatory
  291 	set( CPACK_RPM_PACKAGE_RELEASE 		${CPACK_PACKAGE_RELEASE} )																# mandatory
  292 	set( CPACK_RPM_PACKAGE_LICENSE 		${CPACK_PACKAGE_LICENSE} )																# mandatory 
  293 	set( CPACK_RPM_PACKAGE_GROUP 		"Applications/System" )																	# mandatory, https://fedoraproject.org/wiki/RPMGroups
  294 	set( CPACK_RPM_PACKAGE_VENDOR 		${CPACK_PACKAGE_VENDOR} )																# mandatory
  295 	set( CPACK_RPM_PACKAGE_AUTOREQ 		"no" ) 																					# disable automatic shared libraries dependency detection (most of the time buggy)
  296 	
  297 	if (NOGUI)
  298 		set( CPACK_RPM_PACKAGE_REQUIRES 	"fuse, device-mapper, sudo" )
  299 	else ()
  300 		if ( PLATFORM STREQUAL "CentOS" )
  301 				
  302 			if ( DEFINED WITHGTK3 AND WITHGTK3 )
  303 				set( CPACK_RPM_PACKAGE_REQUIRES 	"fuse, device-mapper, gtk3, sudo" )
  304 			else ()
  305 				set( CPACK_RPM_PACKAGE_REQUIRES 	"fuse, device-mapper, gtk2, sudo" )
  306 			endif()
  307 			
  308 		elseif ( PLATFORM STREQUAL "openSUSE" )
  309 			
  310 			set( CPACK_RPM_PACKAGE_REQUIRES 	"fuse, device-mapper, gtk2, sudo" )
  311 		endif()
  312 	endif()
  313 
  314 	set( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE 			${RPM_PRERM})															# optional
  315 	
  316 	# Prevents CPack from generating file conflicts
  317 	# This is to avoid having %dir of these directories in the .spec file
  318 	set( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION 			"/usr" )
  319 	list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION	"/usr/bin" )
  320 	list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION	"/usr/share" )
  321 	list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION	"/usr/share/applications" )
  322 	list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION	"/usr/share/doc" )
  323 	list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION	"/usr/share/pixmaps" )
  324 	
  325 	set( CPACK_RPM_PACKAGE_RELOCATABLE 					"OFF" )
  326 	set( CPACK_RPM_PACKAGE_CONFLICTS 					"${CONFLICT_PACKAGE}")
  327 	
  328 endif()
  329 
  330 include(CPack)