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.

958 lines
34 KiB

18 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
18 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 years ago
* KIWAY Milestone A): Make major modules into DLL/DSOs. ! The initial testing of this commit should be done using a Debug build so that all the wxASSERT()s are enabled. Also, be sure and keep enabled the USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it off is senseless anyways. If you want stable code, go back to a prior version, the one tagged with "stable". * Relocate all functionality out of the wxApp derivative into more finely targeted purposes: a) DLL/DSO specific b) PROJECT specific c) EXE or process specific d) configuration file specific data e) configuration file manipulations functions. All of this functionality was blended into an extremely large wxApp derivative and that was incompatible with the desire to support multiple concurrently loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects. An amazing amount of organization come from simply sorting each bit of functionality into the proper box. * Switch to wxConfigBase from wxConfig everywhere except instantiation. * Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD, PGM_SINGLE_TOP, * Remove "Return" prefix on many function names. * Remove obvious comments from CMakeLists.txt files, and from else() and endif()s. * Fix building boost for use in a DSO on linux. * Remove some of the assumptions in the CMakeLists.txt files that windows had to be the host platform when building windows binaries. * Reduce the number of wxStrings being constructed at program load time via static construction. * Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that these functions are useful even when the wxConfigBase comes from another source, as is the case in the KICAD_MANAGER_FRAME. * Move the setting of the KIPRJMOD environment variable into class PROJECT, so that it can be moved into a project variable soon, and out of FP_LIB_TABLE. * Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all its child wxFrames and wxDialogs now have a Kiway() member function which returns a KIWAY& that that window tree branch is in support of. This is like wxWindows DNA in that child windows get this member with proper value at time of construction. * Anticipate some of the needs for milestones B) and C) and make code adjustments now in an effort to reduce work in those milestones. * No testing has been done for python scripting, since milestone C) has that being largely reworked and re-thought-out.
12 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
  1. #
  2. # This program source code file is part of KICAD, a free EDA CAD application.
  3. #
  4. # Copyright (C) 2007-2018 Kicad Developers, see AUTHORS.txt for contributors.
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, you may find one here:
  18. # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. # or you may search the http://www.gnu.org website for the version 2 license,
  20. # or you may write to the Free Software Foundation, Inc.,
  21. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. #
  23. cmake_minimum_required( VERSION 2.8.12 FATAL_ERROR )
  24. # because of http://public.kitware.com/Bug/view.php?id=10395
  25. # See https://gitlab.kitware.com/cmake/cmake/issues/15943
  26. # Remove as soon as 3.1 is minimum required version
  27. if(POLICY CMP0025)
  28. cmake_policy(SET CMP0025 NEW) # CMake 3.0
  29. endif()
  30. # Default to CMAKE_BUILD_TYPE = Release unless overridden on command line
  31. # http://www.cmake.org/pipermail/cmake/2008-September/023808.html
  32. if( DEFINED CMAKE_BUILD_TYPE )
  33. set( CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Set to either \"Release\" or \"Debug\"" )
  34. else()
  35. set( CMAKE_BUILD_TYPE Release CACHE STRING "Set to either \"Release\" or \"Debug\"" )
  36. endif()
  37. project( kicad )
  38. include( GNUInstallDirs )
  39. # Path to local CMake modules.
  40. set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
  41. # On Windows, binaries created by link option -g3 are very large (more than 1Gb for pcbnew,
  42. # and more than 3Gb for the full kicad suite)
  43. # This option create binaries using link option -g1 that create much smaller files, but
  44. # there are less info in debug (but the file names and line numbers are available)
  45. option( BUILD_SMALL_DEBUG_FILES "In debug build: create smaller binaries." OFF )
  46. #
  47. # KiCad build options should be added below.
  48. #
  49. # If you add a new build option, please add it's state to the
  50. # OnCopyVersionInfo() function in common/dialog_about/dialog_about.cpp
  51. # so that build option settings can be included in bug reports.
  52. #
  53. option( USE_WX_GRAPHICS_CONTEXT
  54. "Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental" )
  55. option( USE_WX_OVERLAY
  56. "Use wxOverlay: Always ON for MAC and GTK3 (default OFF)." )
  57. option( KICAD_SCRIPTING
  58. "Build the Python scripting support inside KiCad binaries (default ON)."
  59. ON )
  60. option( KICAD_SCRIPTING_MODULES
  61. "Build native portion of the pcbnew Python module: _pcbnew.{pyd,so} for OS command line use of Python."
  62. ON )
  63. option( KICAD_SCRIPTING_PYTHON3
  64. "Build for Python 3 instead of 2 (default OFF)."
  65. OFF )
  66. option( KICAD_SCRIPTING_WXPYTHON
  67. "Build wxPython implementation for wx interface building in Python and py.shell (default ON)."
  68. ON )
  69. option( KICAD_SCRIPTING_WXPYTHON_PHOENIX
  70. "Use new wxPython binding (default OFF)."
  71. OFF )
  72. option( KICAD_SCRIPTING_ACTION_MENU
  73. "Build a tools menu with registered python plugins: actions plugins (default ON)."
  74. ON )
  75. option( KICAD_USE_OCE
  76. "Build tools and plugins related to OpenCascade Community Edition (default ON)"
  77. ON )
  78. option( KICAD_USE_OCC
  79. "Build tools and plugins related to OpenCascade Technology (overrides KICAD_USE_OCE, default OFF)"
  80. OFF )
  81. option( KICAD_INSTALL_DEMOS
  82. "Install KiCad demos and examples (default ON)"
  83. ON )
  84. option( KICAD_BUILD_QA_TESTS
  85. "Build software Quality assurance unit tests (default ON)"
  86. ON )
  87. # when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
  88. # PYTHON_EXECUTABLE can be defined when invoking cmake
  89. # ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
  90. # when not defined by user, the default is python.exe under Windows and python2 for others
  91. # python binary file should be in exec path.
  92. # KICAD_SCRIPTING_MODULES requires KICAD_SCRIPTING enable it here if KICAD_SCRIPTING_MODULES is ON
  93. if ( KICAD_SCRIPTING_MODULES AND NOT KICAD_SCRIPTING )
  94. message(STATUS "Changing KICAD_SCRIPTING to ON as needed by KICAD_SCRIPTING_MODULES")
  95. set ( KICAD_SCRIPTING ON )
  96. endif()
  97. # same with KICAD_SCRIPTING_ACTION_MENUS
  98. if ( KICAD_SCRIPTING_ACTION_MENU AND NOT KICAD_SCRIPTING )
  99. message(STATUS "Changing KICAD_SCRIPTING to ON as needed by KICAD_SCRIPTING_ACTION_MENU")
  100. set ( KICAD_SCRIPTING ON )
  101. endif()
  102. option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." ON )
  103. option( KICAD_SPICE "Build KiCad with internal Spice simulator." ON )
  104. # Global setting: exports are explicit
  105. set( CMAKE_CXX_VISIBILITY_PRESET "hidden" )
  106. set( CMAKE_VISIBILITY_INLINES_HIDDEN ON )
  107. # Global setting: build everything position independent
  108. set( CMAKE_POSITION_INDEPENDENT_CODE ON )
  109. # Global setting: Use C++11
  110. set(CMAKE_CXX_STANDARD 11)
  111. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  112. # CMP0063: CMake < 3.3 does not handle hidden visibility for static libraries,
  113. # and 3.3 is backwards compatible when the minimum version is smaller than 3.3.
  114. if( POLICY CMP0063 )
  115. cmake_policy( GET CMP0063 VISIBILITY_POLICY )
  116. if( VISIBILITY_POLICY STREQUAL NEW )
  117. message( WARNING "Compatibility code for CMake < 3.3 can be removed, search for CMP0063" )
  118. else()
  119. cmake_policy( SET CMP0063 NEW )
  120. endif()
  121. else()
  122. if( CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY AND NOT APPLE )
  123. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY}hidden" )
  124. endif()
  125. if( CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN AND NOT APPLE )
  126. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN}" )
  127. endif()
  128. endif()
  129. # Add option to add user directories for linker, if any
  130. LINK_DIRECTORIES( ${LINK_DIRECTORIES_PATH} )
  131. set( KICAD_CONFIG_DIR "kicad" CACHE STRING "Location of user specific KiCad config files" )
  132. mark_as_advanced( KICAD_CONFIG_DIR )
  133. add_definitions( -DKICAD_CONFIG_DIR=${KICAD_CONFIG_DIR} )
  134. # Set default data file path to CMAKE_INSTALL_PREFIX if it wasn't specified during the
  135. # CMake configuration. The value of DEFAULT_INSTALL_PATH is expanded in config.h and
  136. # used in the source code to define the base path for kicad search paths and environment
  137. # variables.
  138. if( NOT DEFAULT_INSTALL_PATH )
  139. set( DEFAULT_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}"
  140. CACHE
  141. PATH
  142. "Location of KiCad data files." )
  143. endif()
  144. message( STATUS "KiCad install dir: <${DEFAULT_INSTALL_PATH}>" )
  145. # Generate build system specific header file.
  146. include( PerformFeatureChecks )
  147. perform_feature_checks()
  148. # Workaround: CMake < 3.1 does not support CMAKE_CXX_STANDARD
  149. if( NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.1 )
  150. message( FATAL_ERROR "Remove compatibility code" )
  151. endif()
  152. if( CMAKE_VERSION VERSION_LESS 3.1 AND ( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) )
  153. include(CheckCXXCompilerFlag)
  154. CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
  155. if(COMPILER_SUPPORTS_CXX11)
  156. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  157. else()
  158. message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
  159. endif()
  160. endif()
  161. # Warn about missing override specifiers, if supported
  162. if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  163. include(CheckCXXCompilerFlag)
  164. CHECK_CXX_COMPILER_FLAG("-Wsuggest-override" COMPILER_SUPPORTS_WSUGGEST_OVERRIDE)
  165. if(COMPILER_SUPPORTS_WSUGGEST_OVERRIDE)
  166. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
  167. endif()
  168. CHECK_CXX_COMPILER_FLAG("-Wvla" COMPILER_SUPPORTS_WVLA)
  169. if(COMPILER_SUPPORTS_WVLA)
  170. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=vla")
  171. endif()
  172. endif()
  173. # Warn about shadowed variables (-Wshadow option), if supported
  174. # Unfortunately, the swig autogenerated files have a lot of shadowed variables
  175. # and -Wno-shadow does not exist.
  176. # Adding -Wshadow can be made only for .cpp files
  177. # and will be added later in CMakeLists.txt
  178. if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  179. include(CheckCXXCompilerFlag)
  180. CHECK_CXX_COMPILER_FLAG("-Wshadow" COMPILER_SUPPORTS_WSHADOW)
  181. if( COMPILER_SUPPORTS_WSHADOW )
  182. set(WSHADOW_FLAGS "-Wshadow")
  183. endif()
  184. endif()
  185. if( WIN32 )
  186. # define UNICODE and_UNICODE definition on Windows. KiCad uses unicode.
  187. # Both definitions are required
  188. add_definitions(-DUNICODE -D_UNICODE)
  189. endif()
  190. #================================================
  191. # Provide access to CCACHE
  192. #================================================
  193. if (USE_CCACHE)
  194. find_program(CCACHE_FOUND ccache)
  195. if(CCACHE_FOUND)
  196. get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
  197. set(RULE_LAUNCH_COMPILE "${RULE_LAUNCH_COMPILE} ${CCACHE_FOUND}")
  198. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH_COMPILE})
  199. get_property(RULE_LAUNCH_LINK GLOBAL PROPERTY RULE_LAUNCH_LINK)
  200. set(RULE_LAUNCH_LINK "${RULE_LAUNCH_LINK} ${CCACHE_FOUND}")
  201. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${RULE_LAUNCH_LINK})
  202. message(STATUS "Used ${CCACHE_FOUND} for compilation.")
  203. else(CCACHE_FOUND)
  204. message(STATUS "CCache was requested but not found.")
  205. endif(CCACHE_FOUND)
  206. endif(USE_CCACHE)
  207. #================================================
  208. # Provide access to DISTCC
  209. #================================================
  210. if (USE_DISTCC)
  211. find_program(DISTCC_FOUND distcc)
  212. if(DISTCC_FOUND)
  213. get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
  214. set(RULE_LAUNCH_COMPILE "${RULE_LAUNCH_COMPILE} ${DISTCC_FOUND}")
  215. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH_COMPILE})
  216. message(STATUS "Using ${DISTCC_FOUND} for distributed build.")
  217. else(DISTCC_FOUND)
  218. message(INFO "Distcc was requested but not found.")
  219. endif(DISTCC_FOUND)
  220. endif(USE_DISTCC)
  221. #================================================
  222. # Set flags for GCC, or treat llvm as GCC
  223. #================================================
  224. if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  225. # Set 32-bit flag for GCC to prevent excess precision
  226. if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
  227. set( CMAKE_CXX_FLAGS "-ffloat-store ${CMAKE_CXX_FLAGS}" )
  228. endif()
  229. # Establish -Wall early, so specialized relaxations of this may come
  230. # subsequently on the command line, such as in pcbnew/github/CMakeLists.txt
  231. set( CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}" )
  232. set( CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_FLAGS}" )
  233. # Link flags in Debug: -g1 and -ggdb1 or -g1 and -ggdb3 can be used.
  234. # Level 1 produces minimal information, enough for making basic backtraces.
  235. # This includes descriptions of functions and external variables, and line number tables,
  236. # but no information about local variables.
  237. # Level 3 includes full information, but binaries are much larger.
  238. if( BUILD_SMALL_DEBUG_FILES )
  239. set( CMAKE_C_FLAGS_DEBUG "-g1 -ggdb1 -DDEBUG" )
  240. set( CMAKE_CXX_FLAGS_DEBUG "-g1 -ggdb1 -DDEBUG -Wno-deprecated-declarations" )
  241. else()
  242. set( CMAKE_C_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG" )
  243. set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3 -DDEBUG -Wno-deprecated-declarations" )
  244. endif()
  245. if( MINGW )
  246. set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
  247. # Since version 2.8.5, Cmake uses a response file (.rsp) to
  248. # pass the list of include paths to gcc
  249. # unfortunately, under mingw32+msys, at least with gcc 4.8 and previous,
  250. # this file is not always expanded and in this case include paths defined in this file
  251. # are not taken in account ( this is the case of wxWidgets includes )
  252. # If it is the case, disable this response file for includes ( See Windows-GNU.cmake module )
  253. if( false ) #set to true to disable the include response file
  254. if( WIN32 AND MSYS AND NOT CMAKE_CROSSCOMPILING )
  255. # fixme: it is needed only with MSYS+MINGW32? or always under MINGW
  256. if( ${CMAKE_SIZEOF_VOID_P} MATCHES 4 )
  257. set( CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0 )
  258. endif()
  259. endif()
  260. endif()
  261. # for some reasons, cmake does do use always a response file to send the list of objects
  262. # to the archiver, and because this list can be very long, and can create issue
  263. # when it is used in a command line, force use of a response file to store it
  264. SET( CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1 )
  265. # The MinGW compiler can use the microsoft system snprintf as standard and it has a broken
  266. # API with respect to the C99 standard, so make sure we force it to use its own compliant
  267. # snprintf
  268. add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
  269. elseif( NOT APPLE )
  270. # Thou shalt not link vaporware and tell us it's a valid DSO (apple ld doesn't support it)
  271. # temporarily disabled due to breaking ASAN-enabled builds - Tom
  272. # set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
  273. # set( CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined" )
  274. set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
  275. endif()
  276. if( APPLE )
  277. set( CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -headerpad_max_install_names") # needed by fixbundle
  278. endif()
  279. endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  280. if( USE_WX_OVERLAY OR APPLE )
  281. add_definitions( -DUSE_WX_OVERLAY )
  282. endif()
  283. if( KICAD_SCRIPTING )
  284. add_definitions( -DKICAD_SCRIPTING )
  285. endif()
  286. if( KICAD_SCRIPTING_MODULES )
  287. add_definitions( -DKICAD_SCRIPTING_MODULES )
  288. endif()
  289. if( KICAD_SCRIPTING_PYTHON3 )
  290. add_definitions( -DKICAD_SCRIPTING_PYTHON3 )
  291. endif()
  292. if( KICAD_SCRIPTING_WXPYTHON )
  293. add_definitions( -DKICAD_SCRIPTING_WXPYTHON )
  294. endif()
  295. if( KICAD_SCRIPTING_WXPYTHON_PHOENIX )
  296. add_definitions( -DKICAD_SCRIPTING_WXPYTHON_PHOENIX )
  297. endif()
  298. if( KICAD_SCRIPTING_ACTION_MENU )
  299. add_definitions( -DKICAD_SCRIPTING_ACTION_MENU )
  300. endif()
  301. if( KICAD_SPICE )
  302. add_definitions( -DKICAD_SPICE )
  303. endif()
  304. if( KICAD_USE_OCE )
  305. add_definitions( -DKICAD_USE_OCE )
  306. endif()
  307. if( KICAD_USE_OCC )
  308. add_definitions( -DKICAD_USE_OCC )
  309. remove_definitions( -DKICAD_USE_OCE )
  310. unset( KICAD_USE_OCE )
  311. endif()
  312. if( KICAD_USE_CUSTOM_PADS )
  313. add_definitions( -DKICAD_USE_CUSTOM_PADS )
  314. endif()
  315. if( USE_WX_GRAPHICS_CONTEXT OR APPLE )
  316. add_definitions( -DUSE_WX_GRAPHICS_CONTEXT )
  317. endif()
  318. # KIFACE_SUFFIX is the file extension used for top level program modules which
  319. # implement the KIFACE interface. A valid suffix starts with a period '.'.
  320. if( false )
  321. # This is the eventual situation near milestone C) of modular-kicad blueprint.
  322. # Until then we use .kiface extension so we don't collide with python DSO.
  323. set( KIFACE_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX} )
  324. else()
  325. # Temporary situation until we can dovetail the python DSO into the kiface DSO.
  326. set( KIFACE_SUFFIX ".kiface" )
  327. endif()
  328. # KIFACE_PREFIX is a basename prefix used for top level program modules which
  329. # implement the KIFACE.
  330. set( KIFACE_PREFIX "_" )
  331. #message( STATUS "KIFACE_SUFFIX:${KIFACE_SUFFIX} KIFACE_PREFIX:${KIFACE_PREFIX}" )
  332. #================================================
  333. # Locations for install targets.
  334. #================================================
  335. if( NOT APPLE )
  336. # Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
  337. set( KICAD_BIN bin
  338. CACHE PATH "Location of KiCad binaries." )
  339. set( KICAD_DATA ${CMAKE_INSTALL_DATADIR}/kicad
  340. CACHE PATH "Location of KiCad data files." )
  341. if( WIN32 )
  342. set( KICAD_PLUGINS ${KICAD_BIN}/scripting/plugins
  343. CACHE PATH "Location of KiCad plugins." )
  344. set( KICAD_LIB ${KICAD_BIN}
  345. CACHE PATH "Location of KiCad shared objects" )
  346. set( KICAD_USER_PLUGIN ${KICAD_BIN}/plugins
  347. CACHE PATH "Location of KiCad user-loaded plugins" )
  348. else()
  349. set( KICAD_PLUGINS ${KICAD_DATA}/plugins
  350. CACHE PATH "Location of KiCad plugins." )
  351. set( KICAD_LIB ${CMAKE_INSTALL_LIBDIR}
  352. CACHE PATH "Location of KiCad shared objects" )
  353. set( KICAD_USER_PLUGIN ${CMAKE_INSTALL_LIBDIR}/kicad/plugins
  354. CACHE PATH "Location of KiCad user-loaded plugins" )
  355. endif()
  356. set( KICAD_DOCS ${CMAKE_INSTALL_DATADIR}/doc/kicad
  357. CACHE PATH "Location of KiCad documentation files." )
  358. set( KICAD_DEMOS ${KICAD_DATA}/demos
  359. CACHE PATH "Location of KiCad demo files." )
  360. set( KICAD_TEMPLATE ${KICAD_DATA}/template
  361. CACHE PATH "Location of KiCad template files." )
  362. else()
  363. # everything without leading / is relative to CMAKE_INSTALL_PREFIX.
  364. # CMAKE_INSTALL_PREFIX is root of .dmg image
  365. set( KICAD_BIN ${CMAKE_INSTALL_PREFIX}
  366. CACHE PATH "Location of KiCad binaries." FORCE )
  367. # some paths to single app bundle
  368. set( OSX_BUNDLE_MAIN "kicad.app" )
  369. set( OSX_BUNDLE_BIN_DIR "Contents/MacOS" )
  370. set( OSX_BUNDLE_LIB_DIR "Contents/Frameworks" )
  371. set( OSX_BUNDLE_KIFACE_DIR "Contents/PlugIns" )
  372. set( OSX_BUNDLE_SUP_DIR "Contents/SharedSupport" )
  373. set( OSX_BUNDLE_APP_DIR "Contents/Applications" )
  374. set( OSX_BUNDLE_BUILD_DIR "${CMAKE_BINARY_DIR}/kicad/${OSX_BUNDLE_MAIN}" )
  375. set( OSX_BUNDLE_BUILD_BIN_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_BIN_DIR}" )
  376. set( OSX_BUNDLE_BUILD_LIB_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_LIB_DIR}" )
  377. set( OSX_BUNDLE_BUILD_KIFACE_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
  378. set( OSX_BUNDLE_BUILD_PLUGIN_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
  379. set( OSX_BUNDLE_INSTALL_DIR "${KICAD_BIN}/${OSX_BUNDLE_MAIN}" )
  380. set( OSX_BUNDLE_INSTALL_BIN_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_BIN_DIR}" )
  381. set( OSX_BUNDLE_INSTALL_LIB_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_LIB_DIR}" )
  382. set( OSX_BUNDLE_INSTALL_KIFACE_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
  383. set( OSX_BUNDLE_INSTALL_PLUGIN_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
  384. # everything provided with the application bundle goes into
  385. # kicad.app/Contents/SharedSupport => accessible via GetDataDir()
  386. # everything else to the .dmg image
  387. set( KICAD_DATA ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_SUP_DIR}
  388. CACHE PATH "Location of KiCad data files." FORCE )
  389. set( KICAD_LIB ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_LIB_DIR}
  390. CACHE PATH "Location of KiCad shared objects" FORCE )
  391. set( KICAD_USER_PLUGIN ${OSX_BUNDLE_INSTALL_PLUGIN_DIR}
  392. CACHE PATH "Location of KiCad user-loaded plugins" FORCE )
  393. set( KICAD_TEMPLATE ${KICAD_DATA}/template
  394. CACHE PATH "Location of KiCad template files." FORCE )
  395. set( KICAD_PLUGINS ${KICAD_DATA}/plugins
  396. CACHE PATH "Location of KiCad plugins." FORCE )
  397. set( KICAD_DOCS doc
  398. CACHE PATH "Location of KiCad documentation files." FORCE )
  399. set( KICAD_DEMOS demos
  400. CACHE PATH "Location of KiCad demo files." FORCE )
  401. # RPATH setttings for building shared libraries
  402. set( CMAKE_MACOSX_RPATH FALSE )
  403. # Override default paths for fixup_bundle
  404. set( OSX_BUNDLE_OVERRIDE_PATHS "
  405. function( gp_item_default_embedded_path_override item default_embedded_path_var )
  406. # by default, embed things right next to the main bundle executable:
  407. set( path \"@executable_path/../../Contents/MacOS\" )
  408. set( overridden 0 )
  409. # embed .dylibs right next to the main bundle executable:
  410. if( item MATCHES \"\\\\.dylib$\" )
  411. set( path \"@executable_path/../Frameworks\" )
  412. set( overridden 1 )
  413. endif()
  414. set( \${default_embedded_path_var} \"\${path}\" PARENT_SCOPE )
  415. endfunction(gp_item_default_embedded_path_override)
  416. # If `BU_CHMOD_BUNDLE_ITEMS` is not set, `install_name_tool` will fail to re-write some
  417. # loader paths due to lack of writable permissions if the build dependencies were installed
  418. # by brew (or didn't have writable permissions)
  419. set ( BU_CHMOD_BUNDLE_ITEMS ON )
  420. "
  421. )
  422. endif()
  423. mark_as_advanced( KICAD_BIN
  424. KICAD_PLUGINS
  425. KICAD_USER_PLUGIN
  426. KICAD_LIB
  427. KICAD_DATA
  428. KICAD_DOCS
  429. KICAD_DEMOS
  430. KICAD_TEMPLATE )
  431. include( Functions )
  432. include( ExternalProject )
  433. #================================================
  434. # Find libraries that are needed to build KiCad.
  435. #================================================
  436. include( CheckFindPackageResult )
  437. #
  438. # Find OpenGL library, required
  439. #
  440. set( OpenGL_GL_PREFERENCE "LEGACY" ) # CMake 3.11+ setting; see 'cmake --help-policy CMP0072'
  441. find_package( OpenGL REQUIRED )
  442. #
  443. # Find GLEW library, required
  444. #
  445. if( NOT GLEW_FOUND )
  446. find_package( GLEW REQUIRED )
  447. check_find_package_result( GLEW_FOUND "GLEW" )
  448. endif()
  449. #
  450. # Find GLM library, required
  451. #
  452. find_package( GLM 0.9.5.1 REQUIRED )
  453. if( GLM_VERSION MATCHES "0.9.9.3" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
  454. MESSAGE( FATAL_ERROR "\nGLM version ${GLM_VERSION} is incompatible with KiCad using GCC.\n"
  455. "Please downgrade to GLM version 0.9.9.2 or older or use clang instead" )
  456. endif()
  457. add_definitions( -DGLM_FORCE_CTOR_INIT )
  458. #
  459. # Find CURL library, required for github plugin
  460. #
  461. if( BUILD_GITHUB_PLUGIN )
  462. find_package( CURL REQUIRED )
  463. endif()
  464. #
  465. # Find Cairo library, required
  466. #
  467. find_package( Cairo 1.12 REQUIRED )
  468. find_package( Pixman 0.30 REQUIRED )
  469. #
  470. # Find Boost headers, required.
  471. find_package( Boost 1.54.0 REQUIRED COMPONENTS regex )
  472. # Include MinGW resource compiler.
  473. include( MinGWResourceCompiler )
  474. # Find GDI+ on windows if wxGraphicsContext is available, and only link gdiplus library
  475. # if wxGraphicsContext not used, because the cairo printing system uses this library
  476. if( WIN32 )
  477. if( USE_WX_GRAPHICS_CONTEXT )
  478. find_package( GdiPlus )
  479. check_find_package_result( GDI_PLUS_FOUND "GDI+" )
  480. else()
  481. # if WX_GRAPHICS_CONTEXT is not used we just need the gdiplus library for cairo printing
  482. set( GDI_PLUS_LIBRARIES gdiplus )
  483. endif()
  484. endif()
  485. # Find ngspice library, required for integrated circuit simulator
  486. if( KICAD_SPICE )
  487. find_package( ngspice REQUIRED )
  488. endif()
  489. # Find OpenCascade Community Edition, required for STEP plugin and tools
  490. if( KICAD_USE_OCE )
  491. set( OCC_LIBRARIES TKBinXCAF TKPCAF TKSTEP TKXDESTEP TKIGES TKXDEIGES )
  492. find_package( OCE 0.16 REQUIRED ${OCC_LIBRARIES} )
  493. elseif( KICAD_USE_OCC )
  494. find_package(OpenCASCADE)
  495. if( NOT OCC_FOUND )
  496. MESSAGE( FATAL_ERROR "================================================================\n"
  497. " KICAD_USE_OCC=True but OpenCASCADE was no found!\n"
  498. "================================================================\n")
  499. endif()
  500. if( OCC_VERSION_STRING VERSION_LESS 6.8.0 )
  501. MESSAGE( FATAL_ERROR "================================================================\n"
  502. "OpenCASCADE version ${OCC_VERSION_STRING} was found.\n"
  503. " KiCad requires a minimum version of 6.8.0\n"
  504. "================================================================\n")
  505. endif()
  506. include_directories( SYSTEM ${OCC_INCLUDE_DIR} )
  507. endif()
  508. # Assist with header file searching optimization:
  509. # INC_BEFORE and INC_AFTER are two lists which go at the front and back of the
  510. # header file search lists, respectively.
  511. # INC_BEFORE is for use with "include_directories( BEFORE ...)", which _reverses_
  512. # the order during insertion. (So put first wanted last, which is
  513. # ${CMAKE_SOURCE_DIR/include.) Use '.' for current source dir since
  514. # we don't want expansion here and now, which would happen if using ${CMAKE_CURRENT_SOURCE_DIR}.
  515. # Instead we use '.' which is applicable to any source directory below here as a result of
  516. # this lack of expansion.
  517. set( INC_BEFORE
  518. .
  519. ${CMAKE_SOURCE_DIR}/include
  520. )
  521. set( INC_AFTER
  522. ${Boost_INCLUDE_DIR}
  523. ${CMAKE_BINARY_DIR}
  524. )
  525. # Find Python and other scripting resources
  526. if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
  527. # SWIG 3.0 or later require for C++11 support.
  528. find_package( SWIG 3.0 REQUIRED )
  529. include( ${SWIG_USE_FILE} )
  530. if( KICAD_SCRIPTING_PYTHON3 )
  531. set( PythonInterp_FIND_VERSION 3.3 )
  532. set( PythonLibs_FIND_VERSION 3.3 )
  533. else()
  534. # force a python version < 3.0
  535. set( PythonInterp_FIND_VERSION 2.6 )
  536. set( PythonLibs_FIND_VERSION 2.6 )
  537. endif()
  538. find_package( PythonInterp )
  539. check_find_package_result( PYTHONINTERP_FOUND "Python Interpreter" )
  540. if( NOT KICAD_SCRIPTING_PYTHON3 AND NOT PYTHON_VERSION_MAJOR EQUAL 2 )
  541. message( FATAL_ERROR "Python 2.x is required." )
  542. endif()
  543. # Get the correct Python site package install path from the Python interpreter found by
  544. # FindPythonInterp unless the user specifically defined a custom path.
  545. if( NOT PYTHON_SITE_PACKAGE_PATH )
  546. execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig;print(\"%s\"%distutils.sysconfig.get_python_lib(plat_specific=0, standard_lib=0, prefix=''))"
  547. OUTPUT_VARIABLE PYTHON_SITE_PACKAGE_PATH
  548. OUTPUT_STRIP_TRAILING_WHITESPACE
  549. )
  550. if( NOT PYTHON_SITE_PACKAGE_PATH )
  551. message( FATAL_ERROR "Error occurred while attempting to find the Python site library path." )
  552. endif()
  553. endif()
  554. if( NOT APPLE )
  555. set( PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}"
  556. CACHE PATH "Python module install path."
  557. )
  558. else()
  559. # relative path for python in bundle
  560. set( PYTHON_LIB_DIR "python/site-packages" )
  561. # install into bundle Frameworks folder
  562. set( PYTHON_DEST "${OSX_BUNDLE_BUILD_LIB_DIR}/${PYTHON_LIB_DIR}"
  563. CACHE PATH "Python module install path."
  564. )
  565. endif()
  566. mark_as_advanced( PYTHON_DEST )
  567. message( STATUS "Python module install path: ${PYTHON_DEST}" )
  568. if( KICAD_SCRIPTING_PYTHON3 )
  569. find_package( PythonLibs 3.3 REQUIRED )
  570. else()
  571. find_package( PythonLibs 2.6 REQUIRED )
  572. endif()
  573. if( KICAD_SCRIPTING_WXPYTHON )
  574. find_package( wxPython REQUIRED )
  575. message( STATUS "Found ${WXPYTHON_FLAVOR} "
  576. "${WXPYTHON_VERSION}/${WXPYTHON_TOOLKIT} "
  577. "(wxWidgets ${WXPYTHON_WXVERSION})" )
  578. endif()
  579. # Infrequently needed headers go at end of search paths, append to INC_AFTER which
  580. # although is used for all components, should be a harmless hit for something like eeschema
  581. # so long as unused search paths are at the end like this.
  582. set( INC_AFTER ${INC_AFTER} ${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/scripting )
  583. endif()
  584. #
  585. # Find wxWidgets library, required
  586. #
  587. # Turn on wxWidgets compatibility mode for some classes
  588. add_definitions( -DWX_COMPATIBILITY )
  589. if( KICAD_SCRIPTING_WXPYTHON )
  590. # Check if '--toolkit=xxx' option has been passed
  591. string( REGEX MATCH "--toolkit=([a-zA-Z0-9]+)"
  592. WXWIDGETS_REQUESTED_TOOLKIT "${wxWidgets_CONFIG_OPTIONS}" )
  593. if( WXWIDGETS_REQUESTED_TOOLKIT
  594. AND NOT WXWIDGETS_REQUESTED_TOOLKIT STREQUAL "--toolkit=${WXPYTHON_TOOLKIT}" )
  595. message( WARNING "wxWidgets and wxPython must be based on the same toolkit.\n"
  596. "It will be fixed automatically if you skip the '--toolkit=xxx' "
  597. "wxWidgets_CONFIG_OPTIONS parameter.")
  598. else()
  599. # Use the same toolkit as wxPython otherwise there will be a symbol conflict
  600. set( wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} "--toolkit=${WXPYTHON_TOOLKIT}" )
  601. endif()
  602. # Require the same wxWidgets version as is used by wxPython
  603. set( wxWidgets_REQ_VERSION ${WXPYTHON_WXVERSION} )
  604. else()
  605. # Require wxWidgets 3.0.0 as the minimum when wxPython is disabled
  606. set( wxWidgets_REQ_VERSION 3.0.0 )
  607. endif()
  608. # See line 49 of CMakeModules/FindwxWidgets.cmake
  609. set( wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} --static=no )
  610. find_package( wxWidgets ${wxWidgets_REQ_VERSION} COMPONENTS gl aui adv html core net base xml stc REQUIRED )
  611. # Include wxWidgets macros.
  612. include( ${wxWidgets_USE_FILE} )
  613. # Check for GTK3 libraries - These do not have XOR, so we need overlay (Page layout editor)
  614. if( wxWidgets_LIBRARIES MATCHES "gtk3" )
  615. add_definitions( -DUSE_WX_OVERLAY )
  616. endif()
  617. if( KICAD_SCRIPTING_WXPYTHON AND NOT KICAD_SCRIPTING_WXPYTHON_PHOENIX )
  618. # wxPython appears to be installed and valid so make sure the headers are available.
  619. foreach( path ${wxWidgets_INCLUDE_DIRS} )
  620. #message( STATUS "Searching for wx/wxPython/wxPython.h in ${path}" )
  621. find_path( wxPYTHON_INCLUDE_DIRS wx/wxPython/wxPython.h
  622. PATHS "${path}" )
  623. if( wxPYTHON_INCLUDE_DIRS )
  624. message( STATUS "Found wxPython.h in ${path}/wx/wxPython" )
  625. break()
  626. endif()
  627. endforeach()
  628. if( NOT wxPYTHON_INCLUDE_DIRS )
  629. message( FATAL_ERROR "Cannot find wxPython.h" )
  630. endif()
  631. endif()
  632. if( APPLE )
  633. # Remove app bundles in ${KICAD_BIN} before installing anything new.
  634. # Must be defined before all includes so that it is executed first.
  635. install( CODE "
  636. message( STATUS \"Removing existing application bundles...\" )
  637. # Remove links to standalone apps
  638. file( REMOVE ${KICAD_BIN}/bitmap2component.app )
  639. file( REMOVE ${KICAD_BIN}/eeschema.app )
  640. file( REMOVE ${KICAD_BIN}/gerbview.app )
  641. file( REMOVE ${KICAD_BIN}/pcb_calculator.app )
  642. file( REMOVE ${KICAD_BIN}/pcbnew.app )
  643. file( REMOVE ${KICAD_BIN}/pl_editor.app )
  644. # Remove main bundle
  645. file( REMOVE_RECURSE ${KICAD_BIN}/${OSX_BUNDLE_MAIN} )
  646. " COMPONENT Runtime
  647. )
  648. endif()
  649. #================================================
  650. # Doxygen Output
  651. #================================================
  652. find_package( Doxygen )
  653. if( DOXYGEN_FOUND )
  654. add_custom_target( doxygen-docs
  655. ${CMAKE_COMMAND} -E remove_directory Documentation/doxygen
  656. COMMAND ${DOXYGEN_EXECUTABLE}
  657. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  658. DEPENDS Doxyfile
  659. COMMENT "building doxygen docs into directory Documentation/doxygen/html"
  660. )
  661. add_custom_target( dev-docs
  662. ${CMAKE_COMMAND} -E remove_directory Documentation/development/doxygen
  663. COMMAND ${DOXYGEN_EXECUTABLE}
  664. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Documentation/development
  665. DEPENDS Doxyfile
  666. COMMENT "building developer's resource docs into directory Documentation/development/doxygen/html"
  667. )
  668. add_subdirectory(Documentation/docset)
  669. else()
  670. message( STATUS "WARNING: Doxygen not found - doxygen-docs (Source Docs) target not created" )
  671. endif()
  672. # Generate config.h.
  673. configure_file( ${PROJECT_SOURCE_DIR}/CMakeModules/config.h.cmake
  674. ${CMAKE_BINARY_DIR}/config.h )
  675. ###
  676. # Generate Map file
  677. ###
  678. if( KICAD_MAKE_LINK_MAPS )
  679. # Currently only works on linux/gcc
  680. if( UNIX AND NOT APPLE )
  681. set( MAKE_LINK_MAPS true )
  682. else()
  683. set( MAKE_LINK_MAPS false )
  684. endif()
  685. endif()
  686. #================================================
  687. # "make uninstall" rules
  688. #================================================
  689. configure_file(
  690. "${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
  691. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  692. IMMEDIATE @ONLY )
  693. add_custom_target( uninstall
  694. "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
  695. #================================================
  696. # Installation
  697. #================================================
  698. ###
  699. # Install scripts
  700. ###
  701. if( UNIX AND NOT APPLE )
  702. install( DIRECTORY scripts
  703. DESTINATION ${KICAD_DOCS}
  704. COMPONENT resources
  705. PATTERN "*.bat" EXCLUDE
  706. )
  707. endif()
  708. ###
  709. # FreeDesktop .desktop and MIME resources
  710. ###
  711. if( UNIX AND NOT APPLE )
  712. # Set paths
  713. set( UNIX_MIME_DIR resources/linux/mime )
  714. set( UNIX_MIME_FILES ${UNIX_MIME_DIR}/mime )
  715. set( UNIX_ICON_FILES ${UNIX_MIME_DIR}/icons )
  716. set( UNIX_APPLICATIONS_FILES ${UNIX_MIME_DIR}/applications )
  717. set( UNIX_APPDATA_FILES resources/linux/appdata )
  718. # Install Mime directory
  719. install( DIRECTORY ${UNIX_ICON_FILES}
  720. DESTINATION share
  721. COMPONENT resources
  722. )
  723. # Install Icons
  724. install( DIRECTORY ${UNIX_MIME_FILES}
  725. DESTINATION share
  726. COMPONENT resources
  727. )
  728. # Install Applications directory (.desktop files)
  729. install( DIRECTORY ${UNIX_APPLICATIONS_FILES}
  730. DESTINATION share
  731. COMPONENT resources
  732. )
  733. # Install AppStream directory (app store entry)
  734. install( DIRECTORY ${UNIX_APPDATA_FILES}
  735. DESTINATION share
  736. COMPONENT resources
  737. )
  738. endif()
  739. #include( CTest )
  740. enable_testing()
  741. if( UNIX AND NOT APPLE )
  742. # Create a *.deb file:
  743. set( CPACK_GENERATOR "DEB" )
  744. set( CPACK_DEBIAN_PACKAGE_MAINTAINER "http://launchpad.net/kicad" )
  745. set( CPACK_PACKAGE_VERSION_MAJOR 1 )
  746. set( CPACK_PACKAGE_VERSION_MINOR 0 )
  747. set( CPACK_PACKAGE_VERSION_PATCH 0 )
  748. #set( CPACK_PACKAGE_CONTACT Firstname Lastname <email@company.com> )
  749. set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "KiCad built by CMake build system." )
  750. include( CPack )
  751. endif()
  752. #================================================
  753. # Let CMake look in these directories for nested
  754. # 'CMakeLists.txt' files to process
  755. #================================================
  756. # Binaries ( CMake targets )
  757. add_subdirectory( bitmaps_png )
  758. add_subdirectory( libs )
  759. add_subdirectory( common )
  760. add_subdirectory( 3d-viewer )
  761. add_subdirectory( cvpcb )
  762. add_subdirectory( eeschema )
  763. add_subdirectory( gerbview )
  764. add_subdirectory( dxflib_qcad )
  765. add_subdirectory( pcbnew )
  766. add_subdirectory( polygon )
  767. add_subdirectory( pagelayout_editor )
  768. add_subdirectory( potrace )
  769. add_subdirectory( bitmap2component )
  770. add_subdirectory( pcb_calculator )
  771. add_subdirectory( plugins ) # 3D plugins must be built before kicad
  772. add_subdirectory( kicad ) # should follow pcbnew, eeschema
  773. add_subdirectory( tools )
  774. add_subdirectory( utils )
  775. add_subdirectory( qa )
  776. # Resources
  777. if ( KICAD_INSTALL_DEMOS )
  778. add_subdirectory( demos )
  779. endif ( KICAD_INSTALL_DEMOS )
  780. add_subdirectory( template )