1################################################################################ 2# Project: Lib jbig 3# Purpose: CMake build scripts 4# Author: Dmitry Baryshnikov, dmitry.baryshnikov@nexgis.com 5################################################################################ 6# Copyright (C) 2015, NextGIS <info@nextgis.com> 7# 8# Permission is hereby granted, free of charge, to any person obtaining a 9# copy of this software and associated documentation files (the "Software"), 10# to deal in the Software without restriction, including without limitation 11# the rights to use, copy, modify, merge, publish, distribute, sublicense, 12# and/or sell copies of the Software, and to permit persons to whom the 13# Software is furnished to do so, subject to the following conditions: 14# 15# The above copyright notice and this permission notice shall be included 16# in all copies or substantial portions of the Software. 17# 18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 23# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 24# DEALINGS IN THE SOFTWARE. 25################################################################################ 26 27function(check_version major minor rev) 28 29 # parse the version number from gdal_version.h and include in 30 # major, minor and rev parameters 31 32 file(READ ${CMAKE_CURRENT_SOURCE_DIR}/opencad.h VERSION_H_CONTENTS) 33 34 string(REGEX MATCH "OCAD_VERSION_MAJOR[ \t]+([0-9]+)" 35 MAJOR_VERSION ${VERSION_H_CONTENTS}) 36 string (REGEX MATCH "([0-9]+)" 37 MAJOR_VERSION ${MAJOR_VERSION}) 38 string(REGEX MATCH "OCAD_VERSION_MINOR[ \t]+([0-9]+)" 39 MINOR_VERSION ${VERSION_H_CONTENTS}) 40 string (REGEX MATCH "([0-9]+)" 41 MINOR_VERSION ${MINOR_VERSION}) 42 43 string(REGEX MATCH "OCAD_VERSION_REV[ \t]+([0-9]+)" 44 REV_VERSION ${VERSION_H_CONTENTS}) 45 string (REGEX MATCH "([0-9]+)" 46 REV_VERSION ${REV_VERSION}) 47 48 set(${major} ${MAJOR_VERSION} PARENT_SCOPE) 49 set(${minor} ${MINOR_VERSION} PARENT_SCOPE) 50 set(${rev} ${REV_VERSION} PARENT_SCOPE) 51 52endfunction(check_version) 53 54 55function(report_version name ver) 56 57 string(ASCII 27 Esc) 58 set(BoldYellow "${Esc}[1;33m") 59 set(ColourReset "${Esc}[m") 60 61 message(STATUS "${BoldYellow}${name} version ${ver}${ColourReset}") 62 63endfunction() 64 65 66# macro to find packages on the host OS 67macro( find_exthost_package ) 68 if(CMAKE_CROSSCOMPILING) 69 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) 70 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) 71 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) 72 if( CMAKE_HOST_WIN32 ) 73 SET( WIN32 1 ) 74 SET( UNIX ) 75 elseif( CMAKE_HOST_APPLE ) 76 SET( APPLE 1 ) 77 SET( UNIX ) 78 endif() 79 find_package( ${ARGN} ) 80 SET( WIN32 ) 81 SET( APPLE ) 82 SET( UNIX 1 ) 83 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) 84 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) 85 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) 86 else() 87 find_package( ${ARGN} ) 88 endif() 89endmacro() 90 91 92# macro to find programs on the host OS 93macro( find_exthost_program ) 94 if(CMAKE_CROSSCOMPILING) 95 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER ) 96 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER ) 97 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER ) 98 if( CMAKE_HOST_WIN32 ) 99 SET( WIN32 1 ) 100 SET( UNIX ) 101 elseif( CMAKE_HOST_APPLE ) 102 SET( APPLE 1 ) 103 SET( UNIX ) 104 endif() 105 find_program( ${ARGN} ) 106 SET( WIN32 ) 107 SET( APPLE ) 108 SET( UNIX 1 ) 109 set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY ) 110 set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY ) 111 set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY ) 112 else() 113 find_program( ${ARGN} ) 114 endif() 115endmacro() 116 117