Commit 4d465ec8 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Configuration and compile documentation improvements.

* Improve the stable and testing build version option logic.
* Use CMake FindPythonInterp to configure the Python interpreter.
* Use Python interpreter to determine the system Python module install
  path if not already defined on the command line.
* Add header symbol checks for asinh(), acosh(), and atanh().
* Add test source to check for isinf() which can be defined as a C++template.
* Replace conditional compile on windows systems for aXXXh() with CMake
  configuration tests.
* A few minor MSVC compile fixes.
* Fix incorrect python environment string in fixswigimports.py
* Create a separate document for KiCad CMake build options.
* Create a separate how to compile KiCad on Windows document.
parent 00fafe7d
Loading
Loading
Loading
Loading
+35 −34
Original line number Diff line number Diff line
@@ -61,29 +61,22 @@ option(KICAD_SCRIPTING_WXPYTHON
# PYTHON_EXECUTABLE can be defined when invoking cmake
# ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
# when not defined by user, the default is python.exe under Windows and python2 for others
# python binary filee should be is exec path.
# python binary file should be is exec path.


#Set version option (stable or testing)

if (KICAD_STABLE_VERSION )
    if ( KICAD_TESTING_VERSION )
        message( FATAL_ERROR
        "Please set to ON only one option KICAD_TESTING_VERSION or KICAD_STABLE_VERSION" )
    endif( KICAD_TESTING_VERSION )
if(KICAD_STABLE_VERSION AND KICAD_TESTING_VERSION )
    message(FATAL_ERROR "Only one KiCad build version option KICAD_TESTING_VERSION or KICAD_STABLE_VERSION can be set to ON")
elif(NOT KICAD_STABLE_VERSION AND NOT KICAD_TESTING_VERSION)
    message(FATAL_ERROR "Either KiCad build version option KICAD_TESTING_VERSION or KICAD_STABLE_VERSION must be set to ON")
elif(KICAD_STABLE_VERSION)
    add_definitions(-DKICAD_STABLE_VERSION)
    message( "Build stable version of Kicad" )
else (KICAD_STABLE_VERSION )
    if (KICAD_TESTING_VERSION )
    message( "Build stable version of KiCad")
else(KICAD_STABLE_VERSION AND KICAD_TESTING_VERSION)
    add_definitions(-DKICAD_TESTING_VERSION)
        message( "Build testing (unstable) version of Kicad" )
    else (KICAD_TESTING_VERSION )
        message( "Please set to ON one option of KICAD_TESTING_VERSION or KICAD_STABLE_VERSION" )
        message( "When calling cmake add option -DKICAD_STABLE_VERSION=ON" )
        message( "or add option -DKICAD_TESTING_VERSION=ON" )
        message( FATAL_ERROR "one option of KICAD_TESTING_VERSION or KICAD_STABLE_VERSION must be defined" )
    endif(KICAD_TESTING_VERSION )
endif(KICAD_STABLE_VERSION )
    message("Build testing (unstable) version of KiCad")
endif(KICAD_STABLE_VERSION AND KICAD_TESTING_VERSION)


#================================================
@@ -292,21 +285,29 @@ endif(WIN32 AND USE_WX_GRAPHICS_CONTEXT)

# Find Python and other scripting resources
if(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
    set(PythonInterp_FIND_VERSION)
    find_package(PythonInterp)
    check_find_package_result(PYTHONINTERP_FOUND "Python Interpreter")

    # Get the correct Python site package install path from the Python interpreter found by
    # FindPythonInterp unless the user specifically defined a custom path.
    if(NOT PYTHON_SITE_PACKAGE_PATH)
        execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig;print\"%s\"%distutils.sysconfig.get_python_lib()"
            OUTPUT_VARIABLE PYTHON_SITE_PACKAGE_PATH
            OUTPUT_STRIP_TRAILING_WHITESPACE
            )

    if( "${PYTHON_EXECUTABLE}" STREQUAL  "" )
        if(WIN32)
            SET( PYTHON_EXECUTABLE "python.exe" )
        else(WIN32)
            SET( PYTHON_EXECUTABLE "python2" )
        endif(WIN32)
    endif()
        if(NOT PYTHON_SITE_PACKAGE_PATH)
            message(FATAL_ERROR "Error occurred while attemping to find the Python site library path.")
        endif(NOT PYTHON_SITE_PACKAGE_PATH)
    endif(NOT PYTHON_SITE_PACKAGE_PATH)

  execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sys;print\"%s.%s\"%sys.version_info[0:2]" OUTPUT_VARIABLE PYTHON_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
  set(PYTHON_DEST "lib/python${PYTHON_VERSION}/dist-packages" )
    set(PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}" CACHE PATH "Python module install path.")
    mark_as_advanced(PYTHON_DEST)
    message( STATUS "Python module install path: ${PYTHON_DEST}")
    find_package(PythonLibs)
    include_directories(${PYTHON_INCLUDE_PATH}
                        ./scripting)

endif(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)


+16 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ macro(perform_feature_checks)
    #include(CheckFunctionExists)
    include(CheckLibraryExists)
    include(CheckSymbolExists)
    include(CheckIncludeFileCXX)
    include(CheckCXXSymbolExists)
    include(CheckCXXSourceCompiles)

    check_include_file("malloc.h" HAVE_MALLOC_H)

@@ -70,8 +73,21 @@ macro(perform_feature_checks)
    check_symbol_exists(_stricmp "string.h" HAVE_ISO_STRICMP)
    check_symbol_exists(_strnicmp "string.h" HAVE_ISO_STRNICMP)
    check_symbol_exists(_snprintf "stdio.h" HAVE_ISO_SNPRINTF)

    # Check for functions in math.h.
    check_include_file("math.h" HAVE_MATH_H)
    check_symbol_exists(_hypot "math.h" HAVE_ISO_HYPOT)

    # 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>\nusing namespace std;\nint main(int argc, char** argv)\n{\n  (void)argv;\n  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)

+17 −0
Original line number Diff line number Diff line
@@ -17,13 +17,30 @@
#define snprintf _snprintf
#endif


// Handle platform differences in math.h
#cmakedefine HAVE_MATH_H

#cmakedefine HAVE_ISO_HYPOT

#if defined( HAVE_ISO_HYPOT )
#define hypot _hypot
#endif


// 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
+3 −37
Original line number Diff line number Diff line
@@ -170,42 +170,8 @@ If linux, run instead the following command:
Make the Debug binaries:
    make


Fine-tune Build Process
-----------------------
These should be set from command line:

One of these 2 option *must* be set to ON:
  KICAD_STABLE_VERSION or KICAD_TESTING_VERSION
    ** KICAD_STABLE_VERSION:
    set this option to ON to build the stable version of KICAD. mainly used to set version ID
    Usually set for kicad version downloaded from stable branch

    ** KICAD_TESTING_VERSION
    set this option to ON to build the stable version of KICAD. mainly used to set version ID
    Usually set for kicad version downloaded from testing branch

 CMAKE_BUILD_TYPE Release/Debug (REQUIRED)
   Choose build type: Release/Debug.

 wxWidgets_USE_STATIC ON/OFF (OPTIONAL)

 CMAKE_VERBOSE_MAKEFILE ON/OFF (OPTIONAL)
   Turns ON/OFF verbose build messages.
   You can also pass VERBOSE=1 to make for the same effect.

 CMAKE_INSTALL_PREFIX (OPTIONAL)

 USE_WX_GRAPHICS_CONTEXT ON/OFF (OPTIONAL)
   *Experimental* advanced drawing library code using wxGraphicsContext (for tests only).
   Under Windows, a very recent version of mingw is needed.
   It requires wxWidgets to be built with the --enable-graphics_ctx switch.
   See building wxWidgets above.

 USE_IMAGES_IN_MENUS ON/OFF (OPTIONAL)
   Force building Kicad with or without images in menu items.  If this is not defined on
   when CMake is used to create the build files, images will be included in menu items
   on all platforms except OSX.

Note: that it is easy to build only a specific binary such as pcbnew alone:
    make pcbnew


See ./cmake_config.txt for customizing the KiCad build setting.
+144 −0
Original line number Diff line number Diff line
KiCad uses CMake to generate the build files specific for the target platform
specified by the developer.  This document attempts to define some of the more
common CMake and KiCad build configuration settings.  You can use CMake either
by the command CMake on or the graphical version ccmake.  This document only
documents a very small subset of the total CMake documentation  For all of the
gory details, please see the complete CMake documentation at:

http://www.cmake.org/cmake/help/documentation.html.


Useful CMake Build Settings.
----------------------------
This section defines some of the more common CMake build configuration setting
used when configuring KiCad.  These settings are valid for all projects that
use CMake.

Changing the Build Generator.
-----------------------------
CMake attempts to create the project build system based on the platform.  On
Posix systems CMake will create Unix Makefiles to build KiCad.  On Windows
systems CMake will attempt to find the latest version of Visual C++ installed
on the system and create the appropriate project files.  This behavior can be
changed by specifying the project generator using the -G "Project Generator"
switch on the command line.  Please note, only a small subset of these project
generators are supported.  If you want to use Eclipse on Linux to build KiCad,
you may be in for a lot of work.

CMAKE_BUILD_TYPE (Release/Debug/RelWithDebInfo/MinSizeRel)
----------------------------------------------------------
When configuring the KiCad build for the command line you must specify build
type.  To create a debug build, set CMAKE_BUILD_TYPE to Debug.  To create a
release build, set CMAKE_BUILD_TYPE to Release.  See the CMake documentation
for other build types.  For IDE project files, the build type can be selected
by the IDE configuration manager.

CMAKE_INSTALL_PATH (InstallPath)
--------------------------------
By default CMake will select the correct install path for your platform.  If
you wish to install KiCad in a custom location, set CMAKE_INSTALL_PATH to the
path where you want to install KiCad.  Please note that the default install
path that CMake chooses will likely overwrite the current version of KiCad
installed on your system.


wxWidgets Library Configuration.
--------------------------------
KiCad is built using the wxWidgets library.  The following options allow you
to specifically tailor the wxWidgets library configuration.  For the complete
list of wxWidgets setting see CMakeModules/FindwxWidgets.cmake in the KiCad
source.

wxWidgets_ROOT_DIR (NonDefaultwxWidgetsPath)
--------------------------------------------
CMake looks in the standard platform locations to find the default version of
the wxWidgets library.  If you wish to use a custom built wxWidgets library,
set wxWidgets_ROOT_DIR to the correct path.

wxWidgets_USE_DEBUG (ON/OFF)
----------------------------
When creating a debug build of KiCad, it is often useful to link against the
debug build of the wxWidgets.  To use the debug build of wxWidgets, set
wxWidgets_USE_DEBUG to ON.

wxWidgets_USE_UNICODE (ON/OFF)
------------------------------
If you platform supports Unicode and you wish to build KiCad with Unicode
support, set wxWidgets_USE_UNICODE to ON.  Please note as of the 2.9 branch
this option is not required.


KiCad Specific Options
----------------------
All of the configuration settings below are specific to the KiCad project.
If for any reason you add or remove a build option to the KiCad CMake files,
please update the list below.

KICAD_STABLE_VERSION (ON/OFF)
-----------------------------
This option enables or disables the stable version string to be created and
used when building KiCad.  It is mutually exclusive with KICAD_TESTING_VERSION.

KICAD_TESTING_VERSION (ON/OFF)
------------------------------
This option enables or disables the testing version string to be created and
used when building KiCad.  It is mutually exclusive with KICAD_STABLE_VERSION.

USE_WX_GRAPHICS_CONTEXT (ON/OFF)
--------------------------------
This option is *Experimental* and used the advanced drawing library code
using wxGraphicsContext and should only be used for testing purposes.
Under Windows, a very recent version of mingw is needed.  It also requires
wxWidgets to be built with the --enable-graphics_ctx configuration switch.

USE_IMAGES_IN_MENUS (ON/OFF)
----------------------------
This option is used to enable or disable building KiCad with images in menu
items.  If this is not defined when CMake is used to create the build files,
images will be included in menu items on all platforms except OSX.

USE_PCBNEW_NANOMETRES (ON/OFF)
This option is used to enable or disable the nano-meter internal units for
Pcbnew.  The default is ON.

KICAD_GOST (ON/OFF)
-------------------
This option is used to enable or disable the GOST notation for multiple gates
per package in Eeschema.  The default is  OFF

KICAD_KEEPCASE (ON/OFF)
-----------------------
This option enables or disables turning off the  automatic component name
conversion to uppercase.  The default is OFF which means component names will
be converted to upper case.

USE_WX_OVERLAY (ON/OFF)
-----------------------
This option enables or disables wxOverlay for drawing operation on OSX.  It is
OFF by default on all platforms except OSX.  Warning, this is experimental!

KICAD_SCRIPTING (ON/OFF)
------------------------
This option enables or disables building Python scripting support for KiCad.
The default is OFF.  Currently only Pcbnew is supported.  This option requires
that SWIG and Python are installed on the system.

KICAD_SCRIPTING_MODULES (ON/OFF)
--------------------------------
This option enables or disables building the KiCad modules that can be used
from scripting languages.  The default is OFF.  Currently only Pcbnew is
supported.  This option requires that SWIG and Python are installed on the
system.

KICAD_SCRIPTING_WXPYTHON (ON/OFF)
---------------------------------
This option enables or disables building wxPython support into KiCad for
python and py.shell.    The default is OFF.  Currently only Pcbnew is
supported.  This option requires that SWIG, Python, and wxPython are
installed on the system.

PYTHON_SITE_PACKAGE_PATH (PATH)
-------------------------------
When building KiCad with Python scripting enable, the Python site library path
is used by default.  If you want to install the KiCad Python extension in a
different path, set this variable to the desired path.
Loading