Commit 0be39929 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

Lay basis for a more full featured usage of boost, including compiled...

Lay basis for a more full featured usage of boost, including compiled libraries such as unit_test_framework, system, etc.  Move headers now into boost_root/include/boost/.
parent e04860d6
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
include/boost
boost_root
.downloads-by-cmake
.downloads-by-cmake
common/netlist_keywords.*
common/netlist_keywords.*
common/netlist_lexer.h
common/netlist_lexer.h
+0 −1
Original line number Original line Diff line number Diff line
@@ -2,7 +2,6 @@ add_definitions(-DPCBNEW)


include_directories(BEFORE ${INC_BEFORE})
include_directories(BEFORE ${INC_BEFORE})
include_directories(
include_directories(
    ${Boost_INCLUDE_DIR}
    ../pcbnew
    ../pcbnew
    ../polygon
    ../polygon
    ${INC_AFTER}
    ${INC_AFTER}
+208 −192
Original line number Original line Diff line number Diff line
@@ -53,11 +53,14 @@ option(KICAD_SCRIPTING_WXPYTHON


option( USE_FP_LIB_TABLE "Use the new footprint library table implementation. ( default OFF)" )
option( USE_FP_LIB_TABLE "Use the new footprint library table implementation. ( default OFF)" )


#option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF )


#Set version option (stable or testing)
#Set version option (stable or testing)


if( KICAD_STABLE_VERSION)
if( KICAD_STABLE_VERSION)
    add_definitions( -DKICAD_STABLE_VERSION )
    add_definitions( -DKICAD_STABLE_VERSION )
    message( "Building stable version of KiCad")
    message( STATUS "Building stable version of KiCad" )
endif()
endif()


# All CMake downloads go here.  Suggested is up in the source tree, not in the build dir where they
# All CMake downloads go here.  Suggested is up in the source tree, not in the build dir where they
@@ -248,9 +251,8 @@ include(CheckFindPackageResult)
find_package( OpenGL QUIET )
find_package( OpenGL QUIET )
check_find_package_result( OPENGL_FOUND "OpenGL" )
check_find_package_result( OPENGL_FOUND "OpenGL" )


##########################
# Download boost and possibly build parts of it
# Download Boost library #
#################################################
##########################
include( download_boost )
include( download_boost )




@@ -286,6 +288,27 @@ if(MINGW AND USE_WX_GRAPHICS_CONTEXT)
    check_find_package_result( GDI_PLUS_FOUND "GDI+" )
    check_find_package_result( GDI_PLUS_FOUND "GDI+" )
endif()
endif()


# Assist with header file searching optimization:
# INC_BEFORE and INC_AFTER are two lists which go at the front and back of the
# header file search lists, respectively.
# INC_BEFORE is for use with "include_directories( BEFORE ...)", which _reverses_
# the order during insertion.  (So put first wanted last, which is
# ${CMAKE_SOURCE_DIR/include.)  Use '.' for current source dir since
# we don't want expansion here and now, which would happen if using ${CMAKE_CURRENT_SOURCE_DIR}.
# Instead we use '.' which is applicable to any source directory below here as a result of
# this lack of expansion.
set( INC_BEFORE
    .
    ${CMAKE_SOURCE_DIR}/include
    )

set( INC_AFTER
    ${Boost_INCLUDE_DIR}
    #include <config.h>
    ${CMAKE_BINARY_DIR}
    )


# Find Python and other scripting resources
# Find Python and other scripting resources
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
    set( PythonInterp_FIND_VERSION )
    set( PythonInterp_FIND_VERSION )
@@ -308,11 +331,19 @@ if(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
    set( PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}" CACHE PATH "Python module install path." )
    set( PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}" CACHE PATH "Python module install path." )
    mark_as_advanced( PYTHON_DEST )
    mark_as_advanced( PYTHON_DEST )
    message( STATUS "Python module install path: ${PYTHON_DEST}" )
    message( STATUS "Python module install path: ${PYTHON_DEST}" )

    find_package( PythonLibs )
    find_package( PythonLibs )
    include_directories(${PYTHON_INCLUDE_DIRS}
                        ./scripting)
endif(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)


    #message( STATUS "PYTHON_INCLUDE_DIRS:${PYTHON_INCLUDE_DIRS}" )

    # Infrequently needed headers go at end of search paths, append to INC_AFTER which
    # although is used for all components, should be a harmless hit for something like eeschema
    # so long as unused search paths are at the end like this.
    set( INC_AFTER ${INC_AFTER} ${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/scripting )

    #message( STATUS "/ INC_AFTER:${INC_AFTER}" )

endif()




# Automagically create version header file.
# Automagically create version header file.
@@ -327,20 +358,6 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/include/config.h)
    add_definitions( -DHAVE_SVN_REVISION )
    add_definitions( -DHAVE_SVN_REVISION )
endif()
endif()


# For include_directories(BEFORE ...), which _reverses_
# the order during insertion, so put first wanted last, which is
# ${CMAKE_SOURCE_DIR/include.  Use '.' for current source dir since
# we don't want expansion here and now, and don't need expansion of
# ${CMAKE_CURRENT_SOURCE_DIR}, '.' will work for any source directory.
set(INC_BEFORE
    .
    ${CMAKE_SOURCE_DIR}/include
    )

set(INC_AFTER
    #include <config.h>
    ${CMAKE_BINARY_DIR}
    )


#================================================
#================================================
# Let CMake look in these directories for nested
# Let CMake look in these directories for nested
@@ -359,7 +376,6 @@ add_subdirectory(eeschema)
add_subdirectory( gerbview )
add_subdirectory( gerbview )
add_subdirectory( kicad )
add_subdirectory( kicad )
add_subdirectory( pcbnew )
add_subdirectory( pcbnew )
add_subdirectory(pcbnew/pcad2kicadpcb_plugin)
add_subdirectory( polygon )
add_subdirectory( polygon )
add_subdirectory( pagelayout_editor )
add_subdirectory( pagelayout_editor )
add_subdirectory( potrace )
add_subdirectory( potrace )
@@ -370,7 +386,7 @@ add_subdirectory(tools)




# Make all libs and executables depend on ExternalProject_Add( boost ),
# Make all libs and executables depend on ExternalProject_Add( boost ),
# except perhaps bitmap lib
# except perhaps bitmap lib.  This allows a multi-threaded build to succeed.
add_dependencies( pcbnew boost )
add_dependencies( pcbnew boost )
add_dependencies( eeschema boost )
add_dependencies( eeschema boost )
add_dependencies( cvpcb boost )
add_dependencies( cvpcb boost )
+4 −0
Original line number Original line Diff line number Diff line
@@ -81,4 +81,8 @@
/// Definition to compile with Pcbnew footprint library table implementation.
/// Definition to compile with Pcbnew footprint library table implementation.
#cmakedefine USE_FP_LIB_TABLE
#cmakedefine USE_FP_LIB_TABLE


/// When defined, build the GITHUB_PLUGIN for pcbnew.
#cmakedefine BUILD_GITHUB_PLUGIN


#endif  // CONFIG_H_
#endif  // CONFIG_H_
+123 −20
Original line number Original line Diff line number Diff line
@@ -22,12 +22,39 @@






# Download and patch boost headers to a particular version.
# 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.
# 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.53.0 )
set( BOOST_RELEASE 1.53.0 )
set( BOOST_MD5 a00d22605d5dbcfb4c9936a9b35bc4c2 )   # re-calc this on every RELEASE change
set( BOOST_MD5 a00d22605d5dbcfb4c9936a9b35bc4c2 )   # 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" )


if( BUILD_GITHUB_PLUGIN )
    # Space separated list which indicates the subset of boost libraries to compile.
    set( BOOST_LIBS_BUILT
        filesystem
        system
        regex
        program_options
        date_time
        thread
        exception
        unit_test_framework
        )
endif()

#-----</configure>---------------------------------------------------------------



string( REGEX REPLACE "\\." "_" BOOST_VERS "${BOOST_RELEASE}" )
string( REGEX REPLACE "\\." "_" BOOST_VERS "${BOOST_RELEASE}" )
set( PREFIX ${DOWNLOAD_DIR}/boost_${BOOST_VERS} )
set( PREFIX ${DOWNLOAD_DIR}/boost_${BOOST_VERS} )


@@ -36,27 +63,102 @@ set( PREFIX ${DOWNLOAD_DIR}/boost_${BOOST_VERS} )
# download, the patch is applied.  This lets you regenerate a new patch at any time
# 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.
# easily, simply by editing the working tree in <SOURCE_DIR> and doing "bzr diff" in there.


# include only the headers in the repo.
# path to the boost headers in the repo.
# repo = "${headers}/../.bzr" = "<SOURCE_DIR>/.bzr"
# repo = "${headers_src}/../.bzr" = "<SOURCE_DIR>/.bzr"
set( headers ${PREFIX}/src/boost/boost )
set( headers_src "${PREFIX}/src/boost/boost" )


# don't look at this:
function( set_boost_lib_names libs )
    foreach( lib IN LISTS ${libs} )
        string( TOUPPER ${lib} LIB )
        message( STATUS "LIB:${LIB} lib:${lib}" )
        set( Boost_${LIB}_LIBRARY, "${BOOST_ROOT}/lib/libboost_${lib}.a" PARENT_SCOPE )
        set( Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${LIB}_LIBRARY} PARENT_SCOPE )
    endforeach()
endfunction()


if( BUILD_GITHUB_PLUGIN )

    message( FATAL_ERROR
        "BUILD_GITHUB_PLUGIN not functional. With this commit we get merely a greenfield for better boost usage and building."
        )

    # (BTW "test" yields "unit_test_framework" when passed to bootstrap.{sh,bat} ).
    message( STATUS "BOOST_LIBS_BUILT:${BOOST_LIBS_BUILT}" )
    string( REPLACE "unit_test_framework" "test" libs_csv "${BOOST_LIBS_BUILT}" )
    message( STATUS "REPLACE libs_csv:${libs_csv}" )

    string( REGEX REPLACE "\\;" "," libs_csv "${libs_csv}" )
    message( STATUS "libs_csv:${libs_csv}" )

    if( MINGW )
        set( bootstrap "bootstart.bat mingw" )
    else()
        set( bootstrap bootstrap.sh )
    endif()

    ExternalProject_Add( boost
        PREFIX          "${PREFIX}"
        DOWNLOAD_DIR    "${DOWNLOAD_DIR}"
        URL             http://downloads.sourceforge.net/project/boost/boost/${BOOST_RELEASE}/boost_${BOOST_VERS}.tar.bz2
        URL_MD5         ${BOOST_MD5}

        # The patch command executes with the working directory set to <SOURCE_DIR>
        PATCH_COMMAND   bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/boost.patch"

        # [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}
                        --with-libraries=${libs_csv}

        BUILD_COMMAND   b2
                        variant=release
                        threading=multi
                        toolset=gcc
                        link=static
                        --prefix=${BOOST_ROOT}
                        install

        INSTALL_COMMAND ""
        )


else( BUILD_GITHUB_PLUGIN )




    ExternalProject_Add( boost
    ExternalProject_Add( boost
    PREFIX          ${PREFIX}
        PREFIX          "${PREFIX}"
    DOWNLOAD_DIR    ${DOWNLOAD_DIR}
        DOWNLOAD_DIR    "${DOWNLOAD_DIR}"
        URL             http://downloads.sourceforge.net/project/boost/boost/${BOOST_RELEASE}/boost_${BOOST_VERS}.tar.bz2
        URL             http://downloads.sourceforge.net/project/boost/boost/${BOOST_RELEASE}/boost_${BOOST_VERS}.tar.bz2
        URL_MD5         ${BOOST_MD5}
        URL_MD5         ${BOOST_MD5}


        # The patch command executes with the working directory set to <SOURCE_DIR>
        # The patch command executes with the working directory set to <SOURCE_DIR>
    PATCH_COMMAND   bzr patch -p0 ${PROJECT_SOURCE_DIR}/patches/boost.patch
        PATCH_COMMAND   bzr patch -p0 "${PROJECT_SOURCE_DIR}/patches/boost.patch"

        # Dick 18-Aug-2013:
        # [mis-]use this UPDATE_COMMAND opportunity to remove the old place of boost headers.
        # Can eventually remove this step after headers are moved from <kicad_src>/include/boost
        # to <kicad_src>/boost_root/include/boost over the next several months.
        UPDATE_COMMAND  ${CMAKE_COMMAND} -E remove_directory "${PROJECT_SOURCE_DIR}/include/boost"


        CONFIGURE_COMMAND ""
        CONFIGURE_COMMAND ""


        # remove then re-copy into the include/boost directory during next two steps:
        # remove then re-copy into the include/boost directory during next two steps:
    BUILD_COMMAND   ${CMAKE_COMMAND} -E remove_directory ${PROJECT_SOURCE_DIR}/include/boost
        BUILD_COMMAND   ${CMAKE_COMMAND} -E remove_directory ${BOOST_ROOT}
    INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory ${headers} ${PROJECT_SOURCE_DIR}/include/boost
        INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory "${headers_src}" "${BOOST_ROOT}/include/boost"
        )
        )


    # Until my find_package() support is done for my boost.
    set( Boost_INCLUDE_DIR  "${BOOST_ROOT}/include" CACHE FILEPATH "Boost library directory" )


endif( BUILD_GITHUB_PLUGIN )



ExternalProject_Add_Step( boost bzr_commit_boost
ExternalProject_Add_Step( boost bzr_commit_boost
    COMMAND bzr ci -q -m pristine <SOURCE_DIR>
    COMMAND bzr ci -q -m pristine <SOURCE_DIR>
@@ -66,8 +168,8 @@ ExternalProject_Add_Step( boost bzr_commit_boost




ExternalProject_Add_Step( boost bzr_add_boost
ExternalProject_Add_Step( boost bzr_add_boost
    # add only the headers to the scratch repo, repo = "../.bzr" from ${headers}
    # add only the headers to the scratch repo, repo = "../.bzr" from ${headers_src}
    COMMAND bzr add -q ${headers}
    COMMAND bzr add -q ${headers_src}
    COMMENT "adding pristine boost files to 'boost scratch repo'"
    COMMENT "adding pristine boost files to 'boost scratch repo'"
    DEPENDERS bzr_commit_boost
    DEPENDERS bzr_commit_boost
    )
    )
@@ -79,3 +181,4 @@ ExternalProject_Add_Step( boost bzr_init_boost
    DEPENDERS bzr_add_boost
    DEPENDERS bzr_add_boost
    DEPENDEES download
    DEPENDEES download
    )
    )
Loading