You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

696 lines
24 KiB

18 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
18 years ago
18 years ago
Introduction of Graphics Abstraction Layer based rendering for pcbnew. New classes: - VIEW - represents view that is seen by user, takes care of layer ordering & visibility and how it is displayed (which location, how much zoomed, etc.) - VIEW_ITEM - Base class for every item that can be displayed on VIEW (the biggest change is that now it may be necessary to override ViewBBox & ViewGetLayers method for derived classes). - EDA_DRAW_PANEL_GAL - Inherits after EDA_DRAW_PANEL, displays VIEW output, right now it is not editable (in opposite to usual EDA_DRAW_PANEL). - GAL/OPENGL_GAL/CAIRO_GAL - Base Graphics Abstraction Layer class + two different flavours (Cairo is not fully supported yet), that offers methods to draw primitives using different libraries. - WX_VIEW_CONTROLS - Controller for VIEW, handles user events, allows zooming, panning, etc. - PAINTER/PCB_PAINTER - Classes that uses GAL interface to draw items (as you may have already guessed - PCB_PAINTER is a class for drawing PCB specific object, PAINTER is an abstract class). Its methods are invoked by VIEW, when an item has to be drawn. To display a new type of item - you need to implement draw(ITEM_TYPE*) method that draws it using GAL methods. - STROKE_FONT - Implements stroke font drawing using GAL methods. Most important changes to Kicad original code: * EDA_ITEM now inherits from VIEW_ITEM, which is a base class for all drawable objects. * EDA_DRAW_FRAME contains both usual EDA_DRAW_PANEL and new EDA_DRAW_PANEL_GAL, that can be switched anytime. * There are some new layers for displaying multilayer pads, vias & pads holes (these are not shown yet on the right sidebar in pcbnew) * Display order of layers is different than in previous versions (if you are curious - you may check m_galLayerOrder@pcbnew/basepcbframe.cpp). Preserving usual order would result in not very natural display, such as showing silkscreen texts on the bottom. * Introduced new hotkey (Alt+F12) and new menu option (View->Switch canvas) for switching canvas during runtime. * Some of classes (mostly derived from BOARD_ITEM) now includes ViewBBox & ViewGetLayers methods. * Removed tools/class_painter.h, as now it is extended and included in source code. Build changes: * GAL-based rendering option is turned on by a new compilation CMake option KICAD_GAL. * When compiling with CMake option KICAD_GAL=ON, GLEW and Cairo libraries are required. * GAL-related code is compiled into a static library (common/libgal). * Build with KICAD_GAL=OFF should not need any new libraries and should come out as a standard version of Kicad Currently most of items in pcbnew can be displayed using OpenGL (to be done are DIMENSIONS and MARKERS). More details about GAL can be found in: http://www.ohwr.org/attachments/1884/view-spec.pdf
13 years ago
12 years ago
  1. # Default to CMAKE_BUILD_TYPE = Release unless overridden on command line
  2. # http://www.cmake.org/pipermail/cmake/2008-September/023808.html
  3. if( DEFINED CMAKE_BUILD_TYPE )
  4. set( CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Set to either \"Release\" or \"Debug\"" )
  5. else()
  6. set( CMAKE_BUILD_TYPE Release CACHE STRING "Set to either \"Release\" or \"Debug\"" )
  7. endif()
  8. project( kicad )
  9. cmake_minimum_required( VERSION 2.8.4 FATAL_ERROR )
  10. # because of http://public.kitware.com/Bug/view.php?id=10395
  11. # Path to local CMake modules.
  12. set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
  13. #
  14. # KiCad build options should be added below.
  15. #
  16. # If you add a new build option, please add it's state to the CopyVersionInfoToClipboard()
  17. # function in common/basicframe.cpp so that build option settings can be included in bug
  18. # reports.
  19. #
  20. option( USE_KIWAY_DLLS
  21. "Build the major modules as KIFACE DLLs or DSOs, will soon be the norm." OFF )
  22. # The desire is to migrate designs *away from* case independence, and to create designs which use
  23. # literally (case specific) interpreted component names. But for backwards compatibility,
  24. # you may turn OFF this option if you really must. (Remember that with KiCad using text
  25. # data files, typically you would be better off simply doctoring those files into
  26. # a case literal state with a text editor and move forward into the brave new
  27. # world of case specificity. Also, BOM generators may not work properly when you
  28. # have this option turned OFF, the xml export's referential integrity is broken
  29. # on library part name. Hence the default is ON now, as of 29-Jan-2014.
  30. option( KICAD_KEEPCASE
  31. "ON= case specific string matching on component names, OFF= match names as if they were spelt using uppercase."
  32. ON
  33. )
  34. option( USE_WX_GRAPHICS_CONTEXT
  35. "Use wxGraphicsContext for rendering ( default OFF). Warning, this is experimental" )
  36. option( USE_WX_OVERLAY
  37. "Use wxOverlay: Always ON for MAC ( default OFF). Warning, this is experimental" )
  38. option( KICAD_SCRIPTING
  39. "set this option ON to build the scripting support inside kicad binaries"
  40. )
  41. option( KICAD_SCRIPTING_MODULES
  42. "set this option ON to build kicad modules that can be used from scripting languages"
  43. )
  44. option( KICAD_SCRIPTING_WXPYTHON
  45. "set this option ON to build wxpython implementation for wx interface building in python and py.shell"
  46. )
  47. option( KICAD_BUILD_STATIC
  48. "Builds Kicad and all libraries static (except wx-widgets)"
  49. )
  50. # WARNING: KiCad developers strongly advise you to build Boost with supplied patches,
  51. # as it is known to work with KiCad. Other versions may contain bugs that may result
  52. # in KiCad errors.
  53. option( KICAD_SKIP_BOOST
  54. "Skip building downloaded Boost library components, use Boost from your system."
  55. )
  56. mark_as_advanced( KICAD_SKIP_BOOST ) # Normal builders should build Boost.
  57. # when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
  58. # PYTHON_EXECUTABLE can be defined when invoking cmake
  59. # ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
  60. # when not defined by user, the default is python.exe under Windows and python2 for others
  61. # python binary file should be is exec path.
  62. option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF )
  63. # This can be set to a custom name to brag about a particular branch in the "About" dialog:
  64. set( KICAD_REPO_NAME "product" CACHE STRING "Name of the tree from which this build came." )
  65. # All CMake downloads go here. Suggested is up in the source tree, not in the build dir where they
  66. # would have to be downloaded over and over again. The default is to choose a directory that is
  67. # hidden on linux (starts with a '.') because there is a way to exclude this directory when grepping
  68. # the source tree.
  69. set( DOWNLOAD_DIR ${PROJECT_SOURCE_DIR}/.downloads-by-cmake
  70. CACHE PATH "Location of KiCad downloads, suggested is a dir common to all builds, i.e. global." )
  71. #Add option to add user directories for linker, if any
  72. LINK_DIRECTORIES( ${LINK_DIRECTORIES_PATH} )
  73. if( UNIX )
  74. set( KICAD_USER_CONFIG_DIR $ENV{HOME} CACHE PATH "Location of user specifig KiCad config files" )
  75. elseif( MINGW )
  76. set( KICAD_USER_CONFIG_DIR $ENV{%APPDATA%} CACHE PATH "Location of user specifig KiCad config files" )
  77. endif()
  78. mark_as_advanced( KICAD_USER_CONFIG_DIR )
  79. #================================================
  80. # Set flags for GCC, or treat llvm as GCC
  81. #================================================
  82. if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  83. execute_process( COMMAND ${CMAKE_C_COMPILER} -dumpversion
  84. OUTPUT_VARIABLE GCC_VERSION
  85. OUTPUT_STRIP_TRAILING_WHITESPACE )
  86. # Establish -Wall early, so specialized relaxations of this may come
  87. # subsequently on the command line, such as in pcbnew/github/CMakeLists.txt
  88. set( CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}" )
  89. set( CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}" )
  90. # The optimization level is -O1 instead of the usual -O2 level because
  91. # boost::polygon has a function (inflate polygon) broken by the -O2 level
  92. # with GCC 4.7.0 to 4.7.2 (works fine with with GCC 4.6 and 4.7.3).
  93. # This lower optimization level does not have a significant change on the speed.
  94. # See also:
  95. # https://bugs.launchpad.net/kicad/+bug/1056926
  96. # https://svn.boost.org/trac/boost/ticket/7983
  97. if( GCC_VERSION VERSION_EQUAL 4.7.0 OR ( GCC_VERSION VERSION_GREATER 4.7.0 AND GCC_VERSION VERSION_LESS 4.7.3 ) )
  98. set( CMAKE_C_FLAGS_RELEASE "-O1" )
  99. set( CMAKE_CXX_FLAGS_RELEASE "-O1" )
  100. else()
  101. set( CMAKE_C_FLAGS_RELEASE "-O2" )
  102. set( CMAKE_CXX_FLAGS_RELEASE "-O2" )
  103. endif()
  104. set( CMAKE_C_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG" )
  105. set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG -Wno-deprecated-declarations" )
  106. set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG" )
  107. set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG" )
  108. if( GXX_HAS_VISIBILITY_FLAG AND NOT APPLE )
  109. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden" )
  110. endif()
  111. if( GXX_HAS_VISIBILITY_INLINES_FLAG AND NOT APPLE )
  112. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden" )
  113. endif()
  114. if( MINGW )
  115. set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
  116. # _UNICODE definition seems needed under mingw/gcc 4.8
  117. # (Kicad uses unicode, and on Windows, wxWidgets >= 2.9.4 is mandatory
  118. # and uses unicode)
  119. if( GCC_VERSION VERSION_EQUAL 4.8.0 OR GCC_VERSION VERSION_GREATER 4.8.0 )
  120. add_definitions(-D_UNICODE)
  121. endif()
  122. # Since version 2.8.5, Cmake uses a response file (.rsp) to
  123. # pass the list of include paths to gcc
  124. # unfortunately, under mingw32+msys, at least with gcc 4.8 and previous,
  125. # this file is not expanded and include paths defined in this file are not taken in account
  126. # this is the case of wxWidgets includes
  127. # Disable this response file for includes ( See Windows-GNU.cmake module )
  128. if( WIN32 AND MSYS AND NOT CMAKE_CROSSCOMPILING )
  129. # fixme: it is needed only with MSYS+MINGW32? or always under MINGW
  130. if( ${CMAKE_SIZEOF_VOID_P} MATCHES 4 )
  131. set( CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0 )
  132. endif()
  133. endif()
  134. else()
  135. # We build DLL/DSOs from static libraries, so create position independent
  136. # code for all cases, since we do not have DLL/DSO specific static
  137. # libraries. Subdirectories via add_subdirectores() reference this
  138. # variable, and it is either set or empty, empty for Windows.
  139. set( PIC_FLAG -fPIC )
  140. set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PIC_FLAG}" )
  141. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PIC_FLAG}" )
  142. if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  143. set( TO_LINKER -XLinker )
  144. else()
  145. set( TO_LINKER -Wl )
  146. endif()
  147. # Thou shalt not link vaporware and tell us it's a valid DSO:
  148. set( CMAKE_SHARED_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
  149. set( CMAKE_MODULE_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
  150. set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
  151. endif()
  152. # quiet GCC while in boost
  153. if( GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8 )
  154. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs" )
  155. endif()
  156. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing" )
  157. if( APPLE )
  158. set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__ASSERTMACROS__ -mmacosx-version-min=10.5" )
  159. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__ASSERTMACROS__ -mmacosx-version-min=10.5" )
  160. # Allows .dylib relocation in the future
  161. set( CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -headerpad_max_install_names")
  162. if( NOT CMAKE_CXX_COMPILER )
  163. EXEC_PROGRAM( wx-config ARGS --cc OUTPUT_VARIABLE CMAKE_C_COMPILER )
  164. endif( NOT CMAKE_CXX_COMPILER )
  165. if( NOT CMAKE_CXX_COMPILER )
  166. EXEC_PROGRAM( wx-config ARGS --cxx OUTPUT_VARIABLE CMAKE_CXX_COMPILER )
  167. endif( NOT CMAKE_CXX_COMPILER )
  168. endif()
  169. endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  170. if( KICAD_KEEPCASE )
  171. add_definitions( -DKICAD_KEEPCASE )
  172. endif()
  173. if( USE_WX_OVERLAY OR APPLE )
  174. add_definitions( -DUSE_WX_OVERLAY )
  175. endif()
  176. if( KICAD_SCRIPTING )
  177. add_definitions( -DKICAD_SCRIPTING )
  178. endif()
  179. if( KICAD_SCRIPTING_MODULES )
  180. add_definitions( -DKICAD_SCRIPTING_MODULES )
  181. endif()
  182. if( KICAD_SCRIPTING_WXPYTHON )
  183. add_definitions( -DKICAD_SCRIPTING_WXPYTHON )
  184. endif()
  185. if( USE_WX_GRAPHICS_CONTEXT )
  186. add_definitions( -DUSE_WX_GRAPHICS_CONTEXT )
  187. endif()
  188. # Allow user to override the default settings for adding images to menu items. By default
  189. # images in menu items are enabled on all platforms except OSX. This can be over ridden by
  190. # defining -DUSE_IMAGES_IN_MENUS=ON/OFF to force the preferred behavior.
  191. if( NOT DEFINED USE_IMAGES_IN_MENUS )
  192. if( NOT APPLE )
  193. set( USE_IMAGES_IN_MENUS ON )
  194. endif()
  195. else()
  196. if( USE_IMAGES_IN_MENUS )
  197. set( USE_IMAGES_IN_MENUS ON )
  198. endif()
  199. endif()
  200. # KIFACE_SUFFIX is the file extension used for top level program modules which
  201. # implement the KIFACE interface. A valid suffix starts with a period '.'.
  202. if( false )
  203. # This is the eventual situation near milestone C) of modular-kicad blueprint.
  204. # Until then we use .kiface extension so we don't collide with python DSO.
  205. set( KIFACE_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX} )
  206. else()
  207. # Temporary situation until we can dovetail the python DSO into the kiface DSO.
  208. set( KIFACE_SUFFIX ".kiface" )
  209. endif()
  210. # KIFACE_PREFIX is a basename prefix used for top level program modules which
  211. # implement the KIFACE.
  212. set( KIFACE_PREFIX "_" )
  213. #message( STATUS "KIFACE_SUFFIX:${KIFACE_SUFFIX} KIFACE_PREFIX:${KIFACE_PREFIX}" )
  214. #================================================
  215. # Locations for install targets.
  216. set( KICAD_BIN bin
  217. CACHE PATH "Location of KiCad binaries." )
  218. set( KICAD_FP_LIB_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}"
  219. CACHE PATH "Default path where footprint libraries are installed." )
  220. if( UNIX )
  221. # Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
  222. set( KICAD_PLUGINS lib/kicad/plugins
  223. CACHE PATH "Location of KiCad plugins." )
  224. set( KICAD_DATA share/kicad
  225. CACHE PATH "Location of KiCad data files." )
  226. set( KICAD_DOCS share/doc/kicad
  227. CACHE PATH "Location of KiCad documentation files." )
  228. set( KICAD_FP_LIB_INSTALL_PATH "${KICAD_FP_LIB_INSTALL_PATH}/share/kicad/modules" )
  229. endif()
  230. if( MINGW )
  231. # Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
  232. set( KICAD_PLUGINS ${KICAD_BIN}/plugins
  233. CACHE PATH "Location of KiCad plugins." )
  234. set( KICAD_DATA share
  235. CACHE PATH "Location of KiCad data files." )
  236. set( KICAD_DOCS doc
  237. CACHE PATH "Location of KiCad documentation files." )
  238. set( KICAD_FP_LIB_INSTALL_PATH "${KICAD_FP_LIB_INSTALL_PATH}/modules" )
  239. endif()
  240. set( KICAD_DEMOS ${KICAD_DATA}/demos
  241. CACHE PATH "Location of KiCad demo files." )
  242. set( KICAD_TEMPLATE ${KICAD_DATA}/template
  243. CACHE PATH "Location of KiCad template files." )
  244. mark_as_advanced( KICAD_BIN
  245. KICAD_PLUGINS
  246. KICAD_DATA
  247. KICAD_DOCS
  248. KICAD_DEMOS
  249. KICAD_TEMPLATE )
  250. include( Functions )
  251. include( ExternalProject )
  252. #================================================
  253. # Find libraries that are needed to build KiCad.
  254. #================================================
  255. include( CheckFindPackageResult )
  256. # Turn on wxWidgets compatibility mode for some classes
  257. add_definitions(-DWX_COMPATIBILITY)
  258. #######################
  259. # Find OpenGL library #
  260. #######################
  261. find_package( OpenGL QUIET )
  262. check_find_package_result( OPENGL_FOUND "OpenGL" )
  263. if( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
  264. #set(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.so;.dylib;.dll")
  265. if( KICAD_BUILD_STATIC AND KICAD_BUILD_DYNAMIC )
  266. message(FATAL_ERROR "You can't build STATIC and DYNAMIC together")
  267. endif()
  268. if( KICAD_BUILD_STATIC )
  269. message(STATUS "KICAD_BUILD_STATIC set")
  270. endif()
  271. if( KICAD_BUILD_DYNAMIC )
  272. message(STATUS "KICAD_BUILD_DYNAMIC set")
  273. # TODO - Library packaging/relocation
  274. endif()
  275. add_custom_target( lib-dependencies
  276. DEPENDS boost cairo glew libpng pixman pkgconfig
  277. )
  278. include( download_libpng )
  279. if( KICAD_SCRIPTING_WXPYTHON )
  280. message( FATAL_ERROR "KICAD_BUILD_* and SCRIPTING Not Implemented Yet!" )
  281. else()
  282. include( download_wxwidgets )
  283. add_dependencies( lib-dependencies libwx )
  284. endif()
  285. include( download_pkgconfig )
  286. set( PKG_CONFIG_EXECUTABLE "${PKGCONFIG_ROOT}/bin/pkg-config" )
  287. include( download_glew )
  288. set( GLEW_GLEW_LIBRARY "${GLEW_ROOT}/lib/libGLEW.a" )
  289. set( GLEW_INCLUDE_DIR "${GLEW_ROOT}/include" )
  290. include( download_pixman )
  291. set( PIXMAN_LIBRARY "${PIXMAN_ROOT}/lib/libpixman-1.a" )
  292. include( download_cairo )
  293. set( CAIRO_INCLUDE_DIR "${CAIRO_ROOT}/include/cairo" )
  294. set( CAIRO_LIBRARY "${CAIRO_ROOT}/lib/libcairo.a" )
  295. if( KICAD_BUILD_DYNAMIC AND APPLE )
  296. add_custom_target( osx_fix_bundles ALL DEPENDS cvpcb eeschema gerbview kicad pcbnew bitmap2component pcb_calculator pl_editor)
  297. add_custom_command(TARGET osx_fix_bundles POST_BUILD COMMAND scripts/osx_fixbundle.sh COMMENT "Migrating dylibs to bundles")
  298. endif()
  299. endif( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC)
  300. #####################
  301. # Find GLEW library #
  302. #####################
  303. find_package(GLEW)
  304. check_find_package_result(GLEW_FOUND "GLEW")
  305. ######################
  306. # Find Cairo library #
  307. ######################
  308. find_package(Cairo 1.8.1 QUIET)
  309. check_find_package_result(CAIRO_FOUND "Cairo")
  310. # Download boost and possibly build parts of it
  311. #################################################
  312. if( KICAD_SKIP_BOOST )
  313. find_package( Boost 1.54.0 REQUIRED COMPONENTS context date_time filesystem iostreams locale
  314. program_options regex system thread )
  315. if( NOT Boost_FOUND )
  316. message( FATAL_ERROR "Boost 1.54+ libraries are required." )
  317. endif()
  318. message( WARNING "
  319. WARNING: You decided to skip building boost library.
  320. KiCad developers strongly advise you to build the bundled boost library, as it is known to work with KiCad.
  321. Other versions may contain bugs that may result in KiCad errors." )
  322. else()
  323. include( download_boost )
  324. endif()
  325. ##########################
  326. # Find wxWidgets library #
  327. ##########################
  328. # Here you can define what libraries of wxWidgets you need for your
  329. # application. You can figure out what libraries you need here;
  330. # http://www.wxwidgets.org/manuals/2.8/wx_librarieslist.html
  331. # On Apple only wxwidgets 2.9 or higher doesn't need to find aui part of base
  332. # Seems no more needed on wx-3
  333. if( APPLE AND NOT (KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC) )
  334. find_package( wxWidgets COMPONENTS gl adv html core net base xml QUIET )
  335. else()
  336. find_package( wxWidgets COMPONENTS gl aui adv html core net base xml QUIET )
  337. endif()
  338. if( NOT (KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC) )
  339. check_find_package_result( wxWidgets_FOUND "wxWidgets" )
  340. endif( NOT (KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC) )
  341. # Include wxWidgets macros.
  342. include( ${wxWidgets_USE_FILE} )
  343. # Include MinGW resource compiler.
  344. include( MinGWResourceCompiler )
  345. # Generate build system specific header file.
  346. include( PerformFeatureChecks )
  347. perform_feature_checks()
  348. # Find GDI+ on windows if wxGraphicsContext is available.
  349. if( MINGW AND USE_WX_GRAPHICS_CONTEXT )
  350. find_package( GdiPlus )
  351. check_find_package_result( GDI_PLUS_FOUND "GDI+" )
  352. endif()
  353. # Assist with header file searching optimization:
  354. # INC_BEFORE and INC_AFTER are two lists which go at the front and back of the
  355. # header file search lists, respectively.
  356. # INC_BEFORE is for use with "include_directories( BEFORE ...)", which _reverses_
  357. # the order during insertion. (So put first wanted last, which is
  358. # ${CMAKE_SOURCE_DIR/include.) Use '.' for current source dir since
  359. # we don't want expansion here and now, which would happen if using ${CMAKE_CURRENT_SOURCE_DIR}.
  360. # Instead we use '.' which is applicable to any source directory below here as a result of
  361. # this lack of expansion.
  362. set( INC_BEFORE
  363. .
  364. ${CMAKE_SOURCE_DIR}/include
  365. )
  366. set( INC_AFTER
  367. ${Boost_INCLUDE_DIR}
  368. #include <config.h>
  369. ${CMAKE_BINARY_DIR}
  370. )
  371. # Find Python and other scripting resources
  372. if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
  373. set( PythonInterp_FIND_VERSION )
  374. find_package( PythonInterp )
  375. check_find_package_result( PYTHONINTERP_FOUND "Python Interpreter" )
  376. # Get the correct Python site package install path from the Python interpreter found by
  377. # FindPythonInterp unless the user specifically defined a custom path.
  378. if( NOT PYTHON_SITE_PACKAGE_PATH )
  379. execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig;print\"%s\"%distutils.sysconfig.get_python_lib()"
  380. OUTPUT_VARIABLE PYTHON_SITE_PACKAGE_PATH
  381. OUTPUT_STRIP_TRAILING_WHITESPACE
  382. )
  383. if( NOT PYTHON_SITE_PACKAGE_PATH )
  384. message( FATAL_ERROR "Error occurred while attemping to find the Python site library path." )
  385. endif()
  386. endif()
  387. set( PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}" CACHE PATH "Python module install path." )
  388. mark_as_advanced( PYTHON_DEST )
  389. message( STATUS "Python module install path: ${PYTHON_DEST}" )
  390. find_package( PythonLibs )
  391. #message( STATUS "PYTHON_INCLUDE_DIRS:${PYTHON_INCLUDE_DIRS}" )
  392. # Infrequently needed headers go at end of search paths, append to INC_AFTER which
  393. # although is used for all components, should be a harmless hit for something like eeschema
  394. # so long as unused search paths are at the end like this.
  395. set( INC_AFTER ${INC_AFTER} ${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/scripting )
  396. #message( STATUS "/ INC_AFTER:${INC_AFTER}" )
  397. endif()
  398. # Automagically create version header file.
  399. include( CreateBzrVersionHeader )
  400. create_bzr_version_header()
  401. if( EXISTS ${CMAKE_SOURCE_DIR}/include/config.h )
  402. # This file may exist ( created by an alternate process to the svn test above),
  403. # e.g. could be created by a checkout script that produces a source tar file.
  404. # This directive means the about box will have the svn date & revision in it,
  405. # but the hard coded release date ( program version) will be preserved.
  406. add_definitions( -DHAVE_SVN_REVISION )
  407. endif()
  408. #================================================
  409. # Let CMake look in these directories for nested
  410. # 'CMakeLists.txt' files to process
  411. #================================================
  412. ############################
  413. # Binaries ( CMake targets ) #
  414. ############################
  415. add_subdirectory( bitmaps_png )
  416. add_subdirectory( common )
  417. add_subdirectory( 3d-viewer )
  418. add_subdirectory( cvpcb )
  419. add_subdirectory( eeschema )
  420. add_subdirectory( gerbview )
  421. add_subdirectory( kicad )
  422. add_subdirectory( lib_dxf )
  423. add_subdirectory( pcbnew )
  424. add_subdirectory( polygon )
  425. add_subdirectory( pagelayout_editor )
  426. add_subdirectory( potrace )
  427. add_subdirectory( bitmap2component )
  428. add_subdirectory( pcb_calculator )
  429. add_subdirectory( tools )
  430. add_subdirectory( utils )
  431. add_subdirectory( qa )
  432. #add_subdirectory( new )
  433. # Make all libs and executables depend on ExternalProject_Add( boost ),
  434. # except perhaps bitmap lib. This allows a multi-threaded build to succeed.
  435. add_dependencies( pcbnew boost )
  436. add_dependencies( eeschema boost )
  437. add_dependencies( cvpcb boost )
  438. add_dependencies( gal boost )
  439. add_dependencies( common boost )
  440. add_dependencies( pcbcommon boost )
  441. add_dependencies( 3d-viewer boost )
  442. add_dependencies( pcad2kicadpcb boost )
  443. add_dependencies( polygon boost )
  444. add_dependencies( pl_editor boost )
  445. add_dependencies( pnsrouter boost )
  446. if ( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
  447. add_dependencies( pcbnew lib-dependencies )
  448. add_dependencies( eeschema lib-dependencies )
  449. add_dependencies( cvpcb lib-dependencies )
  450. add_dependencies( gal lib-dependencies )
  451. add_dependencies( common lib-dependencies )
  452. add_dependencies( pcbcommon lib-dependencies )
  453. add_dependencies( 3d-viewer lib-dependencies )
  454. add_dependencies( pcad2kicadpcb lib-dependencies )
  455. add_dependencies( polygon lib-dependencies )
  456. add_dependencies( pl_editor lib-dependencies )
  457. add_dependencies( pnsrouter lib-dependencies )
  458. if ( BUILD_GITHUB_PLUGIN )
  459. add_dependencies( github_plugin lib-dependencies )
  460. endif()
  461. endif()
  462. if ( KICAD_BUILD_DYNAMIC )
  463. endif()
  464. #############
  465. # Resources #
  466. #############
  467. add_subdirectory( demos )
  468. add_subdirectory( template )
  469. #================================================
  470. # Doxygen Output
  471. #================================================
  472. find_package( Doxygen )
  473. if( DOXYGEN_FOUND )
  474. add_custom_target( doxygen-docs
  475. ${CMAKE_COMMAND} -E remove_directory Documentation/doxygen
  476. COMMAND ${DOXYGEN_EXECUTABLE}
  477. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  478. DEPENDS Doxyfile
  479. COMMENT "building doxygen docs into directory Documentation/doxygen/html"
  480. )
  481. else()
  482. message( STATUS "WARNING: Doxygen not found - doxygen-docs (Source Docs) target not created" )
  483. endif()
  484. #================================================
  485. # "make uninstall" rules
  486. #================================================
  487. configure_file(
  488. "${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
  489. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  490. IMMEDIATE @ONLY )
  491. add_custom_target( uninstall
  492. "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
  493. #================================================
  494. # Installation
  495. #================================================
  496. install( FILES INSTALL.txt
  497. DESTINATION ${KICAD_DOCS}
  498. COMPONENT resources )
  499. install( FILES resources/freeroute.jnlp
  500. DESTINATION ${KICAD_BIN}
  501. COMPONENT resources )
  502. ###
  503. # Install scripts
  504. ###
  505. if( UNIX )
  506. install( DIRECTORY scripts
  507. DESTINATION ${KICAD_DOCS}
  508. COMPONENT resources
  509. )
  510. endif()
  511. ###
  512. # FreeDesktop .desktop and MIME resources
  513. ###
  514. if( UNIX )
  515. # Set paths
  516. set( UNIX_MIME_DIR resources/linux/mime )
  517. set( UNIX_MIMELNK_FILES ${UNIX_MIME_DIR}/mimelnk )
  518. set( UNIX_MIME_FILES ${UNIX_MIME_DIR}/mime )
  519. set( UNIX_ICON_FILES ${UNIX_MIME_DIR}/icons )
  520. set( UNIX_APPLICATIONS_FILES ${UNIX_MIME_DIR}/applications )
  521. # Install Mimelnk directory
  522. install( DIRECTORY ${UNIX_MIMELNK_FILES}
  523. DESTINATION ${CMAKE_INSTALL_PREFIX}/share
  524. COMPONENT resources
  525. )
  526. # Install Mime directory
  527. install( DIRECTORY ${UNIX_ICON_FILES}
  528. DESTINATION ${CMAKE_INSTALL_PREFIX}/share
  529. COMPONENT resources
  530. )
  531. # Install Icons
  532. install( DIRECTORY ${UNIX_MIME_FILES}
  533. DESTINATION ${CMAKE_INSTALL_PREFIX}/share
  534. COMPONENT resources
  535. )
  536. # Install Applications directory (.desktop files)
  537. install( DIRECTORY ${UNIX_APPLICATIONS_FILES}
  538. DESTINATION ${CMAKE_INSTALL_PREFIX}/share
  539. COMPONENT resources
  540. )
  541. endif()
  542. #include( CTest )
  543. if( UNIX AND NOT APPLE )
  544. # Create a *.deb file:
  545. set( CPACK_GENERATOR "DEB" )
  546. set( CPACK_DEBIAN_PACKAGE_MAINTAINER "http://launchpad.net/kicad" )
  547. set( CPACK_PACKAGE_VERSION_MAJOR 1 )
  548. set( CPACK_PACKAGE_VERSION_MINOR 0 )
  549. set( CPACK_PACKAGE_VERSION_PATCH 0 )
  550. #set( CPACK_PACKAGE_CONTACT Firstname Lastname <email@company.com> )
  551. set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "KiCad built by CMake build system." )
  552. include( CPack )
  553. endif()