From edfb5811cf8b94398aa63d834f6980c1966955af Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Fri, 31 May 2013 16:22:34 -0500 Subject: [PATCH] *) Refinements to ExternalProject_Add( boost ) *) Enhancements to make_lexer(). *) Support multi-threaded build. *) Switch to "bzr patch" from patch.exe for Windows users. --- CMakeLists.txt | 28 ++++++++++++-------- CMakeModules/Functions.cmake | 14 +++++++++- CMakeModules/download_boost.cmake | 28 +++++++++----------- bitmaps_png/CMakeLists.txt | 1 - common/CMakeLists.txt | 32 +++++++++++++++-------- eeschema/CMakeLists.txt | 3 +++ include/kicad_msvc.h | 43 ------------------------------- pcb_calculator/CMakeLists.txt | 11 +++++--- pcbnew/CMakeLists.txt | 3 +++ 9 files changed, 76 insertions(+), 87 deletions(-) delete mode 100644 include/kicad_msvc.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a9d8b4a101..06c4de74c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,7 @@ project(kicad) -# The minimum CMake version requirement could be different under unix, OSX, or Windows -if(WIN32) - cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) # win32 and win64 -elseif(APPLE) - cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) # OSX -else() - cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR) # Linux, Unix, and everything else. -endif() +cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR) +# because of http://public.kitware.com/Bug/view.php?id=10395 # Path to local CMake modules. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) @@ -359,9 +353,9 @@ set(INC_AFTER # 'CMakeLists.txt' files to process #================================================ -############ -# Binaries # -############ +############################ +# Binaries (CMake targets) # +############################ add_subdirectory(bitmaps_png) add_subdirectory(common) @@ -380,6 +374,18 @@ add_subdirectory(tools) #add_subdirectory(new) +# Make all libs and executables depend on ExternalProject_Add( boost ), +# except perhaps bitmap lib +add_dependencies( pcbnew boost ) +add_dependencies( eeschema boost ) +add_dependencies( cvpcb boost ) +add_dependencies( common boost ) +add_dependencies( pcbcommon boost ) +add_dependencies( 3d-viewer boost ) +add_dependencies( pcad2kicadpcb boost ) +add_dependencies( polygon boost ) + + ############# # Resources # ############# diff --git a/CMakeModules/Functions.cmake b/CMakeModules/Functions.cmake index ee5750651c..3d9ec9d21b 100644 --- a/CMakeModules/Functions.cmake +++ b/CMakeModules/Functions.cmake @@ -23,7 +23,10 @@ # Function make_lexer -# is a standard way to invoke TokenList2DsnLexer.cmake +# 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} @@ -41,5 +44,14 @@ function( make_lexer inputFile outHeaderFile outCppFile enum ) ${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() diff --git a/CMakeModules/download_boost.cmake b/CMakeModules/download_boost.cmake index c206b079ca..3a2fcc00e3 100644 --- a/CMakeModules/download_boost.cmake +++ b/CMakeModules/download_boost.cmake @@ -3,49 +3,46 @@ # Assumes include( ExternalProject ) was done inline previous to this file. set( BOOST_RELEASE 1.53.0 ) -string( REGEX REPLACE "\\." "_" BOOST_VERS "${BOOST_RELEASE}" ) - set( BOOST_MD5 a00d22605d5dbcfb4c9936a9b35bc4c2 ) # re-calc this on every RELEASE change + +string( REGEX REPLACE "\\." "_" BOOST_VERS "${BOOST_RELEASE}" ) set( PREFIX ${DOWNLOAD_DIR}/boost_${BOOST_VERS} ) -ExternalProject_Add( - boost +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} - - #UPDATE_COMMAND + 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 - PATCH_COMMAND patch -p0 < ${PROJECT_SOURCE_DIR}/patches/boost.patch + PATCH_COMMAND bzr patch -p0 ${PROJECT_SOURCE_DIR}/patches/boost.patch CONFIGURE_COMMAND "" # 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 ${PROJECT_SOURCE_DIR}/include/boost INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory /boost ${PROJECT_SOURCE_DIR}/include/boost ) -# = ${PREFIX}/src/ +# = ${PREFIX}/src/boost # Add extra steps, so that we can easily regenerate any boost patch needed for the above. # There is a Bazaar 'boost scratch repo' in and after committing pristine # download, the patch is applied. This lets you regenerate a new patch at any time -# easily, simply by editing the copy in and doing "bzr diff" in there. +# easily, simply by editing the working tree in and doing "bzr diff" in there. ExternalProject_Add_Step( boost bzr_commit_boost COMMAND bzr ci -q -m pristine - COMMENT "committing boost files to 'boost scratch repo'" + COMMENT "committing pristine boost files to 'boost scratch repo'" DEPENDERS patch ) ExternalProject_Add_Step( boost bzr_add_boost COMMAND bzr add -q - COMMENT "adding boost files to 'boost scratch repo'" + COMMENT "adding pristine boost files to 'boost scratch repo'" DEPENDERS bzr_commit_boost ) @@ -53,7 +50,6 @@ ExternalProject_Add_Step( boost bzr_add_boost ExternalProject_Add_Step( boost bzr_init_boost COMMAND bzr init -q COMMENT "creating 'boost scratch repo' specifically for boost to track boost patches" - DEPENDERS bzr_commit_boost + DEPENDERS bzr_add_boost DEPENDEES download ) - diff --git a/bitmaps_png/CMakeLists.txt b/bitmaps_png/CMakeLists.txt index 045bc1e8d0..e918e67e6d 100644 --- a/bitmaps_png/CMakeLists.txt +++ b/bitmaps_png/CMakeLists.txt @@ -752,4 +752,3 @@ endforeach() #add_library( bitmaps SHARED ${CPP_LIST} ) add_library( bitmaps STATIC ${CPP_LIST} ) - diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 93b8884a8d..1e5a24dcdf 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -150,13 +150,15 @@ set_source_files_properties( ${PCB_COMMON_SRCS} PROPERTIES add_library(pcbcommon STATIC ${PCB_COMMON_SRCS}) - # auto-generate netlist_lexer.h and netlist_keywords.cpp make_lexer( ${CMAKE_CURRENT_SOURCE_DIR}/netlist.keywords ${PROJECT_SOURCE_DIR}/include/netlist_lexer.h ${CMAKE_CURRENT_SOURCE_DIR}/netlist_keywords.cpp NL_T + + # Pass header file with dependency on *_lexer.h as extra_arg + ${CMAKE_PROJECT_SOURCE_DIR}/pcbnew/netlist_reader.h ) # auto-generate pcb_plot_params_lexer.h and pcb_plot_params_keywords.cpp @@ -165,21 +167,29 @@ make_lexer( ${PROJECT_SOURCE_DIR}/include/pcb_plot_params_lexer.h ${CMAKE_CURRENT_SOURCE_DIR}/pcb_plot_params_keywords.cpp PCBPLOTPARAMS_T + + # Pass header file with dependency on *_lexer.h as extra_arg + ${PROJECT_SOURCE_DIR}/pcbnew/pcb_plot_params.h ) # auto-generate pcbnew_sexpr.h and pcbnew_sexpr.cpp -make_lexer( ${CMAKE_CURRENT_SOURCE_DIR}/pcb.keywords - ${PROJECT_SOURCE_DIR}/include/pcb_lexer.h - ${CMAKE_CURRENT_SOURCE_DIR}/pcb_keywords.cpp - PCB_KEYS_T - ) +make_lexer( + ${CMAKE_CURRENT_SOURCE_DIR}/pcb.keywords + ${PROJECT_SOURCE_DIR}/include/pcb_lexer.h + ${CMAKE_CURRENT_SOURCE_DIR}/pcb_keywords.cpp + PCB_KEYS_T + + # Pass header file with dependency on *_lexer.h as extra_arg + ${PROJECT_SOURCE_DIR}/pcbnew/pcb_parser.h + ) # auto-generate pcbnew s-expression footprint library table code. -make_lexer( ${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table.keywords - ${PROJECT_SOURCE_DIR}/include/fp_lib_table_lexer.h - ${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table_keywords.cpp - FP_LIB_TABLE_T - ) +make_lexer( + ${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table.keywords + ${PROJECT_SOURCE_DIR}/include/fp_lib_table_lexer.h + ${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table_keywords.cpp + FP_LIB_TABLE_T + ) # The dsntest may not build properly using MS Visual Studio. if(NOT MSVC) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 6e1af9d9a4..40738f9762 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -198,6 +198,9 @@ make_lexer( ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_lexer.h ${CMAKE_CURRENT_SOURCE_DIR}/template_fieldnames_keywords.cpp TFIELD_T + + # Pass header file with dependency on *_lexer.h as extra_arg + template_fieldnames.h ) add_executable(eeschema WIN32 MACOSX_BUNDLE diff --git a/include/kicad_msvc.h b/include/kicad_msvc.h deleted file mode 100644 index 8dbfc1fba7..0000000000 --- a/include/kicad_msvc.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * @file kicad_msvc.h - * @brief Code used to compile KiCad with Microsoft Visual C++ - */ - -// __MSVC__ must be defined - -// -// there are several issues -// 1 - the EXCHG macro uses the typeof keyword, this is unsupported in MSVC -// 2 - there is no round function in the msvc math library -// see ReadMe-MSVC. txt to view list of all changes to sources -// -#ifndef __KICAD_MSVC_ INC__ -#define __KICAD_MSVC_ INC__ - -#ifdef __MSVC__ -// the boost libs have a workaround for the typeof problem -#ifdef _MSC_VER - #if ( _MSC_VER <= 1310 ) // 6.5 7.0 and 7.1 use the msvc bug - #include - #else // 8.0 or greater - #include - // we have to register the types used with the typeof keyword with boost - BOOST_TYPEOF_REGISTER_TYPE(wxPoint) ; - BOOST_TYPEOF_REGISTER_TYPE(wxSize) ; - BOOST_TYPEOF_REGISTER_TYPE(wxString) ; - class DrawSheetLabelStruct; - BOOST_TYPEOF_REGISTER_TYPE(DrawSheetLabelStruct *); - class EDA_ITEM; - BOOST_TYPEOF_REGISTER_TYPE(EDA_ITEM *); - class D_PAD; - BOOST_TYPEOF_REGISTER_TYPE(D_PAD *); - BOOST_TYPEOF_REGISTER_TYPE(const D_PAD *); - class BOARD_ITEM; - BOOST_TYPEOF_REGISTER_TYPE(BOARD_ITEM *); - #endif // _MSC_VER <= 1310 - #define typeof(expr) BOOST_TYPEOF(expr) -#endif // def _MSC_VER - -#endif // def __MSVC__ - -#endif // ndef __KICAD_MSVC_ INC__ diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt index 30d44beba3..4bbd5be02d 100644 --- a/pcb_calculator/CMakeLists.txt +++ b/pcb_calculator/CMakeLists.txt @@ -60,10 +60,13 @@ endif(APPLE) # auto-generate pcb_calculator_datafile.h and pcb_calculator_datafile_keywords.cpp # for the storage data file format. make_lexer( - ${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator_datafile.keywords - ${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator_datafile_lexer.h - ${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator_datafile_keywords.cpp - PCBCALC_DATA_T + ${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator_datafile.keywords + ${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator_datafile_lexer.h + ${CMAKE_CURRENT_SOURCE_DIR}/pcb_calculator_datafile_keywords.cpp + PCBCALC_DATA_T + + # Pass header file with dependency on *_lexer.h as extra_arg + datafile_read_write.h ) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 1c6bf153e4..273c87db21 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -385,6 +385,9 @@ make_lexer( ${CMAKE_CURRENT_SOURCE_DIR}/specctra_lexer.h ${CMAKE_CURRENT_SOURCE_DIR}/specctra_keywords.cpp DSN + + # Pass header file with dependency on *_lexer.h as extra_arg + specctra.h )