diff options
Diffstat (limited to 'CMakeModules')
41 files changed, 5369 insertions, 0 deletions
diff --git a/CMakeModules/CMakeFindFrameworks.cmake b/CMakeModules/CMakeFindFrameworks.cmake new file mode 100644 index 0000000..7fdeb84 --- /dev/null +++ b/CMakeModules/CMakeFindFrameworks.cmake @@ -0,0 +1,32 @@ +# - helper module to find OSX frameworks + +#============================================================================= +# Copyright 2003-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if(NOT CMAKE_FIND_FRAMEWORKS_INCLUDED) + set(CMAKE_FIND_FRAMEWORKS_INCLUDED 1) + macro(CMAKE_FIND_FRAMEWORKS fwk) + set(${fwk}_FRAMEWORKS) + if(APPLE) + foreach(dir + ~/Library/Frameworks/${fwk}.framework + /Library/Frameworks/${fwk}.framework + /System/Library/Frameworks/${fwk}.framework + /Network/Library/Frameworks/${fwk}.framework) + if(EXISTS ${dir}) + set(${fwk}_FRAMEWORKS ${${fwk}_FRAMEWORKS} ${dir}) + endif() + endforeach() + endif() + endmacro() +endif() diff --git a/CMakeModules/CheckCXXSymbolExists.cmake b/CMakeModules/CheckCXXSymbolExists.cmake new file mode 100644 index 0000000..2100973 --- /dev/null +++ b/CMakeModules/CheckCXXSymbolExists.cmake @@ -0,0 +1,42 @@ +# - Check if a symbol exists as a function, variable, or macro in C++ +# CHECK_CXX_SYMBOL_EXISTS(<symbol> <files> <variable>) +# +# Check that the <symbol> is available after including given header +# <files> and store the result in a <variable>. Specify the list +# of files in one argument as a semicolon-separated list. +# CHECK_CXX_SYMBOL_EXISTS() can be used to check in C++ files, as opposed +# to CHECK_SYMBOL_EXISTS(), which works only for C. +# +# If the header files define the symbol as a macro it is considered +# available and assumed to work. If the header files declare the +# symbol as a function or variable then the symbol must also be +# available for linking. If the symbol is a type or enum value +# it will not be recognized (consider using CheckTypeSize or +# CheckCSourceCompiles). +# +# The following variables may be set before calling this macro to +# modify the way the check is run: +# +# CMAKE_REQUIRED_FLAGS = string of compile command line flags +# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) +# CMAKE_REQUIRED_INCLUDES = list of include directories +# CMAKE_REQUIRED_LIBRARIES = list of libraries to link + +#============================================================================= +# Copyright 2003-2011 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +include(CheckSymbolExists) + +macro(CHECK_CXX_SYMBOL_EXISTS SYMBOL FILES VARIABLE) + _CHECK_SYMBOL_EXISTS("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) +endmacro() diff --git a/CMakeModules/CheckFindPackageResult.cmake b/CMakeModules/CheckFindPackageResult.cmake new file mode 100644 index 0000000..3cb1a21 --- /dev/null +++ b/CMakeModules/CheckFindPackageResult.cmake @@ -0,0 +1,8 @@ +macro(check_find_package_result _VAR _PKGNAME) + if(${_VAR}) + message(STATUS "Check for installed ${_PKGNAME} -- found") + else(${_VAR}) + message(STATUS "Check for installed ${_PKGNAME} -- not found") + message(FATAL_ERROR "${_PKGNAME} was not found - it is required to build Kicad") + endif(${_VAR}) +endmacro(check_find_package_result) diff --git a/CMakeModules/CreateBzrVersionHeader.cmake b/CMakeModules/CreateBzrVersionHeader.cmake new file mode 100644 index 0000000..2c86e5f --- /dev/null +++ b/CMakeModules/CreateBzrVersionHeader.cmake @@ -0,0 +1,75 @@ +# +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net> +# Copyright (C) 2010-2015 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +macro( create_bzr_version_header _bzr_src_path ) + # If bzr is not found or an error occurs using the bzr commands to determine the repo + # version, set the build version string to "no-bzr" + set( KICAD_BUILD_VERSION "no-bzr" ) + + # Include Bazaar support to automagically create version header file. + find_package( Bazaar ) + + if( Bazaar_FOUND ) + set( _Bazaar_SAVED_LC_ALL "$ENV{LC_ALL}" ) + set( ENV{LC_ALL} C ) + + # Get the tree revision + execute_process( + COMMAND ${Bazaar_EXECUTABLE} revno --tree ${_bzr_src_path} + OUTPUT_VARIABLE _bzr_TREE_DATE + RESULT_VARIABLE _bzr_revno_result + OUTPUT_STRIP_TRAILING_WHITESPACE ) + + if( ${_bzr_revno_result} EQUAL 0 ) + # Get more info about that revision + execute_process( + COMMAND ${Bazaar_EXECUTABLE} log -r${_bzr_TREE_DATE} ${_bzr_src_path} + OUTPUT_VARIABLE _bzr_LAST_CHANGE_LOG + ERROR_VARIABLE _bzr_log_error + RESULT_VARIABLE _bzr_log_result + OUTPUT_STRIP_TRAILING_WHITESPACE ) + + if( ${_bzr_log_result} EQUAL 0 ) + string( REGEX REPLACE "^(.*\n)?revno: ([^ \n]+).*" + "\\2" Kicad_REPO_REVISION "${_bzr_LAST_CHANGE_LOG}" ) + string( REGEX REPLACE "^(.*\n)?committer: ([^\n]+).*" + "\\2" Kicad_REPO_LAST_CHANGED_AUTHOR "${_bzr_LAST_CHANGE_LOG}" ) + string( REGEX REPLACE "^(.*\n)?timestamp: [a-zA-Z]+ ([^ \n]+).*" + "\\2" Kicad_REPO_LAST_CHANGED_DATE "${_bzr_LAST_CHANGE_LOG}" ) + endif() + endif() + + set( ENV{LC_ALL} ${_Bazaar_SAVED_LC_ALL} ) + endif() + + # Check to make sure 'bzr log' command did not fail. Otherwise, default + # to "no-bzr" as the revision. + if( Kicad_REPO_LAST_CHANGED_DATE ) + string( REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+)" "\\1-\\2-\\3" + _kicad_bzr_date ${Kicad_REPO_LAST_CHANGED_DATE} ) + set( KICAD_BUILD_VERSION "(${_kicad_bzr_date} BZR ${Kicad_REPO_REVISION})" ) + endif() + + set( KICAD_BUILD_VERSION ${KICAD_BUILD_VERSION} ) +endmacro() diff --git a/CMakeModules/CreateGitVersionHeader.cmake b/CMakeModules/CreateGitVersionHeader.cmake new file mode 100644 index 0000000..c05ec3d --- /dev/null +++ b/CMakeModules/CreateGitVersionHeader.cmake @@ -0,0 +1,105 @@ +# +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net> +# Copyright (C) 2010-2016 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +macro( create_git_version_header _git_src_path ) + # If an error occurs using the git commands to determine the repo + # version, set the build version string to "git-error". + set( KICAD_GIT_BUILD_VERSION "git-error" ) + + # Include Git support to automagically create version header file. + find_package( Git ) + + if( GIT_FOUND ) + set( _Git_SAVED_LC_ALL "$ENV{LC_ALL}" ) + set( ENV{LC_ALL} C ) + + # Get latest commit hash + execute_process( + COMMAND + ${GIT_EXECUTABLE} --no-pager log -1 HEAD + --pretty=format:%H + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_LONG_HASH + ERROR_VARIABLE _git_log_error + RESULT_VARIABLE _git_log_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if( ${_git_log_result} EQUAL 0 ) + execute_process( + COMMAND + ${GIT_EXECUTABLE} --no-pager log -1 HEAD + --pretty=format:%h + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_SHORT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND + ${GIT_EXECUTABLE} --no-pager log -1 HEAD + --pretty=format:%cn + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_LAST_COMITTER + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND + ${GIT_EXECUTABLE} --no-pager log -1 HEAD + --pretty=format:%cd --date=short + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_LAST_CHANGE_LOG + OUTPUT_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND + ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${_git_src_path} + OUTPUT_VARIABLE _git_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE) + + message(STATUS "Git hash: ${_git_LONG_HASH}") + message(STATUS "Git branch: ${_git_BRANCH}") + + if( ${_git_log_result} EQUAL 0 ) + string( REGEX REPLACE "^(.*\n)?revno: ([^ \n]+).*" + "\\2" Kicad_REPO_REVISION "revision ${_git_SHORT_HASH}" ) + string( REGEX REPLACE "^(.*\n)?committer: ([^\n]+).*" + "\\2" Kicad_REPO_LAST_CHANGED_AUTHOR "${_git_LAST_COMITTER}") + string( REGEX REPLACE "^(.*\n)?timestamp: [a-zA-Z]+ ([^ \n]+).*" + "\\2" Kicad_REPO_LAST_CHANGED_DATE "${_git_LAST_CHANGE_LOG}") + endif() + endif() + + set( ENV{LC_ALL} ${_Git_SAVED_LC_ALL} ) + endif( GIT_FOUND ) + + # Check to make sure 'git' command did not fail. Otherwise fallback + # to "no-git" as the revision. + if( Kicad_REPO_LAST_CHANGED_DATE ) + string( REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+)" "\\1-\\2-\\3" + _kicad_git_date ${Kicad_REPO_LAST_CHANGED_DATE} ) + set( KICAD_VERSION "(${_kicad_git_date} ${Kicad_REPO_REVISION})" ) + set( KICAD_BRANCH_NAME ${_git_BRANCH} ) + endif() + +endmacro() diff --git a/CMakeModules/CreateSVNVersionHeader.cmake b/CMakeModules/CreateSVNVersionHeader.cmake new file mode 100644 index 0000000..1c6b9d9 --- /dev/null +++ b/CMakeModules/CreateSVNVersionHeader.cmake @@ -0,0 +1,61 @@ +macro(create_svn_version_header) + # Include Subversion support to automagically create version header file. + find_package(Subversion) + + if(Subversion_FOUND) + # Copied from the CMake module FindSubversion.cmake. The default + # version prevents generating the output files when the "svn info" + # command fails. Just fall back to using "build_version.h" for + # the version strings. + set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") + set(ENV{LC_ALL} C) + + execute_process( + COMMAND ${Subversion_SVN_EXECUTABLE} info ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE Kicad_WC_INFO + ERROR_VARIABLE _svn_error + RESULT_VARIABLE _svn_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT ${_svn_result} EQUAL 0) + message(STATUS + "Using <build_version.h> for version string.") + else(NOT ${_svn_result} EQUAL 0) + string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" + "\\2" Kicad_WC_URL "${Kicad_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*" + "\\2" Kicad_WC_REVISION "${Kicad_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*" + "\\2" Kicad_WC_LAST_CHANGED_AUTHOR "${Kicad_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*" + "\\2" Kicad_WC_LAST_CHANGED_REV "${Kicad_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*" + "\\2" Kicad_WC_LAST_CHANGED_DATE "${Kicad_WC_INFO}") + endif(NOT ${_svn_result} EQUAL 0) + + set(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL}) + endif(Subversion_FOUND) + + # Check to make sure 'svn info' command did not fail. Otherwise fallback + # to version strings defined in "<kicad-src-dir>/include/build_version.h". + if(Kicad_WC_LAST_CHANGED_DATE) + string(REGEX REPLACE "^([0-9]+)\\-([0-9]+)\\-([0-9]+).*" "\\1\\2\\3" + _kicad_svn_date ${Kicad_WC_LAST_CHANGED_DATE}) + set(KICAD_BUILD_VERSION + "(${_kicad_svn_date} SVN-R${Kicad_WC_LAST_CHANGED_REV})") + + # Definition to conditionally use date and revision returned from the + # Subversion info command instead of hand coded date and revision in + # "include/build_version.h". If subversion is not found then the date + # and version information must be manually edited. + # Directive means SVN build, program version and build version will + # reflect this. + add_definitions(-DHAVE_SVN_VERSION) + + # Generate version.h. + configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/version.h.cmake + ${CMAKE_BINARY_DIR}/version.h) + + message(STATUS "Kicad SVN build version: ${KICAD_BUILD_VERSION}") + endif(Kicad_WC_LAST_CHANGED_DATE) +endmacro(create_svn_version_header) diff --git a/CMakeModules/FindBazaar.cmake b/CMakeModules/FindBazaar.cmake new file mode 100644 index 0000000..91cd855 --- /dev/null +++ b/CMakeModules/FindBazaar.cmake @@ -0,0 +1,81 @@ +# +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net> +# Copyright (C) 2010 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +# This CMake script finds the Bazaar version control system executable and +# and fetches the veresion string to valid that Bazaar was found and executes +# properly. +# +# Usage: +# find_package( Bazaar ) +# +# User definable. +# Bazaar_EXECUTABLE Set this to use a version of Bazaar that is not in +# current path. Defaults to bzr. +# +# Defines: +# Bazaar_FOUND Set to TRUE if Bazaar command line client is found +# and the bzr --version command executes properly. +# Bazaar_VERSION Result of the bzr --version command. +# + +set( Bazaar_FOUND FALSE ) + +find_program( Bazaar_EXECUTABLE bzr + DOC "Bazaar version control system command line client" ) +mark_as_advanced( Bazaar_EXECUTABLE ) + +if( Bazaar_EXECUTABLE ) + + # Bazaar commands should be executed with the C locale, otherwise + # the message (which are parsed) may be translated causing the regular + # expressions to fail. + set( _Bazaar_SAVED_LC_ALL "$ENV{LC_ALL}" ) + set( ENV{LC_ALL} C ) + + # Fetch the Bazaar executable version. + execute_process( COMMAND ${Bazaar_EXECUTABLE} --version + OUTPUT_VARIABLE _bzr_version_output + ERROR_VARIABLE _bzr_version_error + RESULT_VARIABLE _bzr_version_result + OUTPUT_STRIP_TRAILING_WHITESPACE ) + + if( ${_bzr_version_result} EQUAL 0 ) + set( Bazaar_FOUND TRUE ) + string( REGEX REPLACE "^[\n]*Bazaar \\(bzr\\) ([0-9.a-z]+).*" + "\\1" Bazaar_VERSION "${_bzr_version_output}" ) + message( STATUS "Bazaar version control system version ${Bazaar_VERSION} found." ) + endif() + + # restore the previous LC_ALL + set( ENV{LC_ALL} ${_Bazaar_SAVED_LC_ALL} ) +endif() + +if( NOT Bazaar_FOUND ) + if( NOT Bazaar_FIND_QUIETLY ) + message( STATUS "Bazaar version control command line client was not found." ) + else() + if( Bazaar_FIND_REQUIRED ) + message( FATAL_ERROR "Bazaar version control command line client was not found." ) + endif() + endif() +endif() diff --git a/CMakeModules/FindCairo.cmake b/CMakeModules/FindCairo.cmake new file mode 100644 index 0000000..bc23028 --- /dev/null +++ b/CMakeModules/FindCairo.cmake @@ -0,0 +1,168 @@ +# - Try to find the CAIRO library +# Once done this will define +# +# CAIRO_ROOT_DIR - Set this variable to the root installation of CAIRO +# +# Read-Only variables: +# CAIRO_FOUND - system has the CAIRO library +# CAIRO_INCLUDE_DIR - the CAIRO include directory +# CAIRO_LIBRARIES - The libraries needed to use CAIRO +# CAIRO_VERSION - This is set to $major.$minor.$revision (eg. 0.9.8) + +#============================================================================= +# Copyright 2012 Dmitry Baryshnikov <polimax at mail dot ru> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if (UNIX) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_CAIRO cairo) + endif (PKG_CONFIG_FOUND) +endif (UNIX) + +SET(_CAIRO_ROOT_HINTS + $ENV{CAIRO} + ${CAIRO_ROOT_DIR} + ) +SET(_CAIRO_ROOT_PATHS + $ENV{CAIRO}/src + /usr + /usr/local + ) +SET(_CAIRO_ROOT_HINTS_AND_PATHS + HINTS ${_CAIRO_ROOT_HINTS} + PATHS ${_CAIRO_ROOT_PATHS} + ) + +FIND_PATH(CAIRO_INCLUDE_DIR + NAMES + cairo.h + HINTS + ${_CAIRO_INCLUDEDIR} + ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + include + "include/cairo" +) + +IF(WIN32 AND NOT CYGWIN) + # MINGW should go here too + IF(MSVC) + # Implementation details: + # We are using the libraries located in the VC subdir instead of the parent directory eventhough : + FIND_LIBRARY(CAIRO_DEBUG + NAMES + cairod + ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + + FIND_LIBRARY(CAIRO_RELEASE + NAMES + cairo + ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + + if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) + if(NOT CAIRO_DEBUG) + set(CAIRO_DEBUG ${CAIRO_RELEASE}) + endif(NOT CAIRO_DEBUG) + set( CAIRO_LIBRARIES + optimized ${CAIRO_RELEASE} debug ${CAIRO_DEBUG} + ) + else() + set( CAIRO_LIBRARIES ${CAIRO_RELEASE}) + endif() + MARK_AS_ADVANCED(CAIRO_DEBUG CAIRO_RELEASE) + ELSEIF(MINGW) + # same player, for MingW + FIND_LIBRARY(CAIRO + NAMES + cairo + ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "lib/MinGW" + ) + + MARK_AS_ADVANCED(CAIRO) + set( CAIRO_LIBRARIES ${CAIRO}) + ELSE(MSVC) + # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: + FIND_LIBRARY(CAIRO + NAMES + cairo + HINTS + ${_CAIRO_LIBDIR} + ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + lib + ) + + MARK_AS_ADVANCED(CAIRO) + set( CAIRO_LIBRARIES ${CAIRO} ) + ENDIF(MSVC) +ELSE(WIN32 AND NOT CYGWIN) + + FIND_LIBRARY(CAIRO_LIBRARY + NAMES + cairo + HINTS + ${_CAIRO_LIBDIR} + ${_CAIRO_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "local/lib" + ) + + MARK_AS_ADVANCED(CAIRO_LIBRARY) + + # compat defines + SET(CAIRO_LIBRARIES ${CAIRO_LIBRARY}) + +ENDIF(WIN32 AND NOT CYGWIN) + + # if (CAIRO_INCLUDE_DIR) + # file(READ "${CAIRO_INCLUDE_DIR}/gcore/gdal_version.h" _wxgisgdal_VERSION_H_CONTENTS) + # string(REGEX REPLACE ".*# define[ \t]+GDAL_RELEASE_NAME[ \t]+\"([0-9A-Za-z.]+)\".*" + # "\\1" CAIRO_VERSION ${_wxgisgdal_VERSION_H_CONTENTS}) + # set(CAIRO_VERSION ${CAIRO_VERSION} CACHE INTERNAL "The version number for wxgisgdal libraries") + # endif (CAIRO_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) + +# if (CAIRO_VERSION) + # find_package_handle_standard_args(CAIRO + # REQUIRED_VARS + # CAIRO_LIBRARIES + # CAIRO_INCLUDE_DIR + # VERSION_VAR + # CAIRO_VERSION + # FAIL_MESSAGE + # "Could NOT find CAIRO, try to set the path to CAIRO root folder in the system variable CAIRO_ROOT_DIR" + # ) +# else (CAIRO_VERSION) + find_package_handle_standard_args(CAIRO "Could NOT find CAIRO, try to set the path to CAIRO root folder in the system variable CAIRO" + CAIRO_LIBRARIES + CAIRO_INCLUDE_DIR + ) +# endif (CAIRO_VERSION) + +MARK_AS_ADVANCED(CAIRO_INCLUDE_DIR CAIRO_LIBRARIES) + diff --git a/CMakeModules/FindGLEW.cmake b/CMakeModules/FindGLEW.cmake new file mode 100644 index 0000000..621fe3b --- /dev/null +++ b/CMakeModules/FindGLEW.cmake @@ -0,0 +1,112 @@ +# Copyright (c) 2009 Boudewijn Rempt <boud@valdyas.org> +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# +# - try to find glew library and include files +# GLEW_INCLUDE_DIR, where to find GL/glew.h, etc. +# GLEW_LIBRARIES, the libraries to link against +# GLEW_FOUND, If false, do not try to use GLEW. +# Also defined, but not for general use are: +# GLEW_GLEW_LIBRARY = the full path to the glew library. + +IF (WIN32) + + IF(CYGWIN) + + FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h) + + FIND_LIBRARY( GLEW_GLEW_LIBRARY glew32 + ${OPENGL_LIBRARY_DIR} + /usr/lib/w32api + /usr/X11R6/lib + ) + + + ELSE(CYGWIN) + + FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h + $ENV{GLEW_ROOT_PATH}/include + ) + + FIND_LIBRARY( GLEW_GLEW_LIBRARY + NAMES glew glew32 glew32s + PATHS + $ENV{GLEW_ROOT_PATH}/lib + $ENV{GLEW_ROOT_PATH}/lib/Release/Win32 + ${OPENGL_LIBRARY_DIR} + ) + + ENDIF(CYGWIN) + +ELSE (WIN32) + + IF (APPLE) +# These values for Apple could probably do with improvement. + FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h + /System/Library/Frameworks/GLEW.framework/Versions/A/Headers + /opt/local/include + ${OPENGL_LIBRARY_DIR} + ) + + FIND_LIBRARY( GLEW_GLEW_LIBRARY GLEW + /opt/local/lib + ) + + ELSE (APPLE) + + FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h + /usr/include/GL + /usr/openwin/share/include + /usr/openwin/include + /usr/X11R6/include + /usr/include/X11 + /opt/graphics/OpenGL/include + /opt/graphics/OpenGL/contrib/libglew + ) + + FIND_LIBRARY( GLEW_GLEW_LIBRARY GLEW + /usr/openwin/lib + /usr/X11R6/lib + /usr/lib + /usr/lib/x86_64-linux-gnu + ) + + ENDIF (APPLE) + +ENDIF (WIN32) + +SET( GLEW_FOUND "NO" ) +IF(GLEW_INCLUDE_DIR) + IF(GLEW_GLEW_LIBRARY) + # Is -lXi and -lXmu required on all platforms that have it? + # If not, we need some way to figure out what platform we are on. + SET( GLEW_LIBRARIES + ${GLEW_GLEW_LIBRARY} + ${GLEW_cocoa_LIBRARY} + ) + SET( GLEW_FOUND "YES" ) + +#The following deprecated settings are for backwards compatibility with CMake1.4 + SET (GLEW_LIBRARY ${GLEW_LIBRARIES}) + SET (GLEW_INCLUDE_PATH ${GLEW_INCLUDE_DIR}) + + ENDIF(GLEW_GLEW_LIBRARY) +ENDIF(GLEW_INCLUDE_DIR) + +IF(GLEW_FOUND) + IF(NOT GLEW_FIND_QUIETLY) + MESSAGE(STATUS "Found Glew: ${GLEW_LIBRARIES}") + ENDIF(NOT GLEW_FIND_QUIETLY) +ELSE(GLEW_FOUND) + IF(GLEW_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find Glew") + ENDIF(GLEW_FIND_REQUIRED) +ENDIF(GLEW_FOUND) + +MARK_AS_ADVANCED( + GLEW_INCLUDE_DIR + GLEW_GLEW_LIBRARY + GLEW_Xmu_LIBRARY + GLEW_Xi_LIBRARY +) diff --git a/CMakeModules/FindGdiPlus.cmake b/CMakeModules/FindGdiPlus.cmake new file mode 100644 index 0000000..cde55a3 --- /dev/null +++ b/CMakeModules/FindGdiPlus.cmake @@ -0,0 +1,22 @@ +# - Try to find Microsoft GDI+ build files. +# Once done this will define +# +# GDI_PLUS_FOUND - system has GDI+ +# GDI_PLUS_INCLUDE_DIR - the GDI+ include directory +# GDI_PLUS_LIBRARIES - Link these to use GDI+ + +if(GDI_PLUS_INCLUDE_DIR AND GDI_PLUS_LIBRARIES) + set(GDI_PLUS_FIND_QUIETLY TRUE) +endif(GDI_PLUS_INCLUDE_DIR AND GDI_PLUS_LIBRARIES) + +find_path(GDI_PLUS_INCLUDE_DIR GdiPlus.h ) + +find_library(GDI_PLUS_LIBRARIES gdiplus ) + +# handle the QUIETLY and REQUIRED arguments and set GDI_PLUS_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(GDI_PLUS DEFAULT_MSG GDI_PLUS_LIBRARIES GDI_PLUS_INCLUDE_DIR) + +mark_as_advanced(GDI_PLUS_INCLUDE_DIR GDI_PLUS_LIBRARIES) diff --git a/CMakeModules/FindOpenSSL.cmake b/CMakeModules/FindOpenSSL.cmake new file mode 100644 index 0000000..de91787 --- /dev/null +++ b/CMakeModules/FindOpenSSL.cmake @@ -0,0 +1,342 @@ +#.rst: +# FindOpenSSL +# ----------- +# +# Try to find the OpenSSL encryption library +# +# Once done this will define +# +# :: +# +# OPENSSL_ROOT_DIR - Set this variable to the root installation of OpenSSL +# +# +# +# Read-Only variables: +# +# :: +# +# OPENSSL_FOUND - system has the OpenSSL library +# OPENSSL_INCLUDE_DIR - the OpenSSL include directory +# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL +# OPENSSL_VERSION - This is set to $major.$minor.$revision$path (eg. 0.9.8s) + +#============================================================================= +# Copyright 2006-2009 Kitware, Inc. +# Copyright 2006 Alexander Neundorf <neundorf@kde.org> +# Copyright 2009-2011 Mathieu Malaterre <mathieu.malaterre@gmail.com> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +if (UNIX) + find_package(PkgConfig QUIET) + pkg_check_modules(_OPENSSL QUIET openssl) +endif () + +if (WIN32) + # http://www.slproweb.com/products/Win32OpenSSL.html + set(_OPENSSL_ROOT_HINTS + ${OPENSSL_ROOT_DIR} + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]" + ENV OPENSSL_ROOT_DIR + ) + file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles) + set(_OPENSSL_ROOT_PATHS + "${_programfiles}/OpenSSL" + "${_programfiles}/OpenSSL-Win32" + "${_programfiles}/OpenSSL-Win64" + "C:/OpenSSL/" + "C:/OpenSSL-Win32/" + "C:/OpenSSL-Win64/" + ) + unset(_programfiles) +else () + set(_OPENSSL_ROOT_HINTS + ${OPENSSL_ROOT_DIR} + ENV OPENSSL_ROOT_DIR + ) +endif () + +set(_OPENSSL_ROOT_HINTS_AND_PATHS + HINTS ${_OPENSSL_ROOT_HINTS} + PATHS ${_OPENSSL_ROOT_PATHS} + ) + +find_path(OPENSSL_INCLUDE_DIR + NAMES + openssl/ssl.h + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + HINTS + ${_OPENSSL_INCLUDEDIR} + PATH_SUFFIXES + include +) + +if(WIN32 AND NOT CYGWIN) + if(MSVC) + # /MD and /MDd are the standard values - if someone wants to use + # others, the libnames have to change here too + # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b + # TODO: handle /MT and static lib + # In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix: + # * MD for dynamic-release + # * MDd for dynamic-debug + # * MT for static-release + # * MTd for static-debug + + # Implementation details: + # We are using the libraries located in the VC subdir instead of the parent directory eventhough : + # libeay32MD.lib is identical to ../libeay32.lib, and + # ssleay32MD.lib is identical to ../ssleay32.lib + find_library(LIB_EAY_DEBUG + NAMES + libeay32MDd + libeay32d + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + + find_library(LIB_EAY_RELEASE + NAMES + libeay32MD + libeay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + + find_library(SSL_EAY_DEBUG + NAMES + ssleay32MDd + ssleay32d + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + + find_library(SSL_EAY_RELEASE + NAMES + ssleay32MD + ssleay32 + ssl + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "VC" + "lib/VC" + ) + + set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}") + set(LIB_EAY_LIBRARY_RELEASE "${LIB_EAY_RELEASE}") + set(SSL_EAY_LIBRARY_DEBUG "${SSL_EAY_DEBUG}") + set(SSL_EAY_LIBRARY_RELEASE "${SSL_EAY_RELEASE}") + + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) + select_library_configurations(LIB_EAY) + select_library_configurations(SSL_EAY) + + mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE + SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE) + set( OPENSSL_LIBRARIES ${SSL_EAY_LIBRARY} ${LIB_EAY_LIBRARY} ) + elseif(MINGW) + message( STATUS "Searching for OpenSSL in MinGW." ) + # same player, for MinGW + set(LIB_EAY_NAMES libeay32) + set(SSL_EAY_NAMES ssleay32) + list(APPEND LIB_EAY_NAMES crypto) + list(APPEND SSL_EAY_NAMES ssl) + + find_library(LIB_EAY + NAMES + ${LIB_EAY_NAMES} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "lib/MinGW" + # Do not search system path. Otherwise the DLL will be found rather than the link library. + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH + ) + + find_library(SSL_EAY + NAMES + ${SSL_EAY_NAMES} + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + "lib/MinGW" + # Do not search system path. Otherwise the DLL will be found rather than the link library. + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH + ) + + mark_as_advanced(SSL_EAY LIB_EAY) + set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + unset(LIB_EAY_NAMES) + unset(SSL_EAY_NAMES) + else() + # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues: + find_library(LIB_EAY + NAMES + libeay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + HINTS + ${_OPENSSL_LIBDIR} + PATH_SUFFIXES + lib + ) + + find_library(SSL_EAY + NAMES + ssleay32 + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + HINTS + ${_OPENSSL_LIBDIR} + PATH_SUFFIXES + lib + ) + + mark_as_advanced(SSL_EAY LIB_EAY) + set( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} ) + endif() +else() + + find_library(OPENSSL_SSL_LIBRARY + NAMES + ssl + ssleay32 + ssleay32MD + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + HINTS + ${_OPENSSL_LIBDIR} + PATH_SUFFIXES + lib + ) + + find_library(OPENSSL_CRYPTO_LIBRARY + NAMES + crypto + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + HINTS + ${_OPENSSL_LIBDIR} + PATH_SUFFIXES + lib + ) + + mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY) + + # compat defines + set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) + set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) + + set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) + +endif() + +function(from_hex HEX DEC) + string(TOUPPER "${HEX}" HEX) + set(_res 0) + string(LENGTH "${HEX}" _strlen) + + while (_strlen GREATER 0) + math(EXPR _res "${_res} * 16") + string(SUBSTRING "${HEX}" 0 1 NIBBLE) + string(SUBSTRING "${HEX}" 1 -1 HEX) + if (NIBBLE STREQUAL "A") + math(EXPR _res "${_res} + 10") + elseif (NIBBLE STREQUAL "B") + math(EXPR _res "${_res} + 11") + elseif (NIBBLE STREQUAL "C") + math(EXPR _res "${_res} + 12") + elseif (NIBBLE STREQUAL "D") + math(EXPR _res "${_res} + 13") + elseif (NIBBLE STREQUAL "E") + math(EXPR _res "${_res} + 14") + elseif (NIBBLE STREQUAL "F") + math(EXPR _res "${_res} + 15") + else() + math(EXPR _res "${_res} + ${NIBBLE}") + endif() + + string(LENGTH "${HEX}" _strlen) + endwhile() + + set(${DEC} ${_res} PARENT_SCOPE) +endfunction() + +if (OPENSSL_INCLUDE_DIR) + if (_OPENSSL_VERSION) + set(OPENSSL_VERSION "${_OPENSSL_VERSION}") + elseif(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h") + file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str + REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*") + + # The version number is encoded as 0xMNNFFPPS: major minor fix patch status + # The status gives if this is a developer or prerelease and is ignored here. + # Major, minor, and fix directly translate into the version numbers shown in + # the string. The patch field translates to the single character suffix that + # indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so + # on. + + message(STATUS "OPENSSL_VERSION_STR=${openssl_version_str}") + + string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$" + "\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}") + list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR) + list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR) + from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR) + list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX) + from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX) + list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH) + + if (NOT OPENSSL_VERSION_PATCH STREQUAL "00") + from_hex("${OPENSSL_VERSION_PATCH}" _tmp) + # 96 is the ASCII code of 'a' minus 1 + math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96") + unset(_tmp) + # Once anyone knows how OpenSSL would call the patch versions beyond 'z' + # this should be updated to handle that, too. This has not happened yet + # so it is simply ignored here for now. + string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING) + endif () + + set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}") + endif () +endif () + +include(FindPackageHandleStandardArgs) + +if (OPENSSL_VERSION) + find_package_handle_standard_args(OpenSSL + REQUIRED_VARS + OPENSSL_LIBRARIES + OPENSSL_INCLUDE_DIR + VERSION_VAR + OPENSSL_VERSION + FAIL_MESSAGE + "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR" + ) +else () + find_package_handle_standard_args(OpenSSL "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR" + OPENSSL_LIBRARIES + OPENSSL_INCLUDE_DIR + ) +endif () + +mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES) diff --git a/CMakeModules/FindPackageMessage.cmake b/CMakeModules/FindPackageMessage.cmake new file mode 100644 index 0000000..b6a58e4 --- /dev/null +++ b/CMakeModules/FindPackageMessage.cmake @@ -0,0 +1,57 @@ +#.rst: +# FindPackageMessage +# ------------------ +# +# +# +# FIND_PACKAGE_MESSAGE(<name> "message for user" "find result details") +# +# This macro is intended to be used in FindXXX.cmake modules files. It +# will print a message once for each unique find result. This is useful +# for telling the user where a package was found. The first argument +# specifies the name (XXX) of the package. The second argument +# specifies the message to display. The third argument lists details +# about the find result so that if they change the message will be +# displayed again. The macro also obeys the QUIET argument to the +# find_package command. +# +# Example: +# +# :: +# +# if(X11_FOUND) +# FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" +# "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") +# else() +# ... +# endif() + +#============================================================================= +# Copyright 2008-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +function(FIND_PACKAGE_MESSAGE pkg msg details) + # Avoid printing a message repeatedly for the same find result. + if(NOT ${pkg}_FIND_QUIETLY) + string(REGEX REPLACE "[\n]" "" details "${details}") + set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) + if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") + # The message has not yet been printed. + message(STATUS "${msg}") + + # Save the find details in the cache to avoid printing the same + # message again. + set("${DETAILS_VAR}" "${details}" + CACHE INTERNAL "Details about finding ${pkg}") + endif() + endif() +endfunction() diff --git a/CMakeModules/FindPythonInterp.cmake b/CMakeModules/FindPythonInterp.cmake new file mode 100644 index 0000000..9910699 --- /dev/null +++ b/CMakeModules/FindPythonInterp.cmake @@ -0,0 +1,175 @@ +# - Find python interpreter +# This module finds if Python interpreter is installed and determines where the +# executables are. This code sets the following variables: +# +# PYTHONINTERP_FOUND - Was the Python executable found +# PYTHON_EXECUTABLE - path to the Python interpreter +# +# PYTHON_VERSION_STRING - Python version found e.g. 2.5.2 +# PYTHON_VERSION_MAJOR - Python major version found e.g. 2 +# PYTHON_VERSION_MINOR - Python minor version found e.g. 5 +# PYTHON_VERSION_PATCH - Python patch version found e.g. 2 +# +# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list of +# version numbers that should be taken into account when searching for Python. +# You need to set this variable before calling find_package(PythonInterp). +# +# You can point to a preferred python install to use by setting the following +# to the point at the root directory of the python install: +# +# PYTHON_ROOT_DIR - The root directory of the python install +#============================================================================= +# Copyright 2005-2010 Kitware, Inc. +# Copyright 2011 Bjoern Ricks <bjoern.ricks@gmail.com> +# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +unset(_Python_NAMES) + +set(_PYTHON1_VERSIONS 1.6 1.5) +set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) +set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0) + +if(PythonInterp_FIND_VERSION) + if(PythonInterp_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") + string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonInterp_FIND_VERSION}") + string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}") + list(APPEND _Python_NAMES python${_PYTHON_FIND_MAJ_MIN} python${_PYTHON_FIND_MAJ}) + unset(_PYTHON_FIND_OTHER_VERSIONS) + if(NOT PythonInterp_FIND_VERSION_EXACT) + foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS}) + if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) + list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) + endif() + endforeach() + endif() + unset(_PYTHON_FIND_MAJ_MIN) + unset(_PYTHON_FIND_MAJ) + else() + list(APPEND _Python_NAMES python${PythonInterp_FIND_VERSION}) + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonInterp_FIND_VERSION}_VERSIONS}) + endif() +else() + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) +endif() + +list(APPEND _Python_NAMES python) + +# Search for the preferred executable first +if( ${PYTHON_ROOT_DIR} ) + # Search for any of the executable names solely in the directory we've + # been pointed to. Failure to find the python executable here is a fatal + # fail. + find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES} + PATHS ${PYTHON_ROOT_DIR} + NO_DEFAULT_PATH ) +else() + # If there is no specific path given, look for python in the path + find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES}) +endif() + +# Set up the versions we know about, in the order we will search. Always add +# the user supplied additional versions to the front. +set(_Python_VERSIONS + ${Python_ADDITIONAL_VERSIONS} + ${_PYTHON_FIND_OTHER_VERSIONS} + ) + +unset(_PYTHON_FIND_OTHER_VERSIONS) +unset(_PYTHON1_VERSIONS) +unset(_PYTHON2_VERSIONS) +unset(_PYTHON3_VERSIONS) + +# Search for newest python version if python executable isn't found +if(NOT PYTHON_EXECUTABLE) + + # If using the MINGW compiler, we mustn't find the standard python + # distribution because of multiple C-Runtime errors. We must instead + # use the Python-a-mingw-us distribution + if(MINGW) + list( APPEND _Python_PPATHS ${PYTHON_ROOT_DIR} ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.9" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.8" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.7" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.6" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.5" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.4" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.3" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.2" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.1" ) + list( APPEND _Python_PPATHS "C:/python/${_CURRENT_VERSION}.0" ) + else() + list( APPEND _Python_PPATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath] ) + endif() + + foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + set(_Python_NAMES python${_CURRENT_VERSION}) + if(WIN32) + list(APPEND _Python_NAMES python) + endif() + find_program(PYTHON_EXECUTABLE + NAMES ${_Python_NAMES} + PATHS ${_Python_PPATHS} + ) + endforeach() +endif() + +# determine python version string +if(PYTHON_EXECUTABLE) + execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c + "import sys; sys.stdout.write(';'.join([str(x) for x in sys.version_info[:3]]))" + OUTPUT_VARIABLE _VERSION + RESULT_VARIABLE _PYTHON_VERSION_RESULT + ERROR_QUIET) + if(NOT _PYTHON_VERSION_RESULT) + string(REPLACE ";" "." PYTHON_VERSION_STRING "${_VERSION}") + list(GET _VERSION 0 PYTHON_VERSION_MAJOR) + list(GET _VERSION 1 PYTHON_VERSION_MINOR) + list(GET _VERSION 2 PYTHON_VERSION_PATCH) + if(PYTHON_VERSION_PATCH EQUAL 0) + # it's called "Python 2.7", not "2.7.0" + string(REGEX REPLACE "\\.0$" "" PYTHON_VERSION_STRING "${PYTHON_VERSION_STRING}") + endif() + else() + # sys.version predates sys.version_info, so use that + execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import sys; sys.stdout.write(sys.version)" + OUTPUT_VARIABLE _VERSION + RESULT_VARIABLE _PYTHON_VERSION_RESULT + ERROR_QUIET) + if(NOT _PYTHON_VERSION_RESULT) + string(REGEX REPLACE " .*" "" PYTHON_VERSION_STRING "${_VERSION}") + string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}") + string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}") + if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+.*") + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}") + else() + set(PYTHON_VERSION_PATCH "0") + endif() + else() + # sys.version was first documented for Python 1.5, so assume + # this is older. + set(PYTHON_VERSION_STRING "1.4") + set(PYTHON_VERSION_MAJOR "1") + set(PYTHON_VERSION_MAJOR "4") + set(PYTHON_VERSION_MAJOR "0") + endif() + endif() + unset(_PYTHON_VERSION_RESULT) + unset(_VERSION) +endif() + +# handle the QUIETLY and REQUIRED arguments and set PYTHONINTERP_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PythonInterp REQUIRED_VARS PYTHON_EXECUTABLE VERSION_VAR PYTHON_VERSION_STRING) + +mark_as_advanced(PYTHON_EXECUTABLE) diff --git a/CMakeModules/FindPythonLibs.cmake b/CMakeModules/FindPythonLibs.cmake new file mode 100644 index 0000000..5ff25b7 --- /dev/null +++ b/CMakeModules/FindPythonLibs.cmake @@ -0,0 +1,322 @@ +# - Find python libraries +# This module finds if Python is installed and determines where the +# include files and libraries are. It also determines what the name of +# the library is. This code sets the following variables: +# +# PYTHONLIBS_FOUND - have the Python libs been found +# PYTHON_LIBRARIES - path to the python library +# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated) +# PYTHON_INCLUDE_DIRS - path to where Python.h is found +# PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated) +# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8) +# +# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list of +# version numbers that should be taken into account when searching for Python. +# You need to set this variable before calling find_package(PythonLibs). +# +# You can point to a preferred python install to use by setting the following +# to the point at the root directory of the python install: +# +# PYTHON_ROOT_DIR - The root directory of the python install +# +# If you'd like to specify the installation of Python to use, you should modify +# the following cache variables: +# PYTHON_LIBRARY - path to the python library +# PYTHON_INCLUDE_DIR - path to where Python.h is found + +#============================================================================= +# Copyright 2001-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +include(CMakeFindFrameworks) + +# Search for the python framework on Apple. +cmake_find_frameworks(Python) + +set(_PYTHON1_VERSIONS 1.6 1.5) +set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0) +set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0) + +if(PythonLibs_FIND_VERSION) + if(PythonLibs_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\.[0-9]+.*)?$") + string(REGEX REPLACE "^([0-9]+\\.[0-9]+).*" "\\1" _PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION}") + string(REGEX REPLACE "^([0-9]+).*" "\\1" _PYTHON_FIND_MAJ "${_PYTHON_FIND_MAJ_MIN}") + unset(_PYTHON_FIND_OTHER_VERSIONS) + if(PythonLibs_FIND_VERSION_EXACT) + if(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION) + set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}") + else() + set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}") + endif() + else() + foreach(_PYTHON_V ${_PYTHON${_PYTHON_FIND_MAJ}_VERSIONS}) + if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN) + list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V}) + endif() + endforeach() + endif() + unset(_PYTHON_FIND_MAJ_MIN) + unset(_PYTHON_FIND_MAJ) + else() + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION}_VERSIONS}) + endif() +else() + set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS}) +endif() + +# Set up the versions we know about, in the order we will search. Always add +# the user supplied additional versions to the front. +set(_Python_VERSIONS + ${Python_ADDITIONAL_VERSIONS} + ${_PYTHON_FIND_OTHER_VERSIONS} + ) + +unset(_PYTHON_FIND_OTHER_VERSIONS) +unset(_PYTHON1_VERSIONS) +unset(_PYTHON2_VERSIONS) +unset(_PYTHON3_VERSIONS) + +foreach(_CURRENT_VERSION ${_Python_VERSIONS}) + string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION}) + + if(WIN32) + if(MINGW) + find_library(PYTHON_DEBUG_LIBRARY + NAMES python{$_CURRENT_VERSION}_d + PATHS + "${PYTHON_ROOT_DIR}" + "c:/python${_CURRENT_VERSION}" + "c:/python${_CURRENT_VERSION_NO_DOTS}" + NO_SYSTEM_ENVIRONMENT_PATH + ) + else() + find_library(PYTHON_DEBUG_LIBRARY + NAMES python${_CURRENT_VERSION_NO_DOTS}_d python + PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + ) + endif() + endif() + + if(MINGW) + find_library(PYTHON_LIBRARY + NAMES python${_CURRENT_VERSION} + PATHS + "${PYTHON_ROOT_DIR}" + "C:/python" + PATH_SUFFIXES + ${_CURRENT_VERSION} + ${_CURRENT_VERSION_NO_DOTS} + NO_SYSTEM_ENVIRONMENT_PATH + ) + else() + find_library(PYTHON_LIBRARY + NAMES + python${_CURRENT_VERSION_NO_DOTS} + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u + python${_CURRENT_VERSION} + PATHS + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs + # Avoid finding the .dll in the PATH. We want the .lib. + NO_SYSTEM_ENVIRONMENT_PATH + ) + endif() + + # Look for the static library in the Python config directory + find_library(PYTHON_LIBRARY + NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION} + # Avoid finding the .dll in the PATH. We want the .lib. + NO_SYSTEM_ENVIRONMENT_PATH + # This is where the static library is usually located + PATH_SUFFIXES python${_CURRENT_VERSION}/config + ) + + # For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if + # PYTHON_INCLUDE_DIR is not set. + if(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR) + set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH + "Path to where Python.h is found" FORCE) + endif() + + set(PYTHON_FRAMEWORK_INCLUDES) + + if(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR) + foreach(dir ${Python_FRAMEWORKS}) + set(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES} + ${dir}/Versions/${_CURRENT_VERSION}/include/python${_CURRENT_VERSION}) + endforeach() + endif() + + if(MINGW) + find_path(PYTHON_INCLUDE_DIR + NAMES Python.h + PATHS + "${PYTHON_ROOT_DIR}" + "C:/python${_CURRENT_VERSION}" + "C:/python${_CURRENT_VERSION_NOT_DOTS}" + PATH_SUFFIXES + include + python${_CURRENT_VERSION} + python${_CURRENT_VERSION_NOT_DOTS} + ) + else() + find_path(PYTHON_INCLUDE_DIR + NAMES Python.h + PATHS + ${PYTHON_FRAMEWORK_INCLUDES} + [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include + [HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include + PATH_SUFFIXES + python${_CURRENT_VERSION}mu + python${_CURRENT_VERSION}m + python${_CURRENT_VERSION}u + python${_CURRENT_VERSION} + ) + endif() + + # For backward compatibility, set PYTHON_INCLUDE_PATH. + set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}") + + if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h") + file(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str + REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"") + string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1" + PYTHONLIBS_VERSION_STRING "${python_version_str}") + unset(python_version_str) + endif() + + if(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR) + break() + endif() +endforeach() + +mark_as_advanced( + PYTHON_DEBUG_LIBRARY + PYTHON_LIBRARY + PYTHON_INCLUDE_DIR +) + +# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the +# cache entries because they are meant to specify the location of a single +# library. We now set the variables listed by the documentation for this +# module. +set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") +set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") + +# These variables have been historically named in this module different from +# what SELECT_LIBRARY_CONFIGURATIONS() expects. +set(PYTHON_LIBRARY_DEBUG "${PYTHON_DEBUG_LIBRARY}") +set(PYTHON_LIBRARY_RELEASE "${PYTHON_LIBRARY}") +include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) +select_library_configurations(PYTHON) +# SELECT_LIBRARY_CONFIGURATIONS() sets ${PREFIX}_FOUND if it has a library. +# Unset this, this prefix doesn't match the module prefix, they are different +# for historical reasons. +unset(PYTHON_FOUND) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PythonLibs + REQUIRED_VARS PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS + VERSION_VAR PYTHONLIBS_VERSION_STRING) + +# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python. +# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include +# in your sources to initialize the static python modules +function(PYTHON_ADD_MODULE _NAME ) + get_property(_TARGET_SUPPORTS_SHARED_LIBS + GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS) + option(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) + option(PYTHON_MODULE_${_NAME}_BUILD_SHARED + "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS}) + + # Mark these options as advanced + mark_as_advanced(PYTHON_ENABLE_MODULE_${_NAME} + PYTHON_MODULE_${_NAME}_BUILD_SHARED) + + if(PYTHON_ENABLE_MODULE_${_NAME}) + if(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + set(PY_MODULE_TYPE MODULE) + else() + set(PY_MODULE_TYPE STATIC) + set_property(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME}) + endif() + + set_property(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME}) + add_library(${_NAME} ${PY_MODULE_TYPE} ${ARGN}) +# target_link_libraries(${_NAME} ${PYTHON_LIBRARIES}) + + if(PYTHON_MODULE_${_NAME}_BUILD_SHARED) + set_target_properties(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}") + if(WIN32 AND NOT CYGWIN) + set_target_properties(${_NAME} PROPERTIES SUFFIX ".pyd") + endif() + endif() + + endif() +endfunction() + +function(PYTHON_WRITE_MODULES_HEADER _filename) + + get_property(PY_STATIC_MODULES_LIST GLOBAL PROPERTY PY_STATIC_MODULES_LIST) + + get_filename_component(_name "${_filename}" NAME) + string(REPLACE "." "_" _name "${_name}") + string(TOUPPER ${_name} _nameUpper) + set(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename}) + + set(_filenameTmp "${_filename}.in") + file(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n") + file(APPEND ${_filenameTmp} +"#ifndef ${_nameUpper} +#define ${_nameUpper} + +#include <Python.h> + +#ifdef __cplusplus +extern \"C\" { +#endif /* __cplusplus */ + +") + + foreach(_currentModule ${PY_STATIC_MODULES_LIST}) + file(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n") + endforeach() + + file(APPEND ${_filenameTmp} +"#ifdef __cplusplus +} +#endif /* __cplusplus */ + +") + + + foreach(_currentModule ${PY_STATIC_MODULES_LIST}) + file(APPEND ${_filenameTmp} "int ${_name}_${_currentModule}(void) \n{\n static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n") + endforeach() + + file(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n") + foreach(_currentModule ${PY_STATIC_MODULES_LIST}) + file(APPEND ${_filenameTmp} " ${_name}_${_currentModule}();\n") + endforeach() + file(APPEND ${_filenameTmp} "}\n\n") + file(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n") + +# with configure_file() cmake complains that you may not use a file created using file(WRITE) as input file for configure_file() + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET) + +endfunction() diff --git a/CMakeModules/FindSubversion.cmake b/CMakeModules/FindSubversion.cmake new file mode 100644 index 0000000..31f20c2 --- /dev/null +++ b/CMakeModules/FindSubversion.cmake @@ -0,0 +1,140 @@ +# +# From CMake 2.6.1 +# + +# +# - Extract information from a subversion working copy +# The module defines the following variables: +# Subversion_SVN_EXECUTABLE - path to svn command line client +# Subversion_VERSION_SVN - version of svn command line client +# Subversion_FOUND - true if the command line client was found +# If the command line client executable is found the macro +# Subversion_WC_INFO(<dir> <var-prefix>) +# is defined to extract information of a subversion working copy at +# a given location. The macro defines the following variables: +# <var-prefix>_WC_URL - url of the repository (at <dir>) +# <var-prefix>_WC_ROOT - root url of the repository +# <var-prefix>_WC_REVISION - current revision +# <var-prefix>_WC_LAST_CHANGED_AUTHOR - author of last commit +# <var-prefix>_WC_LAST_CHANGED_DATE - date of last commit +# <var-prefix>_WC_LAST_CHANGED_REV - revision of last commit +# <var-prefix>_WC_LAST_CHANGED_LOG - last log of base revision +# <var-prefix>_WC_INFO - output of command `svn info <dir>' +# Example usage: +# FIND_PACKAGE(Subversion) +# IF(Subversion_FOUND) +# Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project) +# MESSAGE("Current revision is ${Project_WC_REVISION}") +# Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project) +# MESSAGE("Last changed log is ${Project_LAST_CHANGED_LOG}") +# ENDIF(Subversion_FOUND) + +# Copyright (c) 2006, Tristan Carel +# All rights reserved. +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the University of California, Berkeley nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# $Id: FindSubversion.cmake,v 1.2.2.3 2008-05-23 20:09:34 hoffman Exp $ + +SET(Subversion_FOUND FALSE) +SET(Subversion_SVN_FOUND FALSE) + +FIND_PROGRAM(Subversion_SVN_EXECUTABLE svn + DOC "subversion command line client") +MARK_AS_ADVANCED(Subversion_SVN_EXECUTABLE) + +IF(Subversion_SVN_EXECUTABLE) + SET(Subversion_SVN_FOUND TRUE) + SET(Subversion_FOUND TRUE) + + MACRO(Subversion_WC_INFO dir prefix) + # the subversion commands should be executed with the C locale, otherwise + # the message (which are parsed) may be translated, Alex + SET(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") + SET(ENV{LC_ALL} C) + + EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} --version + WORKING_DIRECTORY ${dir} + OUTPUT_VARIABLE Subversion_VERSION_SVN + OUTPUT_STRIP_TRAILING_WHITESPACE) + + EXECUTE_PROCESS(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir} + OUTPUT_VARIABLE ${prefix}_WC_INFO + ERROR_VARIABLE Subversion_svn_info_error + RESULT_VARIABLE Subversion_svn_info_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + IF(NOT ${Subversion_svn_info_result} EQUAL 0) + MESSAGE(STATUS "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}") + ELSE(NOT ${Subversion_svn_info_result} EQUAL 0) + + STRING(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" + "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") + STRING(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" + "\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}") + STRING(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*" + "\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}") + STRING(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*" + "\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR "${${prefix}_WC_INFO}") + STRING(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*" + "\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}") + STRING(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*" + "\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}") + + ENDIF(NOT ${Subversion_svn_info_result} EQUAL 0) + + # restore the previous LC_ALL + SET(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL}) + + ENDMACRO(Subversion_WC_INFO) + + MACRO(Subversion_WC_LOG dir prefix) + # This macro can block if the certificate is not signed: + # svn ask you to accept the certificate and wait for your answer + # This macro requires a svn server network access (Internet most of the time) + # and can also be slow since it access the svn server + EXECUTE_PROCESS(COMMAND + ${Subversion_SVN_EXECUTABLE} log -r BASE ${dir} + OUTPUT_VARIABLE ${prefix}_LAST_CHANGED_LOG + ERROR_VARIABLE Subversion_svn_log_error + RESULT_VARIABLE Subversion_svn_log_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + IF(NOT ${Subversion_svn_log_result} EQUAL 0) + MESSAGE(STATUS "Command \"${Subversion_SVN_EXECUTABLE} log -r BASE ${dir}\" failed with output:\n${Subversion_svn_log_error}") + ENDIF(NOT ${Subversion_svn_log_result} EQUAL 0) + ENDMACRO(Subversion_WC_LOG) + +ENDIF(Subversion_SVN_EXECUTABLE) + +IF(NOT Subversion_FOUND) + IF(NOT Subversion_FIND_QUIETLY) + MESSAGE(STATUS "Subversion was not found.") + ELSE(NOT Subversion_FIND_QUIETLY) + IF(Subversion_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Subversion was not found.") + ENDIF(Subversion_FIND_REQUIRED) + ENDIF(NOT Subversion_FIND_QUIETLY) +ENDIF(NOT Subversion_FOUND) + +# FindSubversion.cmake ends here. diff --git a/CMakeModules/FindZLIB.cmake.unused b/CMakeModules/FindZLIB.cmake.unused new file mode 100644 index 0000000..0fdc315 --- /dev/null +++ b/CMakeModules/FindZLIB.cmake.unused @@ -0,0 +1,39 @@ +# +# From CMake 2.6.1 + some path changes +# + +# - Find zlib +# Find the native ZLIB includes and library +# +# ZLIB_INCLUDE_DIR - where to find zlib.h, etc. +# ZLIB_LIBRARIES - List of libraries when using zlib. +# ZLIB_FOUND - True if zlib found. + +IF(MSYS) + SET(ZLIB_DIR_SEARCH + c:/msys/1.0 + ) +ENDIF(MSYS) + +IF (ZLIB_INCLUDE_DIR) + # Already in cache, be silent + SET(ZLIB_FIND_QUIETLY TRUE) +ENDIF (ZLIB_INCLUDE_DIR) + +FIND_PATH(ZLIB_INCLUDE_DIR zlib.h PATHS ${ZLIB_DIR_SEARCH}/local/include) + +SET(ZLIB_NAMES z zlib zdll) +FIND_LIBRARY(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} PATHS ${ZLIB_DIR_SEARCH}/local/lib) + +# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB DEFAULT_MSG ZLIB_LIBRARY ZLIB_INCLUDE_DIR) + +IF(ZLIB_FOUND) + SET( ZLIB_LIBRARIES ${ZLIB_LIBRARY} ) +ELSE(ZLIB_FOUND) + SET( ZLIB_LIBRARIES ) +ENDIF(ZLIB_FOUND) + +MARK_AS_ADVANCED( ZLIB_LIBRARY ZLIB_INCLUDE_DIR ) diff --git a/CMakeModules/FindwxWidgets.cmake b/CMakeModules/FindwxWidgets.cmake new file mode 100644 index 0000000..b93035d --- /dev/null +++ b/CMakeModules/FindwxWidgets.cmake @@ -0,0 +1,1145 @@ +# - Find a wxWidgets (a.k.a., wxWindows) installation. +# This module finds if wxWidgets is installed and selects a default +# configuration to use. wxWidgets is a modular library. To specify the +# modules that you will use, you need to name them as components to +# the package: +# +# find_package(wxWidgets COMPONENTS core base ...) +# +# There are two search branches: a windows style and a unix style. For +# windows, the following variables are searched for and set to +# defaults in case of multiple choices. Change them if the defaults +# are not desired (i.e., these are the only variables you should +# change to select a configuration): +# +# wxWidgets_ROOT_DIR - Base wxWidgets directory +# (e.g., C:/wxWidgets-2.6.3). +# wxWidgets_LIB_DIR - Path to wxWidgets libraries +# (e.g., C:/wxWidgets-2.6.3/lib/vc_lib). +# wxWidgets_CONFIGURATION - Configuration to use +# (e.g., msw, mswd, mswu, mswunivud, etc.) +# wxWidgets_EXCLUDE_COMMON_LIBRARIES +# - Set to TRUE to exclude linking of +# commonly required libs (e.g., png tiff +# jpeg zlib regex expat). +# +# For unix style it uses the wx-config utility. You can select between +# debug/release, unicode/ansi, universal/non-universal, and +# static/shared in the QtDialog or ccmake interfaces by turning ON/OFF +# the following variables: +# +# wxWidgets_USE_DEBUG +# wxWidgets_USE_UNICODE +# wxWidgets_USE_UNIVERSAL +# wxWidgets_USE_STATIC +# +# There is also a wxWidgets_CONFIG_OPTIONS variable for all other +# options that need to be passed to the wx-config utility. For +# example, to use the base toolkit found in the /usr/local path, set +# the variable (before calling the FIND_PACKAGE command) as such: +# +# set(wxWidgets_CONFIG_OPTIONS --toolkit=base --prefix=/usr) +# +# The following are set after the configuration is done for both +# windows and unix style: +# +# wxWidgets_FOUND - Set to TRUE if wxWidgets was found. +# wxWidgets_INCLUDE_DIRS - Include directories for WIN32 +# i.e., where to find "wx/wx.h" and +# "wx/setup.h"; possibly empty for unices. +# wxWidgets_LIBRARIES - Path to the wxWidgets libraries. +# wxWidgets_LIBRARY_DIRS - compile time link dirs, useful for +# rpath on UNIX. Typically an empty string +# in WIN32 environment. +# wxWidgets_DEFINITIONS - Contains defines required to compile/link +# against WX, e.g. WXUSINGDLL +# wxWidgets_DEFINITIONS_DEBUG- Contains defines required to compile/link +# against WX debug builds, e.g. __WXDEBUG__ +# wxWidgets_CXX_FLAGS - Include dirs and compiler flags for +# unices, empty on WIN32. Essentially +# "`wx-config --cxxflags`". +# wxWidgets_USE_FILE - Convenience include file. +# +# Sample usage: +# # Note that for MinGW users the order of libs is important! +# find_package(wxWidgets COMPONENTS net gl core base) +# if(wxWidgets_FOUND) +# include(${wxWidgets_USE_FILE}) +# # and for each of your dependent executable/library targets: +# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) +# endif(wxWidgets_FOUND) +# +# If wxWidgets is required (i.e., not an optional part): +# find_package(wxWidgets REQUIRED net gl core base) +# include(${wxWidgets_USE_FILE}) +# # and for each of your dependent executable/library targets: +# target_link_libraries(<YourTarget> ${wxWidgets_LIBRARIES}) +# +# If a wxWidgets version or greater is required: +# find_package(wxWidgets 2.8.12 COMPONENTS net gl core base REQUIRED) +# +# If specific wxWidgets version is required: +# find_package(wxWidgets 2.8.12 EXACT COMPONENTS net gl core base REQUIRED) +# +#============================================================================= +# Copyright 2004-2009 Kitware, Inc. +# Copyright 2007-2009 Miguel A. Figueroa-Villanueva <miguelf at ieee dot org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# +# FIXME: check this and provide a correct sample usage... +# Remember to connect back to the upper text. +# Sample usage with monolithic wx build: +# +# find_package(wxWidgets COMPONENTS mono) +# ... + +# NOTES +# +# This module has been tested on the WIN32 platform with wxWidgets +# 2.6.2, 2.6.3, and 2.5.3. However, it has been designed to +# easily extend support to all possible builds, e.g., static/shared, +# debug/release, unicode, universal, multilib/monolithic, etc.. +# +# If you want to use the module and your build type is not supported +# out-of-the-box, please contact me to exchange information on how +# your system is setup and I'll try to add support for it. +# +# AUTHOR +# +# Miguel A. Figueroa-Villanueva (miguelf at ieee dot org). +# Jan Woetzel (jw at mip.informatik.uni-kiel.de). +# +# Based on previous works of: +# Jan Woetzel (FindwxWindows.cmake), +# Jorgen Bodde and Jerry Fath (FindwxWin.cmake). + +# TODO/ideas +# +# (1) Option/Setting to use all available wx libs +# In contrast to expert developer who lists the +# minimal set of required libs in wxWidgets_USE_LIBS +# there is the newbie user: +# - who just wants to link against WX with more 'magic' +# - doesn't know the internal structure of WX or how it was built, +# in particular if it is monolithic or not +# - want to link against all available WX libs +# Basically, the intent here is to mimic what wx-config would do by +# default (i.e., `wx-config --libs`). +# +# Possible solution: +# Add a reserved keyword "std" that initializes to what wx-config +# would default to. If the user has not set the wxWidgets_USE_LIBS, +# default to "std" instead of "base core" as it is now. To implement +# "std" will basically boil down to a FOR_EACH lib-FOUND, but maybe +# checking whether a minimal set was found. + + +# FIXME: This and all the dbg_msg calls should be removed after the +# module stabilizes. +# +# Helper macro to control the debugging output globally. There are +# two versions for controlling how verbose your output should be. +macro(dbg_msg _MSG) +# message(STATUS "${_MSG}") +endmacro(dbg_msg) +macro(dbg_msg_v _MSG) +# message(STATUS "${_MSG}") +endmacro(dbg_msg_v) + +# Clear return values in case the module is loaded more than once. +set(wxWidgets_FOUND FALSE) +set(wxWidgets_INCLUDE_DIRS "") +set(wxWidgets_LIBRARIES "") +set(wxWidgets_LIBRARY_DIRS "") +set(wxWidgets_CXX_FLAGS "") + +# Using SYSTEM with INCLUDE_DIRECTORIES in conjunction with wxWidgets on +# the Mac produces compiler errors. Set wxWidgets_INCLUDE_DIRS_NO_SYSTEM +# to prevent UsewxWidgets.cmake from using SYSTEM. +# +# See cmake mailing list discussions for more info: +# http://www.cmake.org/pipermail/cmake/2008-April/021115.html +# http://www.cmake.org/pipermail/cmake/2008-April/021146.html +# +if(APPLE) + set(wxWidgets_INCLUDE_DIRS_NO_SYSTEM 1) +endif(APPLE) + +# DEPRECATED: This is a patch to support the DEPRECATED use of +# wxWidgets_USE_LIBS. +# +# If wxWidgets_USE_LIBS is set: +# - if using <components>, then override wxWidgets_USE_LIBS +# - else set wxWidgets_FIND_COMPONENTS to wxWidgets_USE_LIBS +if(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS) + set(wxWidgets_FIND_COMPONENTS ${wxWidgets_USE_LIBS}) +endif(wxWidgets_USE_LIBS AND NOT wxWidgets_FIND_COMPONENTS) +dbg_msg("wxWidgets_FIND_COMPONENTS : ${wxWidgets_FIND_COMPONENTS}") + +# Add the convenience use file if available. +# +# Get dir of this file which may reside in: +# - CMAKE_MAKE_ROOT/Modules on CMake installation +# - CMAKE_MODULE_PATH if user prefers his own specialized version +set(wxWidgets_USE_FILE "") +get_filename_component( + wxWidgets_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +# Prefer an existing customized version, but the user might override +# the FindwxWidgets module and not the UsewxWidgets one. +if(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") + set(wxWidgets_USE_FILE + "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") +else(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") + set(wxWidgets_USE_FILE UsewxWidgets) +endif(EXISTS "${wxWidgets_CURRENT_LIST_DIR}/UsewxWidgets.cmake") + +#===================================================================== +#===================================================================== + + +if(WIN32 AND NOT CYGWIN AND NOT MSYS AND NOT CMAKE_HOST_UNIX ) + dbg_msg( "setting win32 style" ) + set(wxWidgets_FIND_STYLE "win32") +else() + if(CMAKE_HOST_UNIX OR MSYS) + dbg_msg( "unix style" ) + set(wxWidgets_FIND_STYLE "unix") + endif() +endif() + +#===================================================================== +# WIN32_FIND_STYLE +#===================================================================== +if(wxWidgets_FIND_STYLE STREQUAL "win32") + dbg_msg("Using win32 path") + + # Useful common wx libs needed by almost all components. + set(wxWidgets_COMMON_LIBRARIES png tiff jpeg zlib regex expat) + + # DEPRECATED: Use find_package(wxWidgets COMPONENTS mono) instead. + if(NOT wxWidgets_FIND_COMPONENTS) + if(wxWidgets_USE_MONOLITHIC) + set(wxWidgets_FIND_COMPONENTS mono) + else(wxWidgets_USE_MONOLITHIC) + set(wxWidgets_FIND_COMPONENTS core base) # this is default + endif(wxWidgets_USE_MONOLITHIC) + endif(NOT wxWidgets_FIND_COMPONENTS) + + # Add the common (usually required libs) unless + # wxWidgets_EXCLUDE_COMMON_LIBRARIES has been set. + if(NOT wxWidgets_EXCLUDE_COMMON_LIBRARIES) + list(APPEND wxWidgets_FIND_COMPONENTS + ${wxWidgets_COMMON_LIBRARIES}) + endif(NOT wxWidgets_EXCLUDE_COMMON_LIBRARIES) + + #------------------------------------------------------------------- + # WIN32: Helper MACROS + #------------------------------------------------------------------- + # + # Get filename components for a configuration. For example, + # if _CONFIGURATION = mswunivud, then _UNV=univ, _UCD=u _DBG=d + # if _CONFIGURATION = mswu, then _UNV="", _UCD=u _DBG="" + # + macro(wx_get_name_components _CONFIGURATION _UNV _UCD _DBG) + string(REGEX MATCH "univ" ${_UNV} "${_CONFIGURATION}") + string(REGEX REPLACE "msw.*(u)[d]*$" "u" ${_UCD} "${_CONFIGURATION}") + if(${_UCD} STREQUAL ${_CONFIGURATION}) + set(${_UCD} "") + endif(${_UCD} STREQUAL ${_CONFIGURATION}) + string(REGEX MATCH "d$" ${_DBG} "${_CONFIGURATION}") + endmacro(wx_get_name_components) + + # + # Find libraries associated to a configuration. + # + macro(wx_find_libs _UNV _UCD _DBG) + dbg_msg_v("m_unv = ${_UNV}") + dbg_msg_v("m_ucd = ${_UCD}") + dbg_msg_v("m_dbg = ${_DBG}") + + # FIXME: What if both regex libs are available. regex should be + # found outside the loop and only wx${LIB}${_UCD}${_DBG}. + # Find wxWidgets common libraries. + foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla) + find_library(WX_${LIB}${_DBG} + NAMES + wx${LIB}${_UCD}${_DBG} # for regex + wx${LIB}${_DBG} + PATHS ${WX_LIB_DIR} + NO_DEFAULT_PATH + ) + mark_as_advanced(WX_${LIB}${_DBG}) + endforeach(LIB) + + dbg_msg( "WX_LIB_DIR:${WX_LIB_DIR}" ) + + # Find wxWidgets multilib base libraries. + find_library(WX_base${_DBG} + NAMES + wxbase31${_UCD}${_DBG} + wxbase30${_UCD}${_DBG} + wxbase29${_UCD}${_DBG} + wxbase28${_UCD}${_DBG} + wxbase27${_UCD}${_DBG} + wxbase26${_UCD}${_DBG} + wxbase25${_UCD}${_DBG} + PATHS ${WX_LIB_DIR} + NO_DEFAULT_PATH + ) + mark_as_advanced(WX_base${_DBG}) + foreach(LIB net odbc xml) + find_library(WX_${LIB}${_DBG} + NAMES + wxbase31${_UCD}${_DBG}_${LIB} + wxbase30${_UCD}${_DBG}_${LIB} + wxbase29${_UCD}${_DBG}_${LIB} + wxbase28${_UCD}${_DBG}_${LIB} + wxbase27${_UCD}${_DBG}_${LIB} + wxbase26${_UCD}${_DBG}_${LIB} + wxbase25${_UCD}${_DBG}_${LIB} + PATHS ${WX_LIB_DIR} + NO_DEFAULT_PATH + ) + mark_as_advanced(WX_${LIB}${_DBG}) + endforeach(LIB) + + # Find wxWidgets monolithic library. + find_library(WX_mono${_DBG} + NAMES + wxmsw${_UNV}31${_UCD}${_DBG} + wxmsw${_UNV}30${_UCD}${_DBG} + wxmsw${_UNV}29${_UCD}${_DBG} + wxmsw${_UNV}28${_UCD}${_DBG} + wxmsw${_UNV}27${_UCD}${_DBG} + wxmsw${_UNV}26${_UCD}${_DBG} + wxmsw${_UNV}25${_UCD}${_DBG} + PATHS ${WX_LIB_DIR} + NO_DEFAULT_PATH + ) + mark_as_advanced(WX_mono${_DBG}) + + # Find wxWidgets multilib libraries. + foreach(LIB core adv aui html media xrc dbgrid gl qa richtext + webview stc ribbon propgrid) + find_library(WX_${LIB}${_DBG} + NAMES + wxmsw${_UNV}31${_UCD}${_DBG}_${LIB} + wxmsw${_UNV}30${_UCD}${_DBG}_${LIB} + wxmsw${_UNV}29${_UCD}${_DBG}_${LIB} + wxmsw${_UNV}28${_UCD}${_DBG}_${LIB} + wxmsw${_UNV}27${_UCD}${_DBG}_${LIB} + wxmsw${_UNV}26${_UCD}${_DBG}_${LIB} + wxmsw${_UNV}25${_UCD}${_DBG}_${LIB} + PATHS ${WX_LIB_DIR} + NO_DEFAULT_PATH + ) + mark_as_advanced(WX_${LIB}${_DBG}) + endforeach(LIB) + endmacro(wx_find_libs) + + # + # Clear all library paths, so that FIND_LIBRARY refinds them. + # + # Clear a lib, reset its found flag, and mark as advanced. + macro(wx_clear_lib _LIB) + set(${_LIB} "${_LIB}-NOTFOUND" CACHE FILEPATH "Cleared." FORCE) + set(${_LIB}_FOUND FALSE) + mark_as_advanced(${_LIB}) + endmacro(wx_clear_lib) + # Clear all debug or release library paths (arguments are "d" or ""). + macro(wx_clear_all_libs _DBG) + # Clear wxWidgets common libraries. + foreach(LIB ${wxWidgets_COMMON_LIBRARIES} scintilla) + wx_clear_lib(WX_${LIB}${_DBG}) + endforeach(LIB) + + # Clear wxWidgets multilib base libraries. + wx_clear_lib(WX_base${_DBG}) + foreach(LIB net odbc xml) + wx_clear_lib(WX_${LIB}${_DBG}) + endforeach(LIB) + + # Clear wxWidgets monolithic library. + wx_clear_lib(WX_mono${_DBG}) + + # Clear wxWidgets multilib libraries. + foreach(LIB core adv aui html media xrc dbgrid gl qa richtext + webview stc ribbon propgrid) + wx_clear_lib(WX_${LIB}${_DBG}) + endforeach(LIB) + endmacro(wx_clear_all_libs) + # Clear all wxWidgets debug libraries. + macro(wx_clear_all_dbg_libs) + wx_clear_all_libs("d") + endmacro(wx_clear_all_dbg_libs) + # Clear all wxWidgets release libraries. + macro(wx_clear_all_rel_libs) + wx_clear_all_libs("") + endmacro(wx_clear_all_rel_libs) + + # + # Set the wxWidgets_LIBRARIES variable. + # Also, Sets output variable wxWidgets_FOUND to FALSE if it fails. + # + macro(wx_set_libraries _LIBS _DBG) + dbg_msg_v("Looking for ${${_LIBS}}") + if(WX_USE_REL_AND_DBG) + foreach(LIB ${${_LIBS}}) + dbg_msg_v("Searching for ${LIB} and ${LIB}d") + dbg_msg_v("WX_${LIB} : ${WX_${LIB}}") + dbg_msg_v("WX_${LIB}d : ${WX_${LIB}d}") + if(WX_${LIB} AND WX_${LIB}d) + dbg_msg_v("Found ${LIB} and ${LIB}d") + list(APPEND wxWidgets_LIBRARIES + debug ${WX_${LIB}d} optimized ${WX_${LIB}} + ) + else(WX_${LIB} AND WX_${LIB}d) + dbg_msg_v("- not found due to missing WX_${LIB}=${WX_${LIB}} or WX_${LIB}d=${WX_${LIB}d}") + set(wxWidgets_FOUND FALSE) + endif(WX_${LIB} AND WX_${LIB}d) + endforeach(LIB) + else(WX_USE_REL_AND_DBG) + foreach(LIB ${${_LIBS}}) + dbg_msg_v("Searching for ${LIB}${_DBG}") + dbg_msg_v("WX_${LIB}${_DBG} : ${WX_${LIB}${_DBG}}") + if(WX_${LIB}${_DBG}) + dbg_msg_v("Found ${LIB}${_DBG}") + list(APPEND wxWidgets_LIBRARIES ${WX_${LIB}${_DBG}}) + else(WX_${LIB}${_DBG}) + dbg_msg_v( + "- not found due to missing WX_${LIB}${_DBG}=${WX_${LIB}${_DBG}}") + set(wxWidgets_FOUND FALSE) + endif(WX_${LIB}${_DBG}) + endforeach(LIB) + endif(WX_USE_REL_AND_DBG) + + dbg_msg_v("OpenGL") + list(FIND ${_LIBS} gl WX_USE_GL) + if(NOT WX_USE_GL EQUAL -1) + dbg_msg_v("- is required.") + list(APPEND wxWidgets_LIBRARIES opengl32 glu32) + endif(NOT WX_USE_GL EQUAL -1) + + list(APPEND wxWidgets_LIBRARIES winmm comctl32 rpcrt4 wsock32) + endmacro(wx_set_libraries) + + #------------------------------------------------------------------- + # WIN32: Start actual work. + #------------------------------------------------------------------- + + # Look for an installation tree. + find_path(wxWidgets_ROOT_DIR + NAMES include/wx/wx.h + PATHS + $ENV{wxWidgets_ROOT_DIR} + $ENV{WXWIN} + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\wxWidgets_is1;Inno Setup: App Path]" # WX 2.6.x + C:/ + D:/ + $ENV{ProgramFiles} + PATH_SUFFIXES + wxWidgets-3.0.2 + wxWidgets-3.0.1 + wxWidgets-3.0.0 + wxWidgets-2.9.5 + wxWidgets-2.9.4 + wxWidgets-2.9.3 + wxWidgets-2.9.2 + wxWidgets-2.9.1 + wxWidgets-2.9.0 + wxWidgets-2.8.9 + wxWidgets-2.8.8 + wxWidgets-2.8.7 + wxWidgets-2.8.6 + wxWidgets-2.8.5 + wxWidgets-2.8.4 + wxWidgets-2.8.3 + wxWidgets-2.8.2 + wxWidgets-2.8.1 + wxWidgets-2.8.0 + wxWidgets-2.7.4 + wxWidgets-2.7.3 + wxWidgets-2.7.2 + wxWidgets-2.7.1 + wxWidgets-2.7.0 + wxWidgets-2.7.0-1 + wxWidgets-2.6.4 + wxWidgets-2.6.3 + wxWidgets-2.6.2 + wxWidgets-2.6.1 + wxWidgets-2.5.4 + wxWidgets-2.5.3 + wxWidgets-2.5.2 + wxWidgets-2.5.1 + wxWidgets + DOC "wxWidgets base/installation directory?" + ) + + # If wxWidgets_ROOT_DIR changed, clear lib dir. + if(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR) + dbg_msg( "WX_ROOT_DIR != wxWidgets_ROOT_DIR" ) + + set(WX_ROOT_DIR ${wxWidgets_ROOT_DIR} + CACHE INTERNAL "wxWidgets_ROOT_DIR") + set(wxWidgets_LIB_DIR "wxWidgets_LIB_DIR-NOTFOUND" + CACHE PATH "Cleared." FORCE) + endif(NOT WX_ROOT_DIR STREQUAL wxWidgets_ROOT_DIR) + + if(WX_ROOT_DIR) + dbg_msg( "WX_ROOT_DIR == wxWidgets_ROOT_DIR" ) + + # Select one default tree inside the already determined wx tree. + # Prefer static/shared order usually consistent with build + # settings. + if(MINGW) + dbg_msg( "MINGW" ) + set(WX_LIB_DIR_PREFIX gcc) + else(MINGW) + set(WX_LIB_DIR_PREFIX vc) + endif(MINGW) + if(BUILD_SHARED_LIBS) + dbg_msg( "BUILD_SHARED_LIBS" ) + find_path(wxWidgets_LIB_DIR + NAMES + msw/wx/setup.h + mswd/wx/setup.h + mswu/wx/setup.h + mswud/wx/setup.h + mswuniv/wx/setup.h + mswunivd/wx/setup.h + mswunivu/wx/setup.h + mswunivud/wx/setup.h + PATHS + ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll # prefer shared + ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib + DOC "Path to wxWidgets libraries?" + NO_DEFAULT_PATH + ) + else(BUILD_SHARED_LIBS) + dbg_msg( "!BUILD_SHARED_LIBS WX_LIB_DIR:${WX_LIB_DIR}" ) + find_path(wxWidgets_LIB_DIR + NAMES + msw/wx/setup.h + mswd/wx/setup.h + mswu/wx/setup.h + mswud/wx/setup.h + mswuniv/wx/setup.h + mswunivd/wx/setup.h + mswunivu/wx/setup.h + mswunivud/wx/setup.h + PATHS + ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_lib # prefer static + ${WX_ROOT_DIR}/lib/${WX_LIB_DIR_PREFIX}_dll + DOC "Path to wxWidgets libraries?" + NO_DEFAULT_PATH + ) + endif(BUILD_SHARED_LIBS) + + # If wxWidgets_LIB_DIR changed, clear all libraries. + if(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR) + set(WX_LIB_DIR ${wxWidgets_LIB_DIR} CACHE INTERNAL "wxWidgets_LIB_DIR") + wx_clear_all_dbg_libs() + wx_clear_all_rel_libs() + endif(NOT WX_LIB_DIR STREQUAL wxWidgets_LIB_DIR) + + if(WX_LIB_DIR) + # If building shared libs, define WXUSINGDLL to use dllimport. + if(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*") + set(wxWidgets_DEFINITIONS WXUSINGDLL) + dbg_msg_v("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}") + endif(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*") + + # Search for available configuration types. + foreach(CFG mswunivud mswunivd mswud mswd mswunivu mswuniv mswu msw) + set(WX_${CFG}_FOUND FALSE) + if(EXISTS ${WX_LIB_DIR}/${CFG}) + list(APPEND WX_CONFIGURATION_LIST ${CFG}) + set(WX_${CFG}_FOUND TRUE) + set(WX_CONFIGURATION ${CFG}) + endif(EXISTS ${WX_LIB_DIR}/${CFG}) + endforeach(CFG) + dbg_msg_v("WX_CONFIGURATION_LIST=${WX_CONFIGURATION_LIST}") + + if(WX_CONFIGURATION) + set(wxWidgets_FOUND TRUE) + + # If the selected configuration wasn't found force the default + # one. Otherwise, use it but still force a refresh for + # updating the doc string with the current list of available + # configurations. + if(NOT WX_${wxWidgets_CONFIGURATION}_FOUND) + set(wxWidgets_CONFIGURATION ${WX_CONFIGURATION} CACHE STRING + "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE) + else(NOT WX_${wxWidgets_CONFIGURATION}_FOUND) + set(wxWidgets_CONFIGURATION ${wxWidgets_CONFIGURATION} CACHE STRING + "Set wxWidgets configuration (${WX_CONFIGURATION_LIST})" FORCE) + endif(NOT WX_${wxWidgets_CONFIGURATION}_FOUND) + + # If release config selected, and both release/debug exist. + if(WX_${wxWidgets_CONFIGURATION}d_FOUND) + OPTION(wxWidgets_USE_REL_AND_DBG + "Use release and debug configurations?" TRUE) + set(WX_USE_REL_AND_DBG ${wxWidgets_USE_REL_AND_DBG}) + else(WX_${wxWidgets_CONFIGURATION}d_FOUND) + # If the option exists (already in cache), force it false. + if(wxWidgets_USE_REL_AND_DBG) + set(wxWidgets_USE_REL_AND_DBG FALSE CACHE BOOL + "No ${wxWidgets_CONFIGURATION}d found." FORCE) + endif(wxWidgets_USE_REL_AND_DBG) + set(WX_USE_REL_AND_DBG FALSE) + endif(WX_${wxWidgets_CONFIGURATION}d_FOUND) + + # Get configuration parameters from the name. + wx_get_name_components(${wxWidgets_CONFIGURATION} UNV UCD DBG) + + # Set wxWidgets lib setup include directory. + if(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h) + set(wxWidgets_INCLUDE_DIRS + ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}) + else(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h) + dbg_msg("wxWidgets_FOUND FALSE because ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h does not exists.") + set(wxWidgets_FOUND FALSE) + endif(EXISTS ${WX_LIB_DIR}/${wxWidgets_CONFIGURATION}/wx/setup.h) + + # Set wxWidgets main include directory. + if(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) + list(APPEND wxWidgets_INCLUDE_DIRS ${WX_ROOT_DIR}/include) + else(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) + dbg_msg("wxWidgets_FOUND FALSE because WX_ROOT_DIR=${WX_ROOT_DIR} has no ${WX_ROOT_DIR}/include/wx/wx.h") + set(wxWidgets_FOUND FALSE) + endif(EXISTS ${WX_ROOT_DIR}/include/wx/wx.h) + + # Find wxWidgets libraries. + wx_find_libs("${UNV}" "${UCD}" "${DBG}") + if(WX_USE_REL_AND_DBG) + wx_find_libs("${UNV}" "${UCD}" "d") + endif(WX_USE_REL_AND_DBG) + + # Settings for requested libs (i.e., include dir, libraries, etc.). + wx_set_libraries(wxWidgets_FIND_COMPONENTS "${DBG}") + + # Add necessary definitions for unicode builds + if("${UCD}" STREQUAL "u") + list(APPEND wxWidgets_DEFINITIONS UNICODE _UNICODE) + endif("${UCD}" STREQUAL "u") + + # Add necessary definitions for debug builds + set(wxWidgets_DEFINITIONS_DEBUG _DEBUG __WXDEBUG__) + + endif(WX_CONFIGURATION) + endif(WX_LIB_DIR) + endif(WX_ROOT_DIR) + +#===================================================================== +# UNIX_FIND_STYLE +#===================================================================== +else(wxWidgets_FIND_STYLE STREQUAL "win32") + dbg_msg("NOT win32 path") + + if(wxWidgets_FIND_STYLE STREQUAL "unix") + dbg_msg("unix find style") + + #----------------------------------------------------------------- + # UNIX: Helper MACROS + #----------------------------------------------------------------- + # + # Set the default values based on "wx-config --selected-config". + # + macro(wx_config_select_get_default) + execute_process( + COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" + ${wxWidgets_CONFIG_OPTIONS} --selected-config + OUTPUT_VARIABLE _wx_selected_config + RESULT_VARIABLE _wx_result + ERROR_QUIET + ) + if(_wx_result EQUAL 0) + foreach(_opt_name debug static unicode universal) + string(TOUPPER ${_opt_name} _upper_opt_name) + if(_wx_selected_config MATCHES ".*${_opt_name}.*") + set(wxWidgets_DEFAULT_${_upper_opt_name} ON) + else(_wx_selected_config MATCHES ".*${_opt_name}.*") + set(wxWidgets_DEFAULT_${_upper_opt_name} OFF) + endif(_wx_selected_config MATCHES ".*${_opt_name}.*") + endforeach(_opt_name) + else(_wx_result EQUAL 0) + foreach(_upper_opt_name DEBUG STATIC UNICODE UNIVERSAL) + set(wxWidgets_DEFAULT_${_upper_opt_name} OFF) + endforeach(_upper_opt_name) + endif(_wx_result EQUAL 0) + endmacro(wx_config_select_get_default) + + # + # Query a boolean configuration option to determine if the system + # has both builds available. If so, provide the selection option + # to the user. + # + macro(wx_config_select_query_bool _OPT_NAME _OPT_HELP) + execute_process( + COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" + ${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=yes + RESULT_VARIABLE _wx_result_yes + OUTPUT_QUIET + ERROR_QUIET + ) + execute_process( + COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" + ${wxWidgets_CONFIG_OPTIONS} --${_OPT_NAME}=no + RESULT_VARIABLE _wx_result_no + OUTPUT_QUIET + ERROR_QUIET + ) + string(TOUPPER ${_OPT_NAME} _UPPER_OPT_NAME) + if(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0) + OPTION(wxWidgets_USE_${_UPPER_OPT_NAME} + ${_OPT_HELP} ${wxWidgets_DEFAULT_${_UPPER_OPT_NAME}}) + else(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0) + # If option exists (already in cache), force to available one. + if(DEFINED wxWidgets_USE_${_UPPER_OPT_NAME}) + if(_wx_result_yes EQUAL 0) + set(wxWidgets_USE_${_UPPER_OPT_NAME} ON CACHE BOOL ${_OPT_HELP} FORCE) + else(_wx_result_yes EQUAL 0) + set(wxWidgets_USE_${_UPPER_OPT_NAME} OFF CACHE BOOL ${_OPT_HELP} FORCE) + endif(_wx_result_yes EQUAL 0) + endif(DEFINED wxWidgets_USE_${_UPPER_OPT_NAME}) + endif(_wx_result_yes EQUAL 0 AND _wx_result_no EQUAL 0) + endmacro(wx_config_select_query_bool) + + # + # Set wxWidgets_SELECT_OPTIONS to wx-config options for selecting + # among multiple builds. + # + macro(wx_config_select_set_options) + set(wxWidgets_SELECT_OPTIONS ${wxWidgets_CONFIG_OPTIONS}) + foreach(_opt_name debug static unicode universal) + string(TOUPPER ${_opt_name} _upper_opt_name) + if(DEFINED wxWidgets_USE_${_upper_opt_name}) + if(wxWidgets_USE_${_upper_opt_name}) + list(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=yes) + else(wxWidgets_USE_${_upper_opt_name}) + list(APPEND wxWidgets_SELECT_OPTIONS --${_opt_name}=no) + endif(wxWidgets_USE_${_upper_opt_name}) + endif(DEFINED wxWidgets_USE_${_upper_opt_name}) + endforeach(_opt_name) + endmacro(wx_config_select_set_options) + + #----------------------------------------------------------------- + # UNIX: Start actual work. + #----------------------------------------------------------------- + # Support cross-compiling, only search in the target platform. + find_program(wxWidgets_CONFIG_EXECUTABLE wx-config + ONLY_CMAKE_FIND_ROOT_PATH + ) + + if(wxWidgets_CONFIG_EXECUTABLE) + set(wxWidgets_FOUND TRUE) + + # get defaults based on "wx-config --selected-config" + wx_config_select_get_default() + + # for each option: if both builds are available, provide option + wx_config_select_query_bool(debug "Use debug build?") + wx_config_select_query_bool(unicode "Use unicode build?") + wx_config_select_query_bool(universal "Use universal build?") + wx_config_select_query_bool(static "Link libraries statically?") + + # process selection to set wxWidgets_SELECT_OPTIONS + wx_config_select_set_options() + dbg_msg("wxWidgets_SELECT_OPTIONS=${wxWidgets_SELECT_OPTIONS}") + + # run the wx-config program to get cxxflags + execute_process( + COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" + ${wxWidgets_SELECT_OPTIONS} --cxxflags + OUTPUT_VARIABLE wxWidgets_CXX_FLAGS + RESULT_VARIABLE RET + ERROR_QUIET + ) + if(RET EQUAL 0) + string(STRIP "${wxWidgets_CXX_FLAGS}" wxWidgets_CXX_FLAGS) + separate_arguments(wxWidgets_CXX_FLAGS) + + dbg_msg_v("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}") + + # parse definitions from cxxflags; + # drop -D* from CXXFLAGS and the -D prefix + string(REGEX MATCHALL "-D[^;]+" + wxWidgets_DEFINITIONS "${wxWidgets_CXX_FLAGS}") + string(REGEX REPLACE "-D[^;]+(;|$)" "" + wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}") + string(REGEX REPLACE ";$" "" + wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}") + string(REPLACE "-D" "" + wxWidgets_DEFINITIONS "${wxWidgets_DEFINITIONS}") + + # parse include dirs from cxxflags; drop -I prefix + string(REGEX MATCHALL "-I[^;]+" + wxWidgets_INCLUDE_DIRS "${wxWidgets_CXX_FLAGS}") + string(REGEX REPLACE "-I[^;]+;" "" + wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}") + string(REPLACE "-I" "" + wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}") + + # Flags are a string, not a list, fix it here + string(REPLACE ";" " " + wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}") + + dbg_msg_v("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}") + dbg_msg_v("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}") + dbg_msg_v("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}") + + else(RET EQUAL 0) + set(wxWidgets_FOUND FALSE) + dbg_msg_v("${wxWidgets_CONFIG_EXECUTABLE} --cxxflags FAILED with RET=${RET}") + endif(RET EQUAL 0) + + # run the wx-config program to get the libs + # - NOTE: wx-config doesn't verify that the libs requested exist + # it just produces the names. Maybe a TRY_COMPILE would + # be useful here... + string(REPLACE ";" "," + wxWidgets_FIND_COMPONENTS "${wxWidgets_FIND_COMPONENTS}") + execute_process( + COMMAND sh "${wxWidgets_CONFIG_EXECUTABLE}" + ${wxWidgets_SELECT_OPTIONS} --libs ${wxWidgets_FIND_COMPONENTS} + OUTPUT_VARIABLE wxWidgets_LIBRARIES + RESULT_VARIABLE RET + ERROR_QUIET + ) + if(RET EQUAL 0) + string(STRIP "${wxWidgets_LIBRARIES}" wxWidgets_LIBRARIES) + separate_arguments(wxWidgets_LIBRARIES) + string(REPLACE "-framework;" "-framework " + wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}") + string(REPLACE "-arch;" "-arch " + wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}") + string(REPLACE "-isysroot;" "-isysroot " + wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}") + + # extract linkdirs (-L) for rpath (i.e., LINK_DIRECTORIES) + string(REGEX MATCHALL "-L[^;]+" + wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARIES}") + string(REPLACE "-L" "" + wxWidgets_LIBRARY_DIRS "${wxWidgets_LIBRARY_DIRS}") + + dbg_msg_v("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}") + dbg_msg_v("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}") + + else(RET EQUAL 0) + set(wxWidgets_FOUND FALSE) + dbg_msg("${wxWidgets_CONFIG_EXECUTABLE} --libs ${wxWidgets_FIND_COMPONENTS} FAILED with RET=${RET}") + endif(RET EQUAL 0) + endif(wxWidgets_CONFIG_EXECUTABLE) + + # When using wx-config in MSYS, the include paths are UNIX style paths which may or may + # not work correctly depending on you MSYS/MinGW configuration. CMake expects native + # paths internally. + if(wxWidgets_FOUND AND MSYS) + find_program(_cygpath_exe cygpath ONLY_CMAKE_FIND_ROOT_PATH) + dbg_msg_v("_cygpath_exe: ${_cygpath_exe}") + if(_cygpath_exe) + set(_tmp_path "") + foreach(_path ${wxWidgets_INCLUDE_DIRS}) + execute_process( + COMMAND cygpath -w ${_path} + OUTPUT_VARIABLE _native_path + RESULT_VARIABLE _retv + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + ) + if(_retv EQUAL 0) + file(TO_CMAKE_PATH ${_native_path} _native_path) + dbg_msg_v("Path ${_path} converted to ${_native_path}") + set(_tmp_path "${_tmp_path} ${_native_path}") + endif() + endforeach() + dbg_msg("Setting wxWidgets_INCLUDE_DIRS = ${_tmp_path}") + set(wxWidgets_INCLUDE_DIRS ${_tmp_path}) + separate_arguments(wxWidgets_INCLUDE_DIRS) + list(REMOVE_ITEM wxWidgets_INCLUDE_DIRS "") + endif() + endif() +#===================================================================== +# Neither UNIX_FIND_STYLE, nor WIN32_FIND_STYLE +#===================================================================== + else(wxWidgets_FIND_STYLE STREQUAL "unix") + if(NOT wxWidgets_FIND_QUIETLY) + message(STATUS + "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): \n" + " Platform unknown/unsupported. It's neither WIN32 nor UNIX " + "find style." + ) + endif(NOT wxWidgets_FIND_QUIETLY) + endif(wxWidgets_FIND_STYLE STREQUAL "unix") +endif(wxWidgets_FIND_STYLE STREQUAL "win32") + + +# Check if a specfic version was requested by find_package(). +if(wxWidgets_FOUND AND wxWidgets_FIND_VERSION) + find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH) + dbg_msg("_filename: ${_filename}") + + if(NOT _filename) + message(FATAL_ERROR "wxWidgets wx/version.h file not found in ${wxWidgets_INCLUDE_DIRS}.") + endif() + + file(READ ${_filename} _wx_version_h) + + string(REGEX REPLACE "^(.*\n)?#define wxMAJOR_VERSION[ ]+([0-9]+).*" + "\\2" wxWidgets_VERSION_MAJOR "${_wx_version_h}" ) + string(REGEX REPLACE "^(.*\n)?#define wxMINOR_VERSION[ ]+([0-9]+).*" + "\\2" wxWidgets_VERSION_MINOR "${_wx_version_h}" ) + string(REGEX REPLACE "^(.*\n)?#define wxRELEASE_NUMBER[ ]+([0-9]+).*" + "\\2" wxWidgets_VERSION_PATCH "${_wx_version_h}" ) + set(wxWidgets_VERSION_STRING + "${wxWidgets_VERSION_MAJOR}.${wxWidgets_VERSION_MINOR}.${wxWidgets_VERSION_PATCH}" ) + dbg_msg("wxWidgets_VERSION_STRING: ${wxWidgets_VERSION_STRING}") +endif() + + +# Debug output: +dbg_msg("wxWidgets_FOUND : ${wxWidgets_FOUND}") +dbg_msg("wxWidgets_INCLUDE_DIRS : ${wxWidgets_INCLUDE_DIRS}") +dbg_msg("wxWidgets_LIBRARY_DIRS : ${wxWidgets_LIBRARY_DIRS}") +dbg_msg("wxWidgets_LIBRARIES : ${wxWidgets_LIBRARIES}") +dbg_msg("wxWidgets_CXX_FLAGS : ${wxWidgets_CXX_FLAGS}") +dbg_msg("wxWidgets_USE_FILE : ${wxWidgets_USE_FILE}") +dbg_msg("wxWidgets_FIND_VERSION : ${wxWidgets_FIND_VERSION}") +dbg_msg("wxWidgets_VERSION_MAJOR : ${wxWidgets_VERSION_MAJOR}") +dbg_msg("wxWidgets_VERSION_MINOR : ${wxWidgets_VERSION_MINOR}") +dbg_msg("wxWidgets_VERSION_PATCH : ${wxWidgets_VERSION_PATCH}") + +#===================================================================== +#===================================================================== +# Maintain consistency with all other variables. +dbg_msg("wxWidgets_FOUND : ${wxWidgets_FOUND}") +set(WXWIDGETS_FOUND ${wxWidgetsS_FOUND}) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(wxWidgets + FOUND_VAR wxWidgets_FOUND + REQUIRED_VARS wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS + VERSION_VAR wxWidgets_VERSION_STRING + ) + +#===================================================================== +# Macros for use in wxWidgets apps. +# - This module will not fail to find wxWidgets based on the code +# below. Hence, it's required to check for validity of: +# +# wxWidgets_wxrc_EXECUTABLE +#===================================================================== + +# Resource file compiler. +find_program(wxWidgets_wxrc_EXECUTABLE wxrc + ${wxWidgets_ROOT_DIR}/utils/wxrc/vc_msw + ) + +# +# wx_split_arguments_on(<keyword> <left> <right> <arg1> <arg2> ...) +# +# Sets <left> and <right> to contain arguments to the left and right, +# respectively, of <keyword>. +# +# Example usage: +# function(wxwidgets_add_resources outfiles) +# wx_split_arguments_on(OPTIONS wxrc_files wxrc_options ${ARGN}) +# ... +# endfunction(wxwidgets_add_resources) +# +# wxwidgets_add_resources(sources ${xrc_files} OPTIONS -e -o file.C) +# +# NOTE: This is a generic piece of code that should be renamed to +# SPLIT_ARGUMENTS_ON and put in a file serving the same purpose as +# FindPackageStandardArgs.cmake. At the time of this writing +# FindQt4.cmake has a QT4_EXTRACT_OPTIONS, which I basically copied +# here a bit more generalized. So, there are already two find modules +# using this approach. +# +function(wx_split_arguments_on _keyword _leftvar _rightvar) + # FIXME: Document that the input variables will be cleared. + #list(APPEND ${_leftvar} "") + #list(APPEND ${_rightvar} "") + set(${_leftvar} "") + set(${_rightvar} "") + + set(_doing_right FALSE) + foreach(element ${ARGN}) + if("${element}" STREQUAL "${_keyword}") + set(_doing_right TRUE) + else("${element}" STREQUAL "${_keyword}") + if(_doing_right) + list(APPEND ${_rightvar} "${element}") + else(_doing_right) + list(APPEND ${_leftvar} "${element}") + endif(_doing_right) + endif("${element}" STREQUAL "${_keyword}") + endforeach(element) + + set(${_leftvar} ${${_leftvar}} PARENT_SCOPE) + set(${_rightvar} ${${_rightvar}} PARENT_SCOPE) +endfunction(wx_split_arguments_on) + +# +# wx_get_dependencies_from_xml( +# <depends> +# <match_pattern> +# <clean_pattern> +# <xml_contents> +# <depends_path> +# ) +# +# FIXME: Add documentation here... +# +function(wx_get_dependencies_from_xml + _depends + _match_patt + _clean_patt + _xml_contents + _depends_path + ) + + string(REGEX MATCHALL + ${_match_patt} + dep_file_list + "${${_xml_contents}}" + ) + foreach(dep_file ${dep_file_list}) + string(REGEX REPLACE ${_clean_patt} "" dep_file "${dep_file}") + + # make the file have an absolute path + if(NOT IS_ABSOLUTE "${dep_file}") + set(dep_file "${${_depends_path}}/${dep_file}") + endif(NOT IS_ABSOLUTE "${dep_file}") + + # append file to dependency list + list(APPEND ${_depends} "${dep_file}") + endforeach(dep_file) + + set(${_depends} ${${_depends}} PARENT_SCOPE) +endfunction(wx_get_dependencies_from_xml) + +# +# wxwidgets_add_resources(<sources> <xrc_files> +# OPTIONS <options> [NO_CPP_CODE]) +# +# Adds a custom command for resource file compilation of the +# <xrc_files> and appends the output files to <sources>. +# +# Example usages: +# wxwidgets_add_resources(sources xrc/main_frame.xrc) +# wxwidgets_add_resources(sources ${xrc_files} OPTIONS -e -o altname.cxx) +# +function(wxwidgets_add_resources _outfiles) + wx_split_arguments_on(OPTIONS rc_file_list rc_options ${ARGN}) + + # Parse files for dependencies. + set(rc_file_list_abs "") + set(rc_depends "") + foreach(rc_file ${rc_file_list}) + get_filename_component(depends_path ${rc_file} PATH) + + get_filename_component(rc_file_abs ${rc_file} ABSOLUTE) + list(APPEND rc_file_list_abs "${rc_file_abs}") + + # All files have absolute paths or paths relative to the location + # of the rc file. + file(READ "${rc_file_abs}" rc_file_contents) + + # get bitmap/bitmap2 files + wx_get_dependencies_from_xml( + rc_depends + "<bitmap[^<]+" + "^<bitmap[^>]*>" + rc_file_contents + depends_path + ) + + # get url files + wx_get_dependencies_from_xml( + rc_depends + "<url[^<]+" + "^<url[^>]*>" + rc_file_contents + depends_path + ) + + # get wxIcon files + wx_get_dependencies_from_xml( + rc_depends + "<object[^>]*class=\"wxIcon\"[^<]+" + "^<object[^>]*>" + rc_file_contents + depends_path + ) + endforeach(rc_file) + + # + # Parse options. + # + # If NO_CPP_CODE option specified, then produce .xrs file rather + # than a .cpp file (i.e., don't add the default --cpp-code option). + list(FIND rc_options NO_CPP_CODE index) + if(index EQUAL -1) + list(APPEND rc_options --cpp-code) + # wxrc's default output filename for cpp code. + set(outfile resource.cpp) + else(index EQUAL -1) + list(REMOVE_AT rc_options ${index}) + # wxrc's default output filename for xrs file. + set(outfile resource.xrs) + endif(index EQUAL -1) + + # Get output name for use in add_custom_command. + # - short option scanning + list(FIND rc_options -o index) + if(NOT index EQUAL -1) + MATH(EXPR filename_index "${index} + 1") + list(GET rc_options ${filename_index} outfile) + #list(REMOVE_AT rc_options ${index} ${filename_index}) + endif(NOT index EQUAL -1) + # - long option scanning + string(REGEX MATCH "--output=[^;]*" outfile_opt "${rc_options}") + if(outfile_opt) + string(REPLACE "--output=" "" outfile "${outfile_opt}") + endif(outfile_opt) + #string(REGEX REPLACE "--output=[^;]*;?" "" rc_options "${rc_options}") + #string(REGEX REPLACE ";$" "" rc_options "${rc_options}") + + if(NOT IS_ABSOLUTE "${outfile}") + set(outfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}") + endif(NOT IS_ABSOLUTE "${outfile}") + add_custom_command( + OUTPUT "${outfile}" + COMMAND ${wxWidgets_wxrc_EXECUTABLE} ${rc_options} ${rc_file_list_abs} + DEPENDS ${rc_file_list_abs} ${rc_depends} + ) + + # Add generated header to output file list. + list(FIND rc_options -e short_index) + list(FIND rc_options --extra-cpp-code long_index) + if(NOT short_index EQUAL -1 OR NOT long_index EQUAL -1) + get_filename_component(outfile_ext ${outfile} EXT) + string(REPLACE "${outfile_ext}" ".h" outfile_header "${outfile}") + list(APPEND ${_outfiles} "${outfile_header}") + set_source_files_properties( + "${outfile_header}" PROPERTIES GENERATED TRUE + ) + endif(NOT short_index EQUAL -1 OR NOT long_index EQUAL -1) + + # Add generated file to output file list. + list(APPEND ${_outfiles} "${outfile}") + + set(${_outfiles} ${${_outfiles}} PARENT_SCOPE) +endfunction(wxwidgets_add_resources) diff --git a/CMakeModules/Functions.cmake b/CMakeModules/Functions.cmake new file mode 100644 index 0000000..e3d7f8c --- /dev/null +++ b/CMakeModules/Functions.cmake @@ -0,0 +1,71 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2010 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + + +# Function make_lexer +# is a standard way to invoke TokenList2DsnLexer.cmake. +# Extra arguments are treated as source files which depend on the generated +# outHeaderFile + +function( make_lexer inputFile outHeaderFile outCppFile enum ) + add_custom_command( + OUTPUT ${outHeaderFile} + ${outCppFile} + COMMAND ${CMAKE_COMMAND} + -Denum=${enum} + -DinputFile=${inputFile} + -DoutHeaderFile=${outHeaderFile} + -DoutCppFile=${outCppFile} + -P ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake + DEPENDS ${inputFile} + ${CMAKE_MODULE_PATH}/TokenList2DsnLexer.cmake + COMMENT "TokenList2DsnLexer.cmake creating: + ${outHeaderFile} and + ${outCppFile} from + ${inputFile}" + ) + + # extra_args, if any, are treated as source files (typically headers) which + # are known to depend on the generated outHeader. + foreach( extra_arg ${ARGN} ) + set_source_files_properties( ${extra_arg} + PROPERTIES OBJECT_DEPENDS ${outHeaderFile} + ) + endforeach() + +endfunction() + + +# Is a macro instead of function so there's a higher probability that the +# scope of CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA is global +macro( add_conffiles ) + if( ${ARGC} STREQUAL "0" ) + # remove the file when user passes no arguments, which he should do exactly once at top + file( REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conffiles ) + else() + foreach( filename ${ARGV} ) + file( APPEND ${CMAKE_CURRENT_BINARY_DIR}/conffiles "${filename}\n" ) + endforeach() + set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_BINARY_DIR}/conffiles ) + endif() +endmacro( add_conffiles ) diff --git a/CMakeModules/Html2C.cmake b/CMakeModules/Html2C.cmake new file mode 100644 index 0000000..99919b3 --- /dev/null +++ b/CMakeModules/Html2C.cmake @@ -0,0 +1,13 @@ + +# CMake script file to process a text file by wrapping every line in double quotes. +# Input file must not abuse quotes, staying with single quotes is probably best. + +set( lines "" ) +file( STRINGS ${inputFile} lines ) + +file( WRITE ${outputFile} "// Do not edit this file, it is autogenerated by CMake from an HTML file\n" ) + +foreach( line ${lines} ) + STRING(REGEX REPLACE "\"" "\\\\\"" linem ${line}) + file( APPEND ${outputFile} "\"" ${linem} "\\n\"\n" ) +endforeach( line ${lines} ) diff --git a/CMakeModules/KiCadVersion.cmake b/CMakeModules/KiCadVersion.cmake new file mode 100644 index 0000000..8d02afb --- /dev/null +++ b/CMakeModules/KiCadVersion.cmake @@ -0,0 +1,37 @@ +#
+# This program source code file is part of KICAD, a free EDA CAD application.
+#
+# Copyright (C) 2016 Wayne Stambaugh <stambaughw@verizon.net>
+# Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, you may find one here:
+# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
+# or you may search the http://www.gnu.org website for the version 2 license,
+# or you may write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+#
+
+# Note: unless you are the person responsible for creating releases,
+# do *not* change these variables. This way the KiCad project
+# can maintain control over what is an official KiCad build and
+# what is not. Setting these variable that conflict with KiCad
+# releases is a shooting offense.
+#
+# This file gets included in the WriteVersionHeader.cmake file to set
+# the KiCad version when the source is provided in an archive file.
+# When KiCad is cloned using git, the git version is used. The only
+# time this should be set to a value other than "no-vcs-found" is when
+# a source archive is created. This eliminates the need to set
+# KICAD_VERSION during the build configuration step.
+set( KICAD_VERSION "4.0.7" )
diff --git a/CMakeModules/MinGWResourceCompiler.cmake b/CMakeModules/MinGWResourceCompiler.cmake new file mode 100644 index 0000000..0e13ee5 --- /dev/null +++ b/CMakeModules/MinGWResourceCompiler.cmake @@ -0,0 +1,44 @@ +# resource compilation for mingw (http://www.cmake.org/Bug/view.php?id=4068) + +macro(dbg_msg _MSG) +# message(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}") +endmacro(dbg_msg) + +macro(mingw_resource_compiler _NAME) + # Resource compiler name. + if(NOT DEFINED CMAKE_RC_COMPILER) + set(CMAKE_RC_COMPILER windres.exe) + endif(NOT DEFINED CMAKE_RC_COMPILER) + dbg_msg("CMAKE_RC_COMPILER: ${CMAKE_RC_COMPILER}") + + # Input file. + set(_IN "${CMAKE_CURRENT_SOURCE_DIR}/${_NAME}.rc") + dbg_msg("_IN: ${_IN}") + + # Output file. + set(_OUT "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_NAME}.dir/${_NAME}_rc.obj") + dbg_msg("_OUT: ${_OUT}") + + # Include directories. + set(_WINDRES_INCLUDE_DIRS -I${CMAKE_CURRENT_SOURCE_DIR}) + foreach(wx_include_dir ${wxWidgets_INCLUDE_DIRS}) + set(_WINDRES_INCLUDE_DIRS ${_WINDRES_INCLUDE_DIRS} -I${wx_include_dir}) + endforeach(wx_include_dir ${wxWidgets_INCLUDE_DIRS}) + dbg_msg("_WINDRES_INCLUDE_DIRS: ${_WINDRES_INCLUDE_DIRS}") + + # windres arguments. + set(_ARGS ${_WINDRES_INCLUDE_DIRS} -i${_IN} -o${_OUT}) + dbg_msg("_ARGS: ${_ARGS}") + + # Compile resource file. + add_custom_command(OUTPUT ${_OUT} + COMMAND ${CMAKE_RC_COMPILER} + ARGS ${_ARGS} + COMMENT "Compiling ${_NAME}'s resource file" + VERBATIM) + + # Set a NAME_RESOURCES variable + string(TOUPPER ${_NAME} _NAME_UPPER) + set(${_NAME_UPPER}_RESOURCES ${_OUT}) + dbg_msg("${_NAME_UPPER}_RESOURCES: ${${_NAME_UPPER}_RESOURCES}") +endmacro(mingw_resource_compiler) diff --git a/CMakeModules/PNG2cpp.cmake b/CMakeModules/PNG2cpp.cmake new file mode 100644 index 0000000..986f534 --- /dev/null +++ b/CMakeModules/PNG2cpp.cmake @@ -0,0 +1,81 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2011 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors#. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +############################################################################# +# +# This script converts a *.png file into a *.cpp file. +# The *.cpp file will contain a BITMAP_DEF structure, which is simply a byte +# array and a length of bytes which were found in the *.png file. +# +# +# Invocation Parameters are: inputFile, outCppFile +# +# inputFile - Required, full path and file name of the input PNG file +# +# outCppFile - Required, full path and file name of where to save the +# generated cpp file. + + +file( READ ${inputFile} file_contents HEX ) + +get_filename_component( png_name "${inputFile}" NAME_WE ) + +# split into pairs of ASCII, where each pair gives a single byte's value +string( REGEX MATCHALL "[0-9a-fA-F][0-9a-fA-F]" byte_list ${file_contents} ) + +set( output_begin " +/* Do not modify this file, it was automatically generated by the + * PNG2cpp CMake script, using a *.png file as input. + */ + +#include <bitmaps.h> + +static const unsigned char png[] = {" +) + +set( output_end "}; + +const BITMAP_OPAQUE ${png_name}_xpm[1] = {{ png, sizeof( png ), \"${png_name}_xpm\" }}; + +//EOF +" ) + +set( byte_count 0 ) +set( byte_array "" ) + +foreach( byte ${byte_list} ) + + math( EXPR modulus "${byte_count} % 16" ) + if( modulus EQUAL 0 ) + set( byte_array "${byte_array}\n" ) + endif() + + set( byte_array "${byte_array} 0x${byte}," ) + math( EXPR byte_count "${byte_count} + 1" ) +endforeach() + +set( byte_array "${byte_array}\n" ) + +file( WRITE ${outCppFile} "${output_begin}" ) +file( APPEND ${outCppFile} "${byte_array}" ) +file( APPEND ${outCppFile} "${output_end}" ) + diff --git a/CMakeModules/PerformFeatureChecks.cmake b/CMakeModules/PerformFeatureChecks.cmake new file mode 100644 index 0000000..0240046 --- /dev/null +++ b/CMakeModules/PerformFeatureChecks.cmake @@ -0,0 +1,115 @@ +# +# Check for platform specific features and generate configuration header.. +# +# This cmake file was written to create a platform specific configuration +# header to handle differences between build platforms. Please add new +# feature checks to this file. Always check the wxWidgets headers first +# before adding new feature checks. The wxWidgets build system does a +# very good job of handling platform and compiler differences. +# +# Should you feel the need to do this: +# +# #ifdef SYSTEM_A +# # include <some_header_for_system_a.h> +# #elif SYSTEM_B +# # include <some_other_header_for_system_b.h> +# #elif SYSTEM_C +# # include <yet_another_header_for_system_c.h> +# #endif +# +# in your source, don't. It is not portable nor is it maintainable. +# Use cmake to detect system specific dependencies and update the +# configuration header instead. +# +# See this link for information on writing cmake system checks: +# +# http://www.vtk.org/Wiki/CMake_HowToDoPlatformChecks +# +# More importantly see "Recommendations for Writing Autoconf Macros" in: +# +# http://www.lrde.epita.fr/~adl/dl/autotools.pdf +# +# for an explanation of why you should do this. Even though this is an +# autotools tutorial. This section clearly explains why checking for +# features is superior to checking for systems. The previous section of +# this tutorial shows how to create a system independent check for _mkdir(). +# Consider it a benchmark when writing your own feature tests. +# + +macro( perform_feature_checks ) + + include( CheckIncludeFile ) + #include( CheckFunctionExists ) + include( CheckLibraryExists ) + include( CheckSymbolExists ) + include( CheckIncludeFileCXX ) + include( CheckCXXSymbolExists ) + include( CheckCXXSourceCompiles ) + include( CheckCXXCompilerFlag ) + + check_cxx_compiler_flag( -fvisibility=hidden GXX_HAS_VISIBILITY_FLAG ) + check_cxx_compiler_flag( -fvisibility-inlines-hidden GXX_HAS_VISIBILITY_INLINES_FLAG ) + + check_include_file( "malloc.h" HAVE_MALLOC_H ) + + # FIXME: Visual C++ does not support the "not" keyword natively. It is + # defined as a macro in <iso646.h>. There should be a cmake macro + # to check if compiler supports the not keyword natively. If not, + # then check for <iso646.h> and include it. Although it doesn't + # appear to cause any problems with other compilers, that doesn't + # mean won't fail somewhere down the line. + check_include_file( "iso646.h" HAVE_ISO646_H ) + + # The STDINT header file test is required because MinGW under Windows + # doesn't define HAVE_STDINT_H even though it does have it. + # + # We need to add it to the global compiler definitions as config.h is not + # included in pyport.h which is where the problem ocurrs without this + # fix. + check_include_file( "stdint.h" HAVE_STDINT_H ) + + if( HAVE_STDINT_H ) + add_definitions( -DHAVE_STDINT_H ) + endif() + + # no place is this used, and "HAVE_STRINGS_H", if present in config.h then + # conflicts with /usr/include/python2.6/Python.h. Please rename the macro if + # re-introduce this. + # check_include_file("strings.h" HAVE_STRINGS_H) + + check_symbol_exists( strcasecmp "string.h" HAVE_STRCASECMP ) + check_symbol_exists( strcasecmp "strings.h" HAVE_STRCASECMP ) + check_symbol_exists( strncasecmp "string.h" HAVE_STRNCASECMP ) + check_symbol_exists( strncasecmp "strings.h" HAVE_STRNCASECMP ) + check_symbol_exists( strtok_r "string.h" HAVE_STRTOKR ) + + check_cxx_symbol_exists( strcasecmp "string.h" HAVE_STRCASECMP ) + check_cxx_symbol_exists( strncasecmp "string.h" HAVE_STRNCASECMP ) + + # Some platforms define malloc and free in malloc.h instead of stdlib.h. + check_symbol_exists( malloc "stdlib.h" MALLOC_IN_STDLIB_H ) + + # Check for functions in math.h. + check_include_file( "math.h" HAVE_MATH_H ) + + # Check for functions in C++ cmath. + check_include_file_cxx( cmath HAVE_CXX_CMATH ) + check_cxx_symbol_exists( asinh cmath HAVE_CMATH_ASINH ) + check_cxx_symbol_exists( acosh cmath HAVE_CMATH_ACOSH ) + check_cxx_symbol_exists( atanh cmath HAVE_CMATH_ATANH ) + + # CMakes check_cxx_symbol_exists() doesn't work for templates so we must create a + # small program to verify isinf() exists in cmath. + check_cxx_source_compiles( "#include <cmath>\nint main(int argc, char** argv)\n{\n (void)argv;\n std::isinf(1.0); (void)argc;\n return 0;\n}\n" HAVE_CMATH_ISINF ) + + #check_symbol_exists( clock_gettime "time.h" HAVE_CLOCK_GETTIME ) non-standard library, does not work + check_library_exists( rt clock_gettime "" HAVE_CLOCK_GETTIME ) + + # HAVE_GETTIMEOFDAY is already in use within 2.9 wxWidgets, so use HAVE_GETTIMEOFDAY_FUNC + check_symbol_exists( gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY_FUNC ) + + # Check for Posix getc_unlocked() for improved performance over getc(). Fall back to + # getc() on platforms where getc_unlocked() doesn't exist. + check_symbol_exists( getc_unlocked "stdio.h" HAVE_FGETC_NOLOCK ) + +endmacro( perform_feature_checks ) diff --git a/CMakeModules/SelectLibraryConfigurations.cmake b/CMakeModules/SelectLibraryConfigurations.cmake new file mode 100644 index 0000000..5bca064 --- /dev/null +++ b/CMakeModules/SelectLibraryConfigurations.cmake @@ -0,0 +1,87 @@ +# select_library_configurations( basename ) +# +# This macro takes a library base name as an argument, and will choose good +# values for basename_LIBRARY, basename_LIBRARIES, basename_LIBRARY_DEBUG, and +# basename_LIBRARY_RELEASE depending on what has been found and set. If only +# basename_LIBRARY_RELEASE is defined, basename_LIBRARY, basename_LIBRARY_DEBUG, +# and basename_LIBRARY_RELEASE will be set to the release value. If only +# basename_LIBRARY_DEBUG is defined, then basename_LIBRARY, +# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value. +# +# If the generator supports configuration types, then basename_LIBRARY and +# basename_LIBRARIES will be set with debug and optimized flags specifying the +# library to be used for the given configuration. If no build type has been set +# or the generator in use does not support configuration types, then +# basename_LIBRARY and basename_LIBRARIES will take only the release values. + +#============================================================================= +# Copyright 2009 Will Dicharry <wdicharry@stellarscience.com> +# Copyright 2005-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# This macro was adapted from the FindQt4 CMake module and is maintained by Will +# Dicharry <wdicharry@stellarscience.com>. + +# Utility macro to check if one variable exists while another doesn't, and set +# one that doesn't exist to the one that exists. +macro( _set_library_name basename GOOD BAD ) + if( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} ) + set( ${basename}_LIBRARY_${BAD} ${${basename}_LIBRARY_${GOOD}} ) + set( ${basename}_LIBRARY ${${basename}_LIBRARY_${GOOD}} ) + set( ${basename}_LIBRARIES ${${basename}_LIBRARY_${GOOD}} ) + endif() +endmacro() + +macro( select_library_configurations basename ) + # if only the release version was found, set the debug to be the release + # version. + _set_library_name( ${basename} RELEASE DEBUG ) + # if only the debug version was found, set the release value to be the + # debug value. + _set_library_name( ${basename} DEBUG RELEASE ) + + # Set a default case, which will come into effect if + # -no build type is set and the generator only supports one build type + # at a time (i.e. CMAKE_CONFIGURATION_TYPES is false) + # -${basename}_LIBRARY_DEBUG and ${basename}_LIBRARY_RELEASE are the same + # -${basename}_LIBRARY_DEBUG and ${basename}_LIBRARY_RELEASE are both empty + set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) + set( ${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE} ) + + if( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE AND + NOT ${basename}_LIBRARY_DEBUG STREQUAL ${basename}_LIBRARY_RELEASE ) + # if the generator supports configuration types or CMAKE_BUILD_TYPE + # is set, then set optimized and debug options. + if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) + set( ${basename}_LIBRARY "" ) + foreach( _libname IN LISTS ${basename}_LIBRARY_RELEASE ) + list( APPEND ${basename}_LIBRARY optimized "${_libname}" ) + endforeach() + foreach( _libname IN LISTS ${basename}_LIBRARY_DEBUG ) + list( APPEND ${basename}_LIBRARY debug "${_libname}" ) + endforeach() + set( ${basename}_LIBRARIES "${${basename}_LIBRARY}" ) + endif() + endif() + + set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH + "The ${basename} library" ) + + if( ${basename}_LIBRARY ) + set( ${basename}_FOUND TRUE ) + endif() + + mark_as_advanced( ${basename}_LIBRARY + ${basename}_LIBRARY_RELEASE + ${basename}_LIBRARY_DEBUG + ) +endmacro() diff --git a/CMakeModules/Shaders.cmake b/CMakeModules/Shaders.cmake new file mode 100644 index 0000000..c7f0e57 --- /dev/null +++ b/CMakeModules/Shaders.cmake @@ -0,0 +1,57 @@ +# CMake script file to process a GLSL source file, so it can be included +# in C array and compiled in to an application. + +# number of input files +list( LENGTH inputFiles shadersNumber ) + +# check if GLSL source files were updated since the last time +set( update "FALSE" ) +foreach( inputFile ${inputFiles} ) + if( ${inputFile} IS_NEWER_THAN ${outputFile} ) + set( update "TRUE" ) + endif( ${inputFile} IS_NEWER_THAN ${outputFile} ) +endforeach( inputFile ${inputFiles} ) + +if( NOT update ) + message( "Headers are up-to-date" ) + return() +endif( NOT update ) + +# write header +file( WRITE ${outputFile} "// Do not edit this file, it is autogenerated by CMake. + +#ifndef SHADER_SRC_H +#define SHADER_SRC_H + +const unsigned int shaders_number = ${shadersNumber}; +const char* shaders_src[] = +{\n" ) + +foreach( inputFile ${inputFiles} ) + # put the input file name into the output file + file( APPEND ${outputFile} "\n// ${inputFile}" ) + + # process the input file + file( READ ${inputFile} contents ) + + # remove /* */ comments + string( REGEX REPLACE "/\\*.*\\*/" "" contents "${contents}" ) + # remove // comments + string( REGEX REPLACE "//[^\n]*" "" contents "${contents}" ) + # remove whitespaces at the beginning of each line + string( REGEX REPLACE "\n([\t ])*" "\n" contents "${contents}" ) + # remove unnecessary spaces + string( REGEX REPLACE " *([\\*/+&\\|,=<>\(\)]) *" "\\1" contents "${contents}" ) + # remove empty lines & wrap every line in "" and add '\n' at the end of each line + string( REGEX REPLACE "\n+" "\\\\n\"\n\"" contents "${contents}" ) + # remove unnecessary " & \n from the beginning and the end of contents + string( REGEX REPLACE "^\\\\n\"" "" contents "${contents}" ) + string( REGEX REPLACE "\"$" "," contents "${contents}" ) + + file( APPEND ${outputFile} "${contents}" ) +endforeach( inputFile ${inputFiles} ) + +# write footer +file( APPEND ${outputFile} "}; +#endif /* SHADER_SRC_H */" ) + diff --git a/CMakeModules/TokenList2DsnLexer.cmake b/CMakeModules/TokenList2DsnLexer.cmake new file mode 100644 index 0000000..d11bc5c --- /dev/null +++ b/CMakeModules/TokenList2DsnLexer.cmake @@ -0,0 +1,387 @@ + +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2010 Wayne Stambaugh <stambaughw@verizon.net> +# Copyright (C) 2010 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +# +# This script converts a plain text file with a line feed separated list +# of token names into the appropriate source and header files required by +# the DSN lexer. See files "<base_source_path>/common/dsnlexer.cpp" and +# "<base_source_path>/include/dsnlexer.h" for more information about how +# the DSN lexer works. The token list file format requires a single token +# per line. Tokens can only contain lower case letters, numbers, and +# underscores. The first letter of each token must be a lower case letter. +# Tokens must be unique. If any of the above criteria are not met, the +# source and header files will not be generated and a build error will +# occur. +# +# Valid tokens: a a1 foo_1 foo_bar2 +# Invalid tokens: 1 A _foo bar_ foO +# +# Invocation Parameters are: enum, inputFile, outCppFile, outHeaderFile +# +# enum - Required, namespace in which the enum T will be placed. +# Keep it short because from outside the class you want a short enum name +# like enum::T. Enums are contained in their own namespace to avoid +# collisions on enum value names, a problem with C++ unless the enum +# itself is in a separate namespace. +# +# inputFile - Required, name of the token list file, or "*.keywords" file. +# Choose the basefilename carefully, it decides the class name +# used in the generated *_lexer.h file. +# +# outCppFile - Optional, full path and file name of where to save the generated +# cpp keywords file. If not defined, the output path is the same +# path as the token list file path, with a file name of *_keywords.cpp +# +# outHeaderFile - Optional, full path and file name of where to save the generated +# *.h lexfer file. If not defined, the output path is the same +# path as the token list file path, with a file name of *_lexer.h +# +# Use the max_lexer() CMake function from functions.cmake for invocation convenience. + + +#message( STATUS "TokenList2DsnLexer.cmake" ) # indicate we are running + +set( tokens "" ) +set( lineCount 0 ) +set( dsnErrorMsg "TokenList2DsnLexer.cmake failure:" ) + +if( NOT EXISTS ${inputFile} ) + message( FATAL_ERROR "${dsnErrorMsg} file ${inputFile} cannot be found." ) +endif() + +if( NOT DEFINED enum ) + message( FATAL_ERROR "${dsnErrorMsg} missing \"enum\" processing ${inputFile}." ) +endif() + +get_filename_component( outputPath "${inputFile}" PATH ) + +# the keywords filename without extension is important, it sets the classname into RESULT +get_filename_component( result "${inputFile}" NAME_WE ) +string( TOUPPER "${result}" RESULT ) + +set( LEXERCLASS "${RESULT}_LEXER" ) +set( PARSERCLASS "${RESULT}_PARSER" ) + +#message( "enum:'${enum}' result:'${result}' outputPath:'${outputPath}' inputFile:'${inputFile}'" ) + +if( NOT DEFINED outCppFile ) + set( outCppFile "${outputPath}/${result}_keywords.cpp" ) +endif() + +if( NOT DEFINED outHeaderFile ) + set( outHeaderFile "${outputPath}/${result}_lexer.h" ) +endif() + +# Create tag for generating header file. +set( headerTag "${LEXERCLASS}_H_" ) + +set( includeFileHeader +" +/* Do not modify this file it was automatically generated by the + * TokenList2DsnLexer CMake script. + */ + +#ifndef ${headerTag} +#define ${headerTag} + +#include <dsnlexer.h> + +/** + * C++ does not put enum _values_ in separate namespaces unless the enum itself + * is in a separate namespace. All the token enums must be in separate namespaces + * otherwise the C++ compiler will eventually complain if it sees more than one + * DSNLEXER in the same compilation unit, say by mutliple header file inclusion. + * Plus this also enables re-use of the same enum name T. A typedef can always be used + * to clarify which enum T is in play should that ever be a problem. This is + * unlikely since Parse() functions will usually only be exposed to one header + * file like this one. But if there is a problem, then use: + * typedef ${enum}::T T; + * within that problem area. + */ +namespace ${enum} +{ + /// enum T contains all this lexer's tokens. + enum T + { + // these first few are negative special ones for syntax, and are + // inherited from DSNLEXER. + T_NONE = DSN_NONE, + T_COMMENT = DSN_COMMENT, + T_STRING_QUOTE = DSN_STRING_QUOTE, + T_QUOTE_DEF = DSN_QUOTE_DEF, + T_DASH = DSN_DASH, + T_SYMBOL = DSN_SYMBOL, + T_NUMBER = DSN_NUMBER, + T_RIGHT = DSN_RIGHT, // right bracket: ')' + T_LEFT = DSN_LEFT, // left bracket: '(' + T_STRING = DSN_STRING, // a quoted string, stripped of the quotes + T_EOF = DSN_EOF, // special case for end of file + +" +) + + +set( sourceFileHeader +" +/* Do not modify this file it was automatically generated by the + * TokenList2DsnLexer CMake script. + * + * Include this file in your lexer class to provide the keywords for + * your DSN lexer. + */ + +#include <${result}_lexer.h> + +using namespace ${enum}; + +#define TOKDEF(x) { #x, T_##x } + +const KEYWORD ${LEXERCLASS}::keywords[] = { +" +) + +file( STRINGS ${inputFile} lines NO_HEX_CONVERSION ) + +foreach( line ${lines} ) + math( EXPR lineCount "${lineCount} + 1" ) + + # strip any comment from # to end of line + string( REGEX REPLACE "#.*$" "" tmpToken "${line}" ) + string( STRIP "${tmpToken}" token ) + + # Ignore empty lines. + if( NOT token STREQUAL "" ) # if token is "off" simple if( token) does not work + # Make sure token is valid. + + #message( "token=${token}" ) + + string( REGEX MATCH "[a-z][_0-9a-z]*" validToken "${token}" ) + #message( "validToken=${validToken}" ) + + if( validToken STREQUAL token ) + list( APPEND tokens "${validToken}" ) + else() + message( FATAL_ERROR + "Invalid token string \"${tmpToken}\" at line ${lineCount} in file " + "<${inputFile}>." ) + endif() + endif() +endforeach() + +list( SORT tokens ) + +# Check for duplicates. +list( LENGTH tokens tokensBefore ) +list( REMOVE_DUPLICATES tokens ) +list( LENGTH tokens tokensAfter ) + +if( NOT ( tokensBefore EQUAL tokensAfter ) ) + message( FATAL_ERROR "Duplicate tokens found in file <${inputFile}>." ) +endif() + +file( WRITE "${outHeaderFile}" "${includeFileHeader}" ) +file( WRITE "${outCppFile}" "${sourceFileHeader}" ) + +set( lineCount 1 ) + +foreach( token ${tokens} ) + if( lineCount EQUAL 1 ) + file( APPEND "${outHeaderFile}" " T_${token} = 0" ) + else( lineCount EQUAL 1 ) + file( APPEND "${outHeaderFile}" " T_${token}" ) + endif( lineCount EQUAL 1 ) + + file(APPEND "${outCppFile}" " TOKDEF( ${token} )" ) + + if( lineCount EQUAL tokensAfter ) + file( APPEND "${outHeaderFile}" "\n" ) + file( APPEND "${outCppFile}" "\n" ) + else( lineCount EQUAL tokensAfter ) + file( APPEND "${outHeaderFile}" ",\n" ) + file( APPEND "${outCppFile}" ",\n" ) + endif( lineCount EQUAL tokensAfter ) + math( EXPR lineCount "${lineCount} + 1" ) +endforeach() + +file( APPEND "${outHeaderFile}" +" }; +} // namespace ${enum} + + +/** + * Class ${LEXERCLASS} + * is an automatically generated class using the TokenList2DnsLexer.cmake + * technology, based on keywords provided by file: + * ${inputFile} + */ +class ${LEXERCLASS} : public DSNLEXER +{ + /// Auto generated lexer keywords table and length: + static const KEYWORD keywords[]; + static const unsigned keyword_count; + +public: + /** + * Constructor ( const std::string&, const wxString& ) + * @param aSExpression is (utf8) text possibly from the clipboard that you want to parse. + * @param aSource is a description of the origin of @a aSExpression, such as a filename. + * If left empty, then _(\"clipboard\") is used. + */ + ${LEXERCLASS}( const std::string& aSExpression, const wxString& aSource = wxEmptyString ) : + DSNLEXER( keywords, keyword_count, aSExpression, aSource ) + { + } + + /** + * Constructor ( FILE* ) + * takes @a aFile already opened for reading and @a aFilename as parameters. + * The opened file is assumed to be positioned at the beginning of the file + * for purposes of accurate line number reporting in error messages. The + * FILE is closed by this instance when its destructor is called. + * @param aFile is a FILE already opened for reading. + * @param aFilename is the name of the opened file, needed for error reporting. + */ + ${LEXERCLASS}( FILE* aFile, const wxString& aFilename ) : + DSNLEXER( keywords, keyword_count, aFile, aFilename ) + { + } + + /** + * Constructor ( LINE_READER* ) + * intializes a lexer and prepares to read from @a aLineReader which + * is assumed ready, and may be in use by other DSNLEXERs also. No ownership + * is taken of @a aLineReader. This enables it to be used by other lexers also. + * The transition between grammars in such a case, must happen on a text + * line boundary, not within the same line of text. + * + * @param aLineReader is any subclassed instance of LINE_READER, such as + * STRING_LINE_READER or FILE_LINE_READER. No ownership is taken of aLineReader. + */ + ${LEXERCLASS}( LINE_READER* aLineReader ) : + DSNLEXER( keywords, keyword_count, aLineReader ) + { + } + + /** + * Function TokenName + * returns the name of the token in ASCII form. + */ + static const char* TokenName( ${enum}::T aTok ); + + /** + * Function NextTok + * returns the next token found in the input file or T_EOF when reaching + * the end of file. Users should wrap this function to return an enum + * to aid in grammar debugging while running under a debugger, but leave + * this lower level function returning an int (so the enum does not collide + * with another usage). + * @return ${enum}::T - the type of token found next. + * @throw IO_ERROR - only if the LINE_READER throws it. + */ + ${enum}::T NextTok() throw( IO_ERROR ) + { + return (${enum}::T) DSNLEXER::NextTok(); + } + + /** + * Function NeedSYMBOL + * calls NextTok() and then verifies that the token read in + * satisfies bool IsSymbol(). + * If not, an IO_ERROR is thrown. + * @return int - the actual token read in. + * @throw IO_ERROR, if the next token does not satisfy IsSymbol() + */ + ${enum}::T NeedSYMBOL() throw( IO_ERROR ) + { + return (${enum}::T) DSNLEXER::NeedSYMBOL(); + } + + /** + * Function NeedSYMBOLorNUMBER + * calls NextTok() and then verifies that the token read in + * satisfies bool IsSymbol() or tok==T_NUMBER. + * If not, an IO_ERROR is thrown. + * @return int - the actual token read in. + * @throw IO_ERROR, if the next token does not satisfy the above test + */ + ${enum}::T NeedSYMBOLorNUMBER() throw( IO_ERROR ) + { + return (${enum}::T) DSNLEXER::NeedSYMBOLorNUMBER(); + } + + /** + * Function CurTok + * returns whatever NextTok() returned the last time it was called. + */ + ${enum}::T CurTok() + { + return (${enum}::T) DSNLEXER::CurTok(); + } + + /** + * Function PrevTok + * returns whatever NextTok() returned the 2nd to last time it was called. + */ + ${enum}::T PrevTok() + { + return (${enum}::T) DSNLEXER::PrevTok(); + } +}; + +// example usage + +/** + * Class ${LEXCLASS}_PARSER + * holds data and functions pertinent to parsing a S-expression file . + * +class ${PARSERCLASS} : public ${LEXERCLASS} +{ + +}; +*/ + +#endif // ${headerTag} +" +) + +file( APPEND "${outCppFile}" +"}; + +const unsigned ${LEXERCLASS}::keyword_count = unsigned( sizeof( ${LEXERCLASS}::keywords )/sizeof( ${LEXERCLASS}::keywords[0] ) ); + + +const char* ${LEXERCLASS}::TokenName( T aTok ) +{ + const char* ret; + + if( aTok < 0 ) + ret = DSNLEXER::Syntax( aTok ); + else if( (unsigned) aTok < keyword_count ) + ret = keywords[aTok].name; + else + ret = \"token too big\"; + + return ret; +} +" +) diff --git a/CMakeModules/UsewxWidgets.cmake b/CMakeModules/UsewxWidgets.cmake new file mode 100644 index 0000000..9ecfff0 --- /dev/null +++ b/CMakeModules/UsewxWidgets.cmake @@ -0,0 +1,89 @@ +# - Convenience include for using wxWidgets library. +# Determines if wxWidgets was FOUND and sets the appropriate libs, incdirs, +# flags, etc. INCLUDE_DIRECTORIES and LINK_DIRECTORIES are called. +# +# USAGE +# # Note that for MinGW users the order of libs is important! +# FIND_PACKAGE(wxWidgets REQUIRED net gl core base) +# INCLUDE(${wxWidgets_USE_FILE}) +# # and for each of your dependant executable/library targets: +# TARGET_LINK_LIBRARIES(<YourTarget> ${wxWidgets_LIBRARIES}) +# +# DEPRECATED +# LINK_LIBRARIES is not called in favor of adding dependencies per target. +# +# AUTHOR +# Jan Woetzel <jw -at- mip.informatik.uni-kiel.de> + +#============================================================================= +# Copyright 2004-2009 Kitware, Inc. +# Copyright 2006 Jan Woetzel +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# debug message and logging. +# comment these out for distribution +IF (NOT LOGFILE ) + # SET(LOGFILE "${PROJECT_BINARY_DIR}/CMakeOutput.log") +ENDIF (NOT LOGFILE ) +MACRO(MSG _MSG) + # FILE(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}\n") + # MESSAGE(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}") +ENDMACRO(MSG) + + +MSG("wxWidgets_FOUND=${wxWidgets_FOUND}") +IF (wxWidgets_FOUND) + IF (wxWidgets_INCLUDE_DIRS) + IF(wxWidgets_INCLUDE_DIRS_NO_SYSTEM) + INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS}) + ELSE(wxWidgets_INCLUDE_DIRS_NO_SYSTEM) + INCLUDE_DIRECTORIES(SYSTEM ${wxWidgets_INCLUDE_DIRS}) + ENDIF(wxWidgets_INCLUDE_DIRS_NO_SYSTEM) + MSG("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}") + ENDIF(wxWidgets_INCLUDE_DIRS) + + IF (wxWidgets_LIBRARY_DIRS) + LINK_DIRECTORIES(${wxWidgets_LIBRARY_DIRS}) + MSG("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}") + ENDIF(wxWidgets_LIBRARY_DIRS) + + IF (wxWidgets_DEFINITIONS) + SET_PROPERTY(DIRECTORY APPEND + PROPERTY COMPILE_DEFINITIONS ${wxWidgets_DEFINITIONS}) + MSG("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}") + ENDIF(wxWidgets_DEFINITIONS) + + IF (wxWidgets_DEFINITIONS_DEBUG) + SET_PROPERTY(DIRECTORY APPEND + PROPERTY COMPILE_DEFINITIONS_DEBUG ${wxWidgets_DEFINITIONS_DEBUG}) + MSG("wxWidgets_DEFINITIONS_DEBUG=${wxWidgets_DEFINITIONS_DEBUG}") + ENDIF(wxWidgets_DEFINITIONS_DEBUG) + + IF (wxWidgets_CXX_FLAGS) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS}") + MSG("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}") + ENDIF(wxWidgets_CXX_FLAGS) + + # DEPRECATED JW + # just for backward compatibility: add deps to all targets + # library projects better use advanced FIND_PACKAGE(wxWidgets) directly. + #IF(wxWidgets_LIBRARIES) + # LINK_LIBRARIES(${wxWidgets_LIBRARIES}) + # # BUG: str too long: MSG("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}") + # IF(LOGFILE) + # FILE(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${wxWidgets_LIBRARIES}\n") + # ENDIF(LOGFILE) + #ENDIF(wxWidgets_LIBRARIES) + +ELSE (wxWidgets_FOUND) + MESSAGE("wxWidgets requested but not found.") +ENDIF(wxWidgets_FOUND) diff --git a/CMakeModules/WriteVersionHeader.cmake b/CMakeModules/WriteVersionHeader.cmake new file mode 100644 index 0000000..013a36a --- /dev/null +++ b/CMakeModules/WriteVersionHeader.cmake @@ -0,0 +1,88 @@ +# +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net> +# Copyright (C) 2015-2016 KiCad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +# Automagically create version header file if the version string was +# not defined during the build configuration. If +# CreateGitVersionHeader cannot determine the current repo version, a +# version.h file is still created with KICAD_VERSION set to "no-vcs-found". +include( ${CMAKE_MODULE_PATH}/KiCadVersion.cmake ) + +# Attempt to detect if we have a git repo and set the version string if +# the version wasn't set to something other than the default value in +# KiCadVersion.cmake. +if( KICAD_VERSION STREQUAL "no-vcs-found" AND EXISTS "${SRC_PATH}/.git" ) + message( STATUS "Using Git to determine build version string." ) + include( ${CMAKE_MODULE_PATH}/CreateGitVersionHeader.cmake ) + create_git_version_header( ${SRC_PATH} ) +endif() + +# $KICAD_VERSION_FULL will always be set to something. Even if it is "no-vcs-found". +set( KICAD_VERSION_FULL "${KICAD_VERSION}" ) + +# Optional branch name detected by git or configuration defined option. +if( KICAD_BRANCH_NAME ) + set( KICAD_VERSION_FULL "${KICAD_VERSION_FULL}-${KICAD_BRANCH_NAME}" ) +endif() + +# Optional user version information defined at configuration. +if( KICAD_VERSION_EXTRA ) + set( KICAD_VERSION_FULL "${KICAD_VERSION_FULL}-${KICAD_VERSION_EXTRA}" ) +endif() + +set( _wvh_new_version_text +"/* Do not modify this file, it was automatically generated by CMake. */ + +/* + * Define the KiCad build version string. + */ +#ifndef __KICAD_VERSION_H__ +#define __KICAD_VERSION_H__ + +#define KICAD_VERSION_FULL \"${KICAD_VERSION_FULL}\" + +#endif /* __KICAD_VERSION_H__ */ +" ) + +set( _wvh_write_version_file ON ) + +# Only write the header if it has changed, to avoid rebuilds +if( EXISTS ${OUTPUT_FILE} ) + file( READ ${OUTPUT_FILE} _wvh_old_version_text ) + if( _wvh_old_version_text STREQUAL _wvh_new_version_text ) + message( STATUS "Not updating ${OUTPUT_FILE}" ) + set( _wvh_write_version_file OFF ) + endif() +endif() + +if( _wvh_write_version_file ) + message( STATUS "Writing ${OUTPUT_FILE} file with version: ${KICAD_VERSION_FULL}" ) + + file( WRITE ${OUTPUT_FILE} ${_wvh_new_version_text} ) + +endif() + +# There should always be a valid version.h file. Otherwise, the build will fail. +if( NOT EXISTS ${OUTPUT_FILE} ) + message( FATAL_ERROR "Configuration failed to write file ${OUTPUT_FILE}." ) +endif() diff --git a/CMakeModules/cmake_uninstall.cmake.in b/CMakeModules/cmake_uninstall.cmake.in new file mode 100644 index 0000000..fdb4804 --- /dev/null +++ b/CMakeModules/cmake_uninstall.cmake.in @@ -0,0 +1,22 @@ +if( NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" ) + message( FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"" ) +endif() + +file( READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files ) +string( REGEX REPLACE "\n" ";" files "${files}" ) + +foreach( file ${files} ) + message( STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"" ) + if( EXISTS "$ENV{DESTDIR}${file}" ) + exec_program( + "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + if( NOT "${rm_retval}" STREQUAL "0" ) + message( STATUS "Problem when removing \"$ENV{DESTDIR}${file}\"" ) + endif() + else() + message( STATUS "File \"$ENV{DESTDIR}${file}\" does not exist." ) + endif() +endforeach() diff --git a/CMakeModules/config.h.cmake b/CMakeModules/config.h.cmake new file mode 100644 index 0000000..3b4e121 --- /dev/null +++ b/CMakeModules/config.h.cmake @@ -0,0 +1,80 @@ +// Do not modify this file, it was automatically generated by CMake. + +#ifndef CONFIG_H_ +#define CONFIG_H_ + +#cmakedefine HAVE_STRCASECMP + +#cmakedefine HAVE_STRNCASECMP + +#cmakedefine HAVE_STRTOKR // spelled odly to differ from wx's similar test + +// Handle platform differences in math.h +#cmakedefine HAVE_MATH_H + +// Handle platform differences in C++ cmath. +#cmakedefine HAVE_CXX_CMATH + +#cmakedefine HAVE_CMATH_ASINH + +#cmakedefine HAVE_CMATH_ACOSH + +#cmakedefine HAVE_CMATH_ATANH + +#cmakedefine HAVE_CMATH_ISINF + +#cmakedefine HAVE_CLOCK_GETTIME + +#cmakedefine HAVE_GETTIMEOFDAY_FUNC + +#cmakedefine MALLOC_IN_STDLIB_H + +#if !defined( MALLOC_IN_STDLIB_H ) +#include <malloc.h> +#endif + +#cmakedefine HAVE_ISO646_H + +#if defined( HAVE_ISO646_H ) +#include <iso646.h> +#endif + +#if defined( HAVE_STRCASECMP ) +#define stricmp strcasecmp +#endif + +#if defined( HAVE_STRNCASECMP ) +#define strnicmp strncasecmp +#endif + +// Use Posix getc_unlocked() instead of getc() when it's available. +#cmakedefine HAVE_FGETC_NOLOCK + +// Warning!!! Using wxGraphicContext for rendering is experimental. +#cmakedefine USE_WX_GRAPHICS_CONTEXT 1 + +#cmakedefine USE_IMAGES_IN_MENUS 1 + +/// The legacy file format revision of the *.brd file created by this build +#define LEGACY_BOARD_FILE_VERSION 2 + +/// The install prefix defined during CMake configuration or fall back to CMAKE_INSTALL_PREFIX. +#define DEFAULT_INSTALL_PATH "@DEFAULT_INSTALL_PATH@" + +/// The wxPython version found during configuration. +#if defined( KICAD_SCRIPTING_WXPYTHON ) +#define WXPYTHON_VERSION "@WXPYTHON_VERSION@" +#endif + +/// When defined, build the GITHUB_PLUGIN for pcbnew. +#cmakedefine BUILD_GITHUB_PLUGIN + +/// When defined, use KIWAY and KIFACE DSOs +#cmakedefine USE_KIWAY_DLLS + +/// A file extension with a leading '.' is a suffix, and this one is used on +/// top level program modules which implement the KIFACE. +#define KIFACE_SUFFIX wxT( "@KIFACE_SUFFIX@" ) +#define KIFACE_PREFIX wxT( "@KIFACE_PREFIX@" ) + +#endif // CONFIG_H_ diff --git a/CMakeModules/download_boost.cmake b/CMakeModules/download_boost.cmake new file mode 100644 index 0000000..c29888c --- /dev/null +++ b/CMakeModules/download_boost.cmake @@ -0,0 +1,322 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + +# Download a particular boost version, and patch it [and build it if BUILD_GITHUB_PLUGIN]. +# Assumes include( ExternalProject ) was done inline previous to this file +# and that set( DOWNLOAD_DIR ... ) was set in a higher context. + + +#-----<configure>---------------------------------------------------------------- + +set( BOOST_RELEASE 1.54.0 ) +set( BOOST_MD5 15cb8c0803064faef0c4ddf5bc5ca279 ) # re-calc this on every RELEASE change + +# The boost headers [and static libs if built] go here, at the top of KiCad +# source tree in boost_root. +set( BOOST_ROOT "${PROJECT_SOURCE_DIR}/boost_root" ) + + +# Space separated list which indicates the subset of boost libraries to compile. +# Chosen libraries are based on AVHTTP requirements, and possibly +# unit_test_framework for its own worth. +# tool_manager.cpp -> coroutine -> context (_jump_fcontext) (on OSX) + +set( BOOST_LIBS_BUILT + context + #coroutine + date_time + #exception + filesystem + iostreams + locale + program_options + regex + #signals + system + thread + #unit_test_framework + ) +#-----</configure>--------------------------------------------------------------- + +if( NOT BZIP2_FOUND ) + find_package( BZip2 REQUIRED ) +endif() + +string( REGEX REPLACE "\\." "_" BOOST_VERS "${BOOST_RELEASE}" ) +set( PREFIX ${DOWNLOAD_DIR}/boost_${BOOST_VERS} ) + +# <SOURCE_DIR> = ${PREFIX}/src/boost +# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine +# download, the patch is applied. This lets you regenerate a new patch at any time +# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there. + +# path to the boost headers in the repo. +# repo = "${headers_src}/../.bzr" = "<SOURCE_DIR>/.bzr" +set( headers_src "${PREFIX}/src/boost/boost" ) + + +function( set_boost_lib_names libs output ) + foreach( lib ${libs} ) + set( fullpath_lib "${BOOST_ROOT}/lib/libboost_${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}" ) + list( APPEND results ${fullpath_lib} ) + endforeach() + # set the results into variable represented by output into caller's scope + set( ${output} ${results} PARENT_SCOPE ) +endfunction() + + +# (BTW "test" yields "unit_test_framework" when passed to bootstrap.sh ). +#message( STATUS "BOOST_LIBS_BUILT:${BOOST_LIBS_BUILT}" ) +string( REPLACE "unit_test_framework" "test" boost_libs_list "${BOOST_LIBS_BUILT}" ) +#message( STATUS "REPLACE libs_csv:${boost_libs_list}" ) + +# Default Toolset +set( BOOST_TOOLSET "toolset=gcc" ) + +if( KICAD_BUILD_STATIC OR APPLE ) + set( BOOST_LINKTYPE "link=static" ) +else() + unset( BOOST_LINKTYPE ) +endif() + + +find_program(patch_bin NAMES patch patch.exe) + +if( "${patch_bin}" STREQUAL "patch_bin-NOTFOUND" ) + set( PATCH_STR_CMD ${PATCH_STR_CMD} ) +else() + set( PATCH_STR_CMD ${patch_bin} -p0 -i ) +endif() + + + +if( MINGW AND NOT CMAKE_HOST_UNIX ) # building for MINGW on windows not UNIX + if( MSYS ) + # The Boost system does not build properly on MSYS using bootstrap.sh. Running + # bootstrap.bat with cmd.exe does. It's ugly but it works. At least for Boost + # version 1.54. + set( bootstrap cmd.exe /c "bootstrap.bat mingw" ) + else() + set( bootstrap ./bootstrap.bat mingw ) + endif() + + foreach( lib ${boost_libs_list} ) + set( b2_libs ${b2_libs} --with-${lib} ) + endforeach() + unset( BOOST_CFLAGS ) + +else() + string( REGEX REPLACE "\\;" "," libs_csv "${boost_libs_list}" ) + #message( STATUS "libs_csv:${libs_csv}" ) + + set( bootstrap ./bootstrap.sh --with-libraries=${libs_csv} ) + # pass to *both* C and C++ compilers + set( BOOST_CFLAGS "cflags=${PIC_FLAG}" ) + set( BOOST_CXXFLAGS "cxxflags=${PIC_FLAG}" ) + set( BOOST_INCLUDE "${BOOST_ROOT}/include" ) + unset( b2_libs ) +endif() + + +if( APPLE ) + set( BOOST_CXXFLAGS "cxxflags=-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} -fno-common" ) + set( BOOST_LINKFLAGS "linkflags=-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET} -fno-common" ) + set( BOOST_TOOLSET "toolset=darwin" ) + + if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) + set(BOOST_CXXFLAGS "${BOOST_CXXFLAGS} -fno-lto" ) + set(BOOST_LINKFLAGS "${BOOST_LINKFLAGS} -fno-lto" ) + endif() + + if( CMAKE_OSX_ARCHITECTURES ) + + if( (CMAKE_OSX_ARCHITECTURES MATCHES "386" OR CMAKE_OSX_ARCHITECTURES MATCHES "ppc ") AND + (CMAKE_OSX_ARCHITECTURES MATCHES "64")) + message( "-- BOOST found 32/64 Address Model" ) + + set( BOOST_ADDRESSMODEL "address-model=32_64" ) + endif() + + if( (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "386") AND + (CMAKE_OSX_ARCHITECTURES MATCHES "ppc")) + message("-- BOOST found ppc/x86 Architecture") + + set(BOOST_ARCHITECTURE "architecture=combined") + elseif( (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR CMAKE_OSX_ARCHITECTURES MATCHES "386") ) + message("-- BOOST found x86 Architecture") + + set(BOOST_ARCHITECTURE "architecture=x86") + elseif( (CMAKE_OSX_ARCHITECTURES MATCHES "ppc64" OR CMAKE_OSX_ARCHITECTURES MATCHES "ppc") ) + message("-- BOOST found ppc Architecture") + + set(BOOST_ARCHITECTURE "architecture=ppc") + endif() + + set( BOOST_CFLAGS "${BOOST_CFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" ) + set( BOOST_CXXFLAGS "${BOOST_CXXFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" ) + set( BOOST_LINKFLAGS "${BOOST_LINKFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" ) + endif() +endif() + +ExternalProject_Add( boost + PREFIX "${PREFIX}" + + URL http://downloads.sourceforge.net/project/boost/boost/${BOOST_RELEASE}/boost_${BOOST_VERS}.tar.bz2 + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + TIMEOUT 1200 # 20 minutes + URL_MD5 ${BOOST_MD5} + # If download fails, then enable "LOG_DOWNLOAD ON" and try again. + # Upon a second failure with logging enabled, then look at these logs: + # <src>/.downloads-by-cmake$ less /tmp/product/.downloads-by-cmake/boost_1_54_0/src/boost-stamp/boost-download-out.log + # <src>/.downloads-by-cmake$ less /tmp/product/.downloads-by-cmake/boost_1_54_0/src/boost-stamp/boost-download-err.log + # If out.log does not show 100%, then try increasing TIMEOUT even more, or download the URL manually and put it + # into <src>/.downloads-by-cmake/ dir. + # LOG_DOWNLOAD ON + + INSTALL_DIR "${BOOST_ROOT}" + + # The patch command executes with the working directory set to <SOURCE_DIR> + # Revert the branch to pristine before applying patch sets as bzr patch + # fails when applying a patch to the branch twice and doesn't have a switch + # to ignore previously applied patches + PATCH_COMMAND bzr revert + # bzr revert is insufficient to remove "added" files: + COMMAND bzr clean-tree -q --force + + COMMAND ${PATCH_STR_CMD} "${PROJECT_SOURCE_DIR}/patches/boost_minkowski.patch" + COMMAND ${PATCH_STR_CMD} "${PROJECT_SOURCE_DIR}/patches/boost_cstdint.patch" + + COMMAND ${PATCH_STR_CMD} "${PROJECT_SOURCE_DIR}/patches/boost_macosx_x86.patch" #https://svn.boost.org/trac/boost/ticket/8266 + # tell bzr about "added" files by last patch: + COMMAND bzr add libs/context/src/asm/jump_i386_x86_64_sysv_macho_gas.S + COMMAND bzr add libs/context/src/asm/make_i386_x86_64_sysv_macho_gas.S + + COMMAND ${PATCH_STR_CMD} "${PROJECT_SOURCE_DIR}/patches/boost_macosx_x86_build.patch" #https://svn.boost.org/trac/boost/ticket/8266 + COMMAND ${PATCH_STR_CMD} "${PROJECT_SOURCE_DIR}/patches/boost_macosx_older_openssl.patch" #https://svn.boost.org/trac/boost/ticket/9273 + + COMMAND ${PATCH_STR_CMD} "${PROJECT_SOURCE_DIR}/patches/boost_mingw.patch" #https://svn.boost.org/trac/boost/ticket/7262 + COMMAND ${PATCH_STR_CMD} "${PROJECT_SOURCE_DIR}/patches/boost_mingw64_interlocked.patch" + + # tell bzr about "added" files by last patch: + COMMAND bzr add libs/context/src/asm/make_i386_ms_pe_gas.S + COMMAND bzr add libs/context/src/asm/jump_i386_ms_pe_gas.S + COMMAND bzr add libs/context/src/asm/make_x86_64_ms_pe_gas.S + COMMAND bzr add libs/context/src/asm/jump_x86_64_ms_pe_gas.S + + COMMAND ${PATCH_STR_CMD} "${PROJECT_SOURCE_DIR}/patches/patch_macosx_context_ppc_v2.patch" #https://svn.boost.org/trac/boost/ticket/8266 + COMMAND bzr add libs/context/build/Jamfile.v2 + COMMAND bzr add libs/context/build/architecture.jam + COMMAND bzr add libs/context/src/asm/jump_combined_sysv_macho_gas.S + COMMAND bzr add libs/context/src/asm/jump_ppc32_sysv_macho_gas.S + COMMAND bzr add libs/context/src/asm/jump_ppc64_sysv_macho_gas.S + COMMAND bzr add libs/context/src/asm/make_combined_sysv_macho_gas.S + COMMAND bzr add libs/context/src/asm/make_ppc32_sysv_macho_gas.S + COMMAND bzr add libs/context/src/asm/make_ppc64_sysv_macho_gas.S + + # [Mis-]use this step to erase all the boost headers and libraries before + # replacing them below. + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${BOOST_ROOT}" + + BINARY_DIR "${PREFIX}/src/boost/" + CONFIGURE_COMMAND ${bootstrap} + + BUILD_COMMAND ./b2 + variant=release + threading=multi + ${BOOST_CFLAGS} + ${BOOST_TOOLSET} + ${BOOST_CXXFLAGS} + ${BOOST_LINKFLAGS} + ${BOOST_ADDRESSMODEL} + ${BOOST_ARCHITECTURE} + ${b2_libs} + ${BOOST_LINKTYPE} + --prefix=<INSTALL_DIR> + install + + INSTALL_COMMAND "" + ) + +if( MINGW ) + execute_process( COMMAND ${CMAKE_C_COMPILER} -dumpversion + OUTPUT_VARIABLE GCC_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE ) + + string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.[0-9]+.*" "\\1\\2" BOOST_GCC_VERSION ${GCC_VERSION} ) + #message( STATUS "BOOST_GCC_VERSION: ${BOOST_GCC_VERSION}" ) + + string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9])" "\\1_\\2" BOOST_LIB_VERSION ${BOOST_RELEASE} ) + #message( STATUS "BOOST_LIB_VERSION: ${BOOST_LIB_VERSION}" ) + + # adjust the names of the libraries to suit the build. There's no + # symbolic links provided on the MinGW build to allow us to use + # generic names for the libs + foreach( lib ${BOOST_LIBS_BUILT} ) + set( mingw_boost_libs ${mingw_boost_libs} ${lib}-mgw${BOOST_GCC_VERSION}-mt-${BOOST_LIB_VERSION} ) + endforeach() + + set( BOOST_LIBS_BUILT ${mingw_boost_libs} ) + set( BOOST_INCLUDE "${BOOST_ROOT}/include/boost-${BOOST_LIB_VERSION}" ) + unset( mingw_boost_libs ) +endif() + +set( boost_libs "" ) +set_boost_lib_names( "${BOOST_LIBS_BUILT}" boost_libs ) + +set( Boost_LIBRARIES ${boost_libs} ) +set( Boost_INCLUDE_DIR "${BOOST_INCLUDE}" ) + +mark_as_advanced( Boost_LIBRARIES Boost_INCLUDE_DIR ) + +#message( STATUS "BOOST_ROOT:${BOOST_ROOT} BOOST_LIBRARIES:${BOOST_LIBRARIES}" ) +#message( STATUS "Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}" ) + + + +ExternalProject_Add_Step( boost bzr_commit_boost + COMMAND bzr ci -q -m pristine <SOURCE_DIR> + COMMENT "committing pristine boost files to 'boost scratch repo'" + DEPENDERS patch + ) + + +ExternalProject_Add_Step( boost bzr_add_boost + # add only the headers to the scratch repo, repo = "../.bzr" from ${headers_src} + COMMAND bzr add -q ${PREFIX}/src/boost + COMMENT "adding pristine boost files to 'boost scratch repo'" + DEPENDERS bzr_commit_boost + ) + + +ExternalProject_Add_Step( boost bzr_init_boost + COMMAND bzr init -q <SOURCE_DIR> + #creates a .bzrignore file in boost root dir, to avoid copying useless files + #moreover these files have a very very long name, and sometimes + #have a too long full file name to be handled by DOS commands + COMMAND echo "*.htm*" > ${PREFIX}/src/boost/.bzrignore + COMMENT "creating 'boost scratch repo' specifically for boost to track boost patches" + DEPENDERS bzr_add_boost + DEPENDEES download + ) + diff --git a/CMakeModules/download_cairo.cmake b/CMakeModules/download_cairo.cmake new file mode 100644 index 0000000..2d8b30e --- /dev/null +++ b/CMakeModules/download_cairo.cmake @@ -0,0 +1,109 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# Downloads and builds CAIRO + +#-----<configure>---------------------------------------------------------------- + +set( CAIRO_RELEASE 1.12.0 ) +set( CAIRO_MD5 e6c85575ba7094f88b637bdfd835a751 ) # re-calc this on every RELEASE change + +# The boost headers [and static libs if built] go here, at the top of KiCad +# source tree in boost_root. +set( CAIRO_ROOT "${PROJECT_SOURCE_DIR}/cairo_root" ) + +#-----</configure>--------------------------------------------------------------- + +if( NOT BZIP2_FOUND ) + find_package( BZip2 REQUIRED ) +endif() + +set( PREFIX ${DOWNLOAD_DIR}/cairo ) + +if ( KICAD_BUILD_STATIC ) + set( CAIRO_BUILDTYPE --disable-shared ) +endif( KICAD_BUILD_STATIC ) + + +if (APPLE) + + set( CAIRO_CFLAGS "CFLAGS=" ) + set( CAIRO_LDFLAGS "LDFLAGS=-framework CoreServices -framework Cocoa" ) + set( CAIRO_OPTS --enable-ft=no ) + + if( CMAKE_OSX_ARCHITECTURES ) + set( CAIRO_CFLAGS "${CAIRO_CFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" ) + set( CAIRO_LDFLAGS "${CAIRO_LDFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES}" ) + endif( CMAKE_OSX_ARCHITECTURES ) + + if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) + set(CAIRO_CFLAGS "${CAIRO_CFLAGS} -fno-lto" ) + endif() + + if( CMAKE_OSX_SYSROOT ) + #set( CAIRO_CFLAGS "${CAIRO_CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}") + set( CAIRO_LDFLAGS "${CAIRO_LDFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}") + endif( CMAKE_OSX_SYSROOT) + +endif(APPLE) + +# <SOURCE_DIR> = ${PREFIX}/src/glew +# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine +# download, the patch is applied. This lets you regenerate a new patch at any time +# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there. + +ExternalProject_Add( cairo + PREFIX "${PREFIX}" + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + URL http://cairographics.org/releases/cairo-${CAIRO_RELEASE}.tar.gz + URL_MD5 ${CAIRO_MD5} + STAMP_DIR "${PREFIX}" + + DEPENDS pkgconfig pixman libpng + + BUILD_IN_SOURCE 1 + #SOURCE_DIR "${PREFIX}" + #PATCH_COMMAND "" + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${CAIRO_ROOT}" + + CONFIGURE_COMMAND ./configure --prefix=${CAIRO_ROOT} --enable-static ${CAIRO_BUILDTYPE} + PKG_CONFIG=${PROJECT_SOURCE_DIR}/pkgconfig_root/bin/pkg-config + PKG_CONFIG_PATH=${PROJECT_SOURCE_DIR}/pixman_root/lib/pkgconfig:${PROJECT_SOURCE_DIR}/libpng_root/lib/pkgconfig + --enable-png=yes --enable-svg=yes + --disable-silent-rules --disable-dependency-tracking + ${CAIRO_CFLAGS} + ${CAIRO_LDFLAGS} + ${CAIRO_OPTS} + + #BINARY_DIR "${PREFIX}" + + BUILD_COMMAND $(MAKE) + + INSTALL_DIR "${CAIRO_ROOT}" + INSTALL_COMMAND $(MAKE) install + ) + +# match these with whatever FindCairo.cmake sets +# Dick i'vent set it because /lib and /lib64 issue in non multiarch binaries OSs +#set( CAIRO_FOUND true ) +set( CAIRO_INCLUDE_DIR ${CAIRO_ROOT}/include ) +set( CAIRO_LIBRARIES ${CAIRO_ROOT}/lib ) diff --git a/CMakeModules/download_glew.cmake b/CMakeModules/download_glew.cmake new file mode 100644 index 0000000..1c7d690 --- /dev/null +++ b/CMakeModules/download_glew.cmake @@ -0,0 +1,89 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# Downloads and builds GLEW + +#-----<configure>---------------------------------------------------------------- + +set( GLEW_RELEASE 1.10.0 ) +set( GLEW_MD5 2f09e5e6cb1b9f3611bcac79bc9c2d5d ) # re-calc this on every RELEASE change + +# The boost headers [and static libs if built] go here, at the top of KiCad +# source tree in boost_root. +set( GLEW_ROOT "${PROJECT_SOURCE_DIR}/glew_root" ) + +#-----</configure>--------------------------------------------------------------- + +if( NOT BZIP2_FOUND ) + find_package( BZip2 REQUIRED ) +endif() + +set( PREFIX ${DOWNLOAD_DIR}/glew ) + +if (APPLE) + if( CMAKE_OSX_ARCHITECTURES ) + set( GLEW_CFLAGS "CFLAGS.EXTRA=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" ) + set( GLEW_LDFLAGS "LDFLAGS.EXTRA=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" ) + set( GLEW_STRIP "STRIP=") + endif( CMAKE_OSX_ARCHITECTURES ) +endif(APPLE) + +# <SOURCE_DIR> = ${PREFIX}/src/glew +# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine +# download, the patch is applied. This lets you regenerate a new patch at any time +# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there. + +ExternalProject_Add( glew + PREFIX "${PREFIX}" + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + URL http://sourceforge.net/projects/glew/files/glew/1.10.0/glew-${GLEW_RELEASE}.tgz + URL_MD5 ${GLEW_MD5} + STAMP_DIR "${PREFIX}" + + #SOURCE_DIR "${PREFIX}" + BUILD_IN_SOURCE 1 + + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${GLEW_ROOT}" + + #PATCH_COMMAND "true" + CONFIGURE_COMMAND "" + + #BINARY_DIR "${PREFIX}" + + BUILD_COMMAND $(MAKE) ${GLEW_CFLAGS} ${GLEW_LDFLAGS} ${GLEW_STRIP} + + INSTALL_DIR "${GLEW_ROOT}" + INSTALL_COMMAND $(MAKE) GLEW_DEST="${GLEW_ROOT}" install + ) + +# +# Optional Steps +# + +if( APPLE ) +# On OSX is needed to run ranlib to make .a indexes for all platforms +ExternalProject_Add_Step( glew glew_osx_ranlib + COMMAND ranlib "${GLEW_ROOT}/lib/libGLEW.a" + COMMENT "ranlib ${GLEW_ROOT}/lib/libGLEW.a - Needed on OSX only" + DEPENDEES install + ) +endif() diff --git a/CMakeModules/download_libpng.cmake b/CMakeModules/download_libpng.cmake new file mode 100644 index 0000000..35de835 --- /dev/null +++ b/CMakeModules/download_libpng.cmake @@ -0,0 +1,76 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# Downloads and builds LIBPNG + +#-----<configure>---------------------------------------------------------------- + +set( LIBPNG_RELEASE 1.4.12 ) +set( LIBPNG_MD5 849b14d88e1240a1b9f2cb39dd39701e ) # re-calc this on every RELEASE change + +# The boost headers [and static libs if built] go here, at the top of KiCad +# source tree in boost_root. +set( LIBPNG_ROOT "${PROJECT_SOURCE_DIR}/libpng_root" ) + +#-----</configure>--------------------------------------------------------------- + +find_package( BZip2 REQUIRED ) + +set( PREFIX ${DOWNLOAD_DIR}/libpng ) + +if (APPLE) + if( CMAKE_OSX_ARCHITECTURES ) + SET( LIBPNG_CFLAGS "CFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES}") + endif( CMAKE_OSX_ARCHITECTURES ) +endif(APPLE) + +if (KICAD_BUILD_STATIC) + set(LIBPNG_OPTS --enable-static --disable-shared) +else() + set(LIBPNG_OPTS --enable-static --enable-shared) +endif(KICAD_BUILD_STATIC) + +# <SOURCE_DIR> = ${PREFIX}/src/glew +# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine +# download, the patch is applied. This lets you regenerate a new patch at any time +# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there. + +ExternalProject_Add( libpng + PREFIX "${PREFIX}" + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + URL http://sourceforge.net/projects/libpng/files/libpng14/${LIBPNG_RELEASE}/libpng-${LIBPNG_RELEASE}.tar.bz2 + URL_MD5 ${LIBPNG_MD5} + STAMP_DIR "${PREFIX}" + + #SOURCE_DIR "${PREFIX}" + BUILD_IN_SOURCE 1 + + #PATCH_COMMAND "true" + CONFIGURE_COMMAND ./configure --prefix=${LIBPNG_ROOT} ${LIBPNG_OPTS} ${LIBPNG_CFLAGS} --disable-dependency-tracking + #BINARY_DIR "${PREFIX}" + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${LIBPNG_ROOT}" + + BUILD_COMMAND $(MAKE) + + INSTALL_DIR "${LIBPNG_ROOT}" + INSTALL_COMMAND $(MAKE) install + ) diff --git a/CMakeModules/download_openssl.cmake b/CMakeModules/download_openssl.cmake new file mode 100644 index 0000000..6ab8fc7 --- /dev/null +++ b/CMakeModules/download_openssl.cmake @@ -0,0 +1,127 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + +# Download OPENSSL and install into ${PREFIX}, typically in our KiCad source tree. +# Assumes include( ExternalProject ) was done inline previous to this file +# and that set( DOWNLOAD_DIR ... ) was set in a higher context. + +#-----<configure>------------------------------------------------------------------------------------- + +set( OPENSSL_RELEASE "1.0.1e" ) +set( OPENSSL_MD5 08bec482fe1c4795e819bfcfcb9647b9 ) # re-calc on every RELEASE change + +#-----</configure>----------------------------------------------------------------------------------- + +set( PREFIX ${DOWNLOAD_DIR}/openssl-${OPENSSL_RELEASE} ) + +# CMake barfs if we pass in an empty CMAKE_TOOLCHAIN_FILE, so we only set it up +# if it has a non-empty value +unset( TOOLCHAIN ) +if( CMAKE_TOOLCHAIN_FILE ) + set( TOOLCHAIN "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" ) +endif() + +FIND_PROGRAM (patch_bin NAMES patch.exe patch) + +if( "${patch_bin}" STREQUAL "patch_bin-NOTFOUND" ) + set( PATCH_STR_CMD bzr patch -p0 ) +else() + set( PATCH_STR_CMD ${patch_bin} -p0 -i ) +endif() + +ExternalProject_Add( + openssl + DOWNLOAD_DIR ${DOWNLOAD_DIR} + PREFIX ${PREFIX} + TIMEOUT 60 + URL http://launchpad.net/openssl-cmake/1.0.1e/1.0.1e-1/+download/openssl-cmake-1.0.1e-src.tar.gz + URL_MD5 ${OPENSSL_MD5} + + # mingw uses msvcrt.dll's printf() which cannot handle %zd, so having + # BIO_snprintf() reference printf()'s formating attributes is a bug, since + # BIO_snprintf() does its own formatting and is different from msvcrt's printf(). + + # This one would be easier if Windows folks could be asked to install "patch.exe" + # PATCH_COMMAND patch -p0 < ${PROJECT_SOURCE_DIR}/patches/openssl-1.0.1e.patch + + # This one requires the bzr commit below, since bzr patch only knows a working tree. + + # Revert the branch to pristine before applying patch sets as bzr patch + # fails when applying a patch to the branch twice and doesn't have a switch + # to ignore previously applied patches + PATCH_COMMAND bzr revert + # PATCH_COMMAND continuation (any *_COMMAND here can be continued with COMMAND): + COMMAND ${PATCH_STR_CMD} ${PROJECT_SOURCE_DIR}/patches/openssl-1.0.1e.patch + + CONFIGURE_COMMAND + ${CMAKE_COMMAND} + -G ${CMAKE_GENERATOR} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> + -DBUILD_SHARED_LIBS=ON + ${TOOLCHAIN} + <SOURCE_DIR> + + BUILD_IN_SOURCE 1 + BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} + INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install + ) + +# In order to use "bzr patch", we have to have a bzr working tree, this means a bzr repo +# must be created and source committed to it. These extra steps do that. + +set( target "openssl" ) + +ExternalProject_Add_Step( ${target} bzr_commit_${target} + COMMAND bzr ci -q -m pristine <SOURCE_DIR> + COMMENT "committing pristine ${target} files to '${target} scratch repo'" + DEPENDERS patch + ) + +ExternalProject_Add_Step( ${target} bzr_add_${target} + COMMAND bzr add -q <SOURCE_DIR> + COMMENT "adding pristine ${target} files to '${target} scratch repo'" + DEPENDERS bzr_commit_${target} + ) + +ExternalProject_Add_Step( ${target} bzr_init_${target} + COMMAND bzr init -q <SOURCE_DIR> + COMMENT "creating '${target} scratch repo' specifically for tracking ${target} patches" + DEPENDERS bzr_add_${target} + DEPENDEES download + ) + +# The spelling of these is always taken from CMake Module's FindXYZ.cmake file: +set( OPENSSL_INCLUDE_DIR + ${PREFIX}/include + CACHE FILEPATH "OPENSSL include directory" + ) + +set( OPENSSL_LIBRARIES + ${PREFIX}/lib/libssl${CMAKE_IMPORT_LIBRARY_SUFFIX} + ${PREFIX}/lib/libcrypto${CMAKE_IMPORT_LIBRARY_SUFFIX} + CACHE STRING "OPENSSL libraries" + ) +set( OPENSSL_FOUND true ) + diff --git a/CMakeModules/download_pcre.cmake b/CMakeModules/download_pcre.cmake new file mode 100644 index 0000000..09f8900 --- /dev/null +++ b/CMakeModules/download_pcre.cmake @@ -0,0 +1,67 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# Downloads and builds PCRE + +#-----<configure>---------------------------------------------------------------- + +set( PCRE_RELEASE 8.34 ) +set( PCRE_MD5 eb34b2c9c727fd64940d6fd9a00995eb ) # re-calc this on every RELEASE change + +set( PCRE_ROOT "${PROJECT_SOURCE_DIR}/pcre_root" ) + +#-----</configure>--------------------------------------------------------------- + +find_package( BZip2 REQUIRED ) + +set( PREFIX ${DOWNLOAD_DIR}/pcre ) + +if (APPLE) + if( CMAKE_OSX_ARCHITECTURES ) + set( PCRE_CFLAGS "CFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" ) + set( PCRE_CXXFLAGS "CXXFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" ) + set( PCRE_LDFLAGS "LDFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" ) + endif( CMAKE_OSX_ARCHITECTURES ) +endif(APPLE) + +ExternalProject_Add( pcre + PREFIX "${PREFIX}" + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + URL http://sourceforge.net/projects/pcre/files/pcre/${PCRE_RELEASE}/pcre-${PCRE_RELEASE}.tar.gz + URL_MD5 ${PCRE_MD5} + STAMP_DIR "${PREFIX}" + + #SOURCE_DIR "${PREFIX}" + BUILD_IN_SOURCE 1 + + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${PCRE_ROOT}" + + #PATCH_COMMAND "true" + CONFIGURE_COMMAND ./configure --prefix=${PCRE_ROOT} ${PCRE_CFLAGS} ${PCRE_CXXFLAGS} ${PCRE_LDFLAGS} --disable-dependency-tracking + + #BINARY_DIR "${PREFIX}" + + BUILD_COMMAND $(MAKE) + + INSTALL_DIR "${PCRE_ROOT}" + INSTALL_COMMAND $(MAKE) install + ) diff --git a/CMakeModules/download_pixman.cmake b/CMakeModules/download_pixman.cmake new file mode 100644 index 0000000..cba41a1 --- /dev/null +++ b/CMakeModules/download_pixman.cmake @@ -0,0 +1,83 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# Downloads and builds PIXMAN + +#-----<configure>---------------------------------------------------------------- + +set( PIXMAN_RELEASE 0.32.4 ) +set( PIXMAN_MD5 eba449138b972fbf4547a8c152fea162 ) # re-calc this on every RELEASE change + +# The boost headers [and static libs if built] go here, at the top of KiCad +# source tree in boost_root. +set( PIXMAN_ROOT "${PROJECT_SOURCE_DIR}/pixman_root" ) + +#-----</configure>--------------------------------------------------------------- + +if( NOT BZIP2_FOUND ) + find_package( BZip2 REQUIRED ) +endif() + +set( PREFIX ${DOWNLOAD_DIR}/pixman ) + +set(PIXMAN_CPPFLAGS "CFLAGS=") + +if (APPLE) + if( CMAKE_OSX_ARCHITECTURES ) + set(PIXMAN_CPPFLAGS "${PIXMAN_CPPFLAGS} -arch ${CMAKE_OSX_ARCHITECTURES} -fno-common -mmacosx-version-min=10.5") + else() + set(PIXMAN_CPPFLAGS "${PIXMAN_CPPFLAGS} -fno-common -mmacosx-version-min=10.5") + endif( CMAKE_OSX_ARCHITECTURES ) +endif(APPLE) + +if (KICAD_BUILD_STATIC) + set(PIXMAN_OPTS --enable-static=yes --enable-shared=no) +else() + set(PIXMAN_OPTS --enable-static=yes --enable-shared=yes) +endif(KICAD_BUILD_STATIC) + +# <SOURCE_DIR> = ${PREFIX}/src/glew +# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine +# download, the patch is applied. This lets you regenerate a new patch at any time +# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there. + +ExternalProject_Add( pixman + PREFIX "${PREFIX}" + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + URL http://cairographics.org/releases/pixman-${PIXMAN_RELEASE}.tar.gz + URL_MD5 ${PIXMAN_MD5} + STAMP_DIR "${PREFIX}" + + #SOURCE_DIR "${PREFIX}" + BUILD_IN_SOURCE 1 + + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${PIXMAN_ROOT}" + + #PATCH_COMMAND "true" + CONFIGURE_COMMAND ./configure --prefix=${PIXMAN_ROOT} ${PIXMAN_OPTS} ${PIXMAN_CPPFLAGS} --disable-dependency-tracking + #BINARY_DIR "${PREFIX}" + + BUILD_COMMAND $(MAKE) + + INSTALL_DIR "${PIXMAN_ROOT}" + INSTALL_COMMAND $(MAKE) install + ) diff --git a/CMakeModules/download_pkgconfig.cmake b/CMakeModules/download_pkgconfig.cmake new file mode 100644 index 0000000..a0f6c53 --- /dev/null +++ b/CMakeModules/download_pkgconfig.cmake @@ -0,0 +1,80 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# Downloads and builds CAIRO + +#-----<configure>---------------------------------------------------------------- + +set( PKGCONFIG_RELEASE 0.28 ) +set( PKGCONFIG_MD5 aa3c86e67551adc3ac865160e34a2a0d ) # re-calc this on every RELEASE change + +# The boost headers [and static libs if built] go here, at the top of KiCad +# source tree in boost_root. +set( PKGCONFIG_ROOT "${PROJECT_SOURCE_DIR}/pkgconfig_root" ) + +#-----</configure>--------------------------------------------------------------- + +if( NOT BZIP2_FOUND ) + find_package( BZip2 REQUIRED ) +endif() + +set( PREFIX ${DOWNLOAD_DIR}/pkgconfig ) + +if ( KICAD_BUILD_STATIC ) + set( PKGCONFIG_BUILDTYPE --enable-shared=no --enable-static=yes ) +else() + set( PKGCONFIG_BUILDTYPE --enable-shared=yes --enable-static=yes ) +endif( KICAD_BUILD_STATIC ) + +# <SOURCE_DIR> = ${PREFIX}/src/glew +# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine +# download, the patch is applied. This lets you regenerate a new patch at any time +# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there. + +ExternalProject_Add( pkgconfig + PREFIX "${PREFIX}" + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + URL http://pkgconfig.freedesktop.org/releases/pkg-config-${PKGCONFIG_RELEASE}.tar.gz + URL_MD5 ${PKGCONFIG_MD5} + STAMP_DIR "${PREFIX}" + + #SOURCE_DIR "${PREFIX}" + BUILD_IN_SOURCE 1 + + #PATCH_COMMAND "true" + CONFIGURE_COMMAND ./configure --prefix=${PKGCONFIG_ROOT} --with-internal-glib ${PKGCONFIG_BUILDTYPE} --disable-silent-rules + #BINARY_DIR "${PREFIX}" + + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${PKGCONFIG_ROOT}" + + BUILD_COMMAND $(MAKE) + + INSTALL_DIR "${PKGCONFIG_ROOT}" + INSTALL_COMMAND $(MAKE) install + ) + +ExternalProject_Add_Step( pkgconfig pkgconfig_cleanup + COMMAND ${CMAKE_COMMAND} -E remove_directory "${PKGCONFIG_ROOT}" + COMMENT "pkgconfig - cleanup destination before proceeding in install" + DEPENDEES build + ) + diff --git a/CMakeModules/download_swig.cmake b/CMakeModules/download_swig.cmake new file mode 100644 index 0000000..e72918e --- /dev/null +++ b/CMakeModules/download_swig.cmake @@ -0,0 +1,79 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# Downloads and builds SWIG + +#-----<configure>---------------------------------------------------------------- + +set( SWIG_RELEASE 2.0.11 ) +set( SWIG_MD5 291ba57c0acd218da0b0916c280dcbae ) # re-calc this on every RELEASE change + +# The boost headers [and static libs if built] go here, at the top of KiCad +# source tree in boost_root. +set( SWIG_ROOT "${PROJECT_SOURCE_DIR}/swig_root" ) + +#-----</configure>--------------------------------------------------------------- + +find_package( BZip2 REQUIRED ) + +set( PREFIX ${DOWNLOAD_DIR}/swig ) + +if (APPLE) + if( CMAKE_OSX_ARCHITECTURES ) + set( SWIG_CFLAGS "CFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" ) + set( SWIG_CXXFLAGS "CXXFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" ) + set( SWIG_LDFLAGS "LDFLAGS=-arch ${CMAKE_OSX_ARCHITECTURES} -mmacosx-version-min=10.5" ) + endif( CMAKE_OSX_ARCHITECTURES ) + + set( SWIG_PYTHON "--with-python=/usr/bin/python2.6" ) + set( SWIG_OPTS --disable-dependency-tracking ) +endif(APPLE) + +# <SOURCE_DIR> = ${PREFIX}/src/glew +# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine +# download, the patch is applied. This lets you regenerate a new patch at any time +# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there. + +ExternalProject_Add( swig + PREFIX "${PREFIX}" + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + URL http://sourceforge.net/projects/swig/files/swig/swig-${SWIG_RELEASE}/swig-${SWIG_RELEASE}.tar.gz + URL_MD5 ${SWIG_MD5} + STAMP_DIR "${PREFIX}" + + DEPENDS pcre + + #SOURCE_DIR "${PREFIX}" + BUILD_IN_SOURCE 1 + + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${SWIG_ROOT}" + + #PATCH_COMMAND "true" + CONFIGURE_COMMAND ./configure --prefix=${SWIG_ROOT} --with-pcre-prefix=${PCRE_ROOT} ${SWIG_CFLAGS} ${SWIG_LDFLAGS} ${SWIG_CXXFLAGS} ${SWIG_PYTHON} ${SWIG_OPTS} + + #BINARY_DIR "${PREFIX}" + + BUILD_COMMAND $(MAKE) + + INSTALL_DIR "${SWIG_ROOT}" + INSTALL_COMMAND $(MAKE) install + ) diff --git a/CMakeModules/download_wxpython.cmake b/CMakeModules/download_wxpython.cmake new file mode 100644 index 0000000..112a8de --- /dev/null +++ b/CMakeModules/download_wxpython.cmake @@ -0,0 +1,121 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# Downloads and builds LIBWXPYTHON + +#-----<configure>---------------------------------------------------------------- + +set( LIBWXPYTHON_RELEASE 3.0.0.0 ) +set( LIBWXPYTHON_MD5 f5e32c7d85dc261ba777e113c3b7e365 ) # re-calc this on every RELEASE change + +set( LIBWXPYTHON_ROOT "${PROJECT_SOURCE_DIR}/libwxpython_root" ) + +#-----</configure>--------------------------------------------------------------- + +find_package( BZip2 REQUIRED ) + +set( PREFIX ${DOWNLOAD_DIR}/libwxpython ) +set( LIBWXPYTHON_EXEC python ) +set( LIBWXPYTHON_OPTS --wxpy_installdir=${LIBWXPYTHON_ROOT}/wxPython ) + +if (APPLE) + SET( LIBWXPYTHON_EXEC python2.6 ) + SET( LIBWXPYTHON_OPTS ${LIBWXPYTHON_OPTS} --osx_cocoa ) + #SET( LIBWXPYTHON_OPTS ${LIBWXPYTHON_OPTS} --mac_framework --mac_framework_prefix=${LIBWXPYTHON_ROOT}/wxPython ) + + if( CMAKE_OSX_ARCHITECTURES ) + STRING(REGEX REPLACE " -arch " "," LIBWXPYTHON_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES}) + SET( LIBWXPYTHON_OPTS ${LIBWXPYTHON_OPTS} --mac_arch=${LIBWXPYTHON_ARCHITECTURES}) + endif( CMAKE_OSX_ARCHITECTURES ) + + if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) + SET( LIBWXPYTHON_PRECMD export CFLAGS=-Qunused-arguments && ) + endif() +endif(APPLE) + +if ( KICAD_BUILD_STATIC ) + #message fail + set( LIBWXPYTHON_BUILDTYPE "--disable-shared" ) +endif( KICAD_BUILD_STATIC ) + +# <SOURCE_DIR> = ${PREFIX}/src/libwx +# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine +# download, the patch is applied. This lets you regenerate a new patch at any time +# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there. + +ExternalProject_Add( libwxpython + PREFIX "${PREFIX}" + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + URL http://sourceforge.net/projects/wxpython/files/wxPython/${LIBWXPYTHON_RELEASE}/wxPython-src-${LIBWXPYTHON_RELEASE}.tar.bz2 + URL_MD5 ${LIBWXPYTHON_MD5} + STAMP_DIR "${PREFIX}" + + BUILD_IN_SOURCE 1 + + PATCH_COMMAND bzr revert + COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/wxpython-3.0.0_macosx.patch" + COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/wxpython-3.0.0_macosx_multiarch.patch" # http://trac.wxwidgets.org/ticket/15957 + + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${LIBWXPYTHON_ROOT}" + COMMAND ${LIBWXPYTHON_EXEC} wxPython/build-wxpython.py --clean + + CONFIGURE_COMMAND ${LIBWXPYTHON_PRECMD} ${LIBWXPYTHON_EXEC} wxPython/build-wxpython.py --prefix=${LIBWXPYTHON_ROOT} --unicode --install ${LIBWXPYTHON_OPTS} + + #BINARY_DIR "${PREFIX}" + + BUILD_COMMAND true + + INSTALL_DIR "${LIBWXPYTHON_ROOT}" + INSTALL_COMMAND true + ) + +ExternalProject_Add_Step( libwxpython bzr_commit_libwxpython + COMMAND bzr ci -q -m pristine <SOURCE_DIR> + COMMENT "committing pristine libwxpython files to 'libwxpython scratch repo'" + DEPENDERS patch + ) + + +ExternalProject_Add_Step( libwxpython bzr_add_libwxpython + COMMAND bzr add -q ${PREFIX}/src/libwxpython + COMMENT "adding pristine libwxpython files to 'libwxpython scratch repo'" + DEPENDERS bzr_commit_libwxpython + ) + + +ExternalProject_Add_Step( libwxpython bzr_init_libwxpython + COMMAND bzr init -q <SOURCE_DIR> + COMMENT "creating 'libwxpython scratch repo' specifically for libwx to track libwx patches" + DEPENDERS bzr_add_libwxpython + DEPENDEES download + ) + +###### +# Now is time to search what we have built +###### + +ExternalProject_Add_Step( libwxpython libwxpython_recursive_message + COMMAND cmake . + COMMENT "*** RERUN CMAKE - wxWidgets built, now reissue a cmake to build Kicad" + DEPENDEES install + ) + diff --git a/CMakeModules/download_wxwidgets.cmake b/CMakeModules/download_wxwidgets.cmake new file mode 100644 index 0000000..ed7ebe8 --- /dev/null +++ b/CMakeModules/download_wxwidgets.cmake @@ -0,0 +1,119 @@ +# This program source code file is part of KICAD, a free EDA CAD application. +# +# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> +# Copyright (C) 2013 Kicad Developers, see AUTHORS.txt for contributors. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, you may find one here: +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html +# or you may search the http://www.gnu.org website for the version 2 license, +# or you may write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# Downloads and builds LIBWX + +#-----<configure>---------------------------------------------------------------- + +set( LIBWX_RELEASE 3.0.0 ) +set( LIBWX_MD5 241998efc12205172ed24c18788ea2cd ) # re-calc this on every RELEASE change + +# The boost headers [and static libs if built] go here, at the top of KiCad +# source tree in boost_root. +set( LIBWX_ROOT "${PROJECT_SOURCE_DIR}/libwx_root" ) + +#-----</configure>--------------------------------------------------------------- + +if( NOT BZIP2_FOUND ) + find_package( BZip2 REQUIRED ) +endif() + +set( PREFIX ${DOWNLOAD_DIR}/libwx ) + +if (APPLE) + if( CMAKE_OSX_ARCHITECTURES ) + STRING(REGEX REPLACE " -arch " "," LIBWX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES}) + SET( LIBWX_ARCHITECTURES --enable-universal_binary=${LIBWX_ARCHITECTURES}) + endif( CMAKE_OSX_ARCHITECTURES ) +endif(APPLE) + +if ( KICAD_BUILD_STATIC ) + set( LIBWX_BUILDTYPE "--disable-shared" ) +endif( KICAD_BUILD_STATIC ) + +# <SOURCE_DIR> = ${PREFIX}/src/libwx +# There is a Bazaar 'boost scratch repo' in <SOURCE_DIR>/boost and after committing pristine +# download, the patch is applied. This lets you regenerate a new patch at any time +# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there. + +ExternalProject_Add( libwx + PREFIX "${PREFIX}" + DOWNLOAD_DIR "${DOWNLOAD_DIR}" + URL http://downloads.sourceforge.net/project/wxwindows/${LIBWX_RELEASE}/wxWidgets-${LIBWX_RELEASE}.tar.bz2 + URL_MD5 ${LIBWX_MD5} + STAMP_DIR "${PREFIX}" + + BUILD_IN_SOURCE 1 + + PATCH_COMMAND bzr revert + COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/wxwidgets-3.0.0_macosx.patch" + COMMAND bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/wxwidgets-3.0.0_macosx_bug_15908.patch" + + UPDATE_COMMAND ${CMAKE_COMMAND} -E remove_directory "${LIBWX_ROOT}" + + CONFIGURE_COMMAND ./configure --prefix=${LIBWX_ROOT} -with-opengl --enable-aui --enable-debug_info -with-expat=builtin --with-regex=builtin --enable-utf8 ${LIBWX_ARCHITECTURES} ${LIBWX_BUILDTYPE} + #BINARY_DIR "${PREFIX}" + + BUILD_COMMAND $(MAKE) VERBOSE=1 + + INSTALL_DIR "${LIBWX_ROOT}" + INSTALL_COMMAND make install + ) + +#SET directories +set(wxWidgets_BIN_DIR ${LIBWX_ROOT}/bin) +set(wxWidgets_CONFIG_EXECUTABLE ${LIBWX_ROOT}/bin/wx-config) +set(wxWidgets_INCLUDE_DIRS ${LIBWX_ROOT}/include) +set(wxWidgets_LIBRARY_DIRS ${LIBWX_ROOT}/lib) + + +ExternalProject_Add_Step( libwx bzr_commit_libwx + COMMAND bzr ci -q -m pristine <SOURCE_DIR> + COMMENT "committing pristine libwx files to 'libwx scratch repo'" + DEPENDERS patch + ) + + +ExternalProject_Add_Step( libwx bzr_add_libwx + COMMAND bzr add -q ${PREFIX}/src/libwx + COMMENT "adding pristine libwx files to 'libwx scratch repo'" + DEPENDERS bzr_commit_libwx + ) + + +ExternalProject_Add_Step( libwx bzr_init_libwx + COMMAND bzr init -q <SOURCE_DIR> + COMMENT "creating 'libwx scratch repo' specifically for libwx to track libwx patches" + DEPENDERS bzr_add_libwx + DEPENDEES download + ) + +###### +# Now is time to search what we have built +###### + +ExternalProject_Add_Step( libwx libwx_recursive_message + COMMAND cmake . + COMMENT "*** RERUN CMAKE - wxWidgets built, now reissue a cmake to build Kicad" + DEPENDEES install + ) + |