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.

1002 lines
36 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
* 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-2020 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 3.2 FATAL_ERROR )
  24. # Default to CMAKE_BUILD_TYPE = Release unless overridden on command line
  25. # http://www.cmake.org/pipermail/cmake/2008-September/023808.html
  26. if( DEFINED CMAKE_BUILD_TYPE )
  27. set( CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Set to either \"Release\" or \"Debug\"" )
  28. else()
  29. set( CMAKE_BUILD_TYPE Release CACHE STRING "Set to either \"Release\" or \"Debug\"" )
  30. endif()
  31. project( kicad )
  32. include( GNUInstallDirs )
  33. # Path to local CMake modules.
  34. set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules )
  35. # On Windows, binaries created by link option -g3 are very large (more than 1Gb for pcbnew,
  36. # and more than 3Gb for the full kicad suite)
  37. # This option create binaries using link option -g1 that create much smaller files, but
  38. # there are less info in debug (but the file names and line numbers are available)
  39. option( BUILD_SMALL_DEBUG_FILES "In debug build: create smaller binaries." OFF )
  40. #
  41. # KiCad build options should be added below.
  42. #
  43. # If you add a new build option, please add it's state to the
  44. # OnCopyVersionInfo() function in common/dialog_about/dialog_about.cpp
  45. # so that build option settings can be included in bug reports.
  46. #
  47. option( KICAD_SCRIPTING
  48. "Build the Python scripting support inside KiCad binaries (default ON)."
  49. ON )
  50. option( KICAD_SCRIPTING_MODULES
  51. "Build native portion of the pcbnew Python module: _pcbnew.{pyd,so} for OS command line use of Python."
  52. ON )
  53. option( KICAD_SCRIPTING_PYTHON3
  54. "Build for Python 3 instead of 2 (default OFF)."
  55. OFF )
  56. option( KICAD_SCRIPTING_WXPYTHON
  57. "Build wxPython implementation for wx interface building in Python and py.shell (default ON)."
  58. ON )
  59. option( KICAD_SCRIPTING_WXPYTHON_PHOENIX
  60. "Use new wxPython binding (default OFF)."
  61. OFF )
  62. option( KICAD_SCRIPTING_ACTION_MENU
  63. "Build a tools menu with registered python plugins: actions plugins (default ON)."
  64. ON )
  65. option( KICAD_USE_OCE
  66. "Build tools and plugins related to OpenCascade Community Edition (default ON)"
  67. ON )
  68. option( KICAD_USE_OCC
  69. "Build tools and plugins related to OpenCascade Technology (overrides KICAD_USE_OCE, default OFF)"
  70. OFF )
  71. option( KICAD_INSTALL_DEMOS
  72. "Install KiCad demos and examples (default ON)"
  73. ON )
  74. option( KICAD_BUILD_QA_TESTS
  75. "Build software Quality assurance unit tests (default ON)"
  76. ON )
  77. option( BUILD_GITHUB_PLUGIN
  78. "Build the GITHUB_PLUGIN for pcbnew."
  79. ON )
  80. option( KICAD_SPICE
  81. "Build KiCad with internal Spice simulator."
  82. ON )
  83. # Not supported by all platforms (for instance mingw)
  84. option( KICAD_SANITIZE
  85. "Build KiCad with sanitizer options. WARNING: Not compatible with gold linker"
  86. OFF )
  87. option( KICAD_STDLIB_DEBUG
  88. "Build KiCad with libstdc++ debug flags enabled."
  89. OFF )
  90. option( KICAD_STDLIB_LIGHT_DEBUG
  91. "Build KiCad with libstdc++ with -Wp,-D_GLIBCXX_ASSERTIONS flag enabled. Not as intrusive as KICAD_STDLIB_DEBUG"
  92. OFF )
  93. option( KICAD_BUILD_PARALLEL_CL_MP
  94. "Build in parallel using the /MP compiler option (default OFF for safety reasons)"
  95. OFF )
  96. option( KICAD_USE_VALGRIND
  97. "Build KiCad with valgrind stack tracking enabled."
  98. OFF )
  99. option( KICAD_NETLIST_QA
  100. "Run eeschema netlist QA tests (requires Python 3)"
  101. OFF )
  102. # when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
  103. # PYTHON_EXECUTABLE can be defined when invoking cmake
  104. # ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
  105. # when not defined by user, the default is python.exe under Windows and python2 for others
  106. # python binary file should be in exec path.
  107. # KICAD_SCRIPTING controls the entire python scripting system. If it is off, no other scripting
  108. # functions are available.
  109. if ( NOT KICAD_SCRIPTING )
  110. message( STATUS "KICAD_SCRIPTING is OFF: Disabling all python scripting support" )
  111. set( KICAD_SCRIPTING_MODULES OFF )
  112. set( KICAD_SCRIPTING_ACTION_MENU OFF )
  113. set( KICAD_SCRIPTING_PYTHON3 OFF )
  114. set( KICAD_SCRIPTING_WXPYTHON OFF )
  115. set( KICAD_SCRIPTING_WXPYTHON_PHOENIX OFF)
  116. endif()
  117. # KICAD_SCRIPTING_WXPYTHON_PHOENIX requires enabling the KICAD_SCRIPTING_WXPYTHON flag
  118. # so that the wxWidgets library is properly versioned
  119. if ( KICAD_SCRIPTING AND NOT KICAD_SCRIPTING_WXPYTHON AND KICAD_SCRIPTING_WXPYTHON_PHOENIX )
  120. message( STATUS
  121. "KICAD_SCRIPTING_WXPYTHON_PHOENIX has been requested, setting KICAD_SCRIPTING_WXPYTHON to ON")
  122. set( KICAD_SCRIPTING_WXPYTHON ON)
  123. endif()
  124. # Global setting: exports are explicit
  125. set( CMAKE_CXX_VISIBILITY_PRESET "hidden" )
  126. set( CMAKE_VISIBILITY_INLINES_HIDDEN ON )
  127. # Global setting: build everything position independent
  128. set( CMAKE_POSITION_INDEPENDENT_CODE ON )
  129. # Global setting: Use C++14
  130. set(CMAKE_CXX_STANDARD 14)
  131. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  132. # Enable additional valgrind instrumentation for stack tracking in libcontext
  133. if( KICAD_USE_VALGRIND )
  134. add_definitions( -DKICAD_USE_VALGRIND )
  135. endif()
  136. # Ensure DEBUG is defined for all platforms in Debug builds
  137. # change to add_compile_definitions() after minimum required CMake version is 3.12
  138. set_property( DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$<CONFIG:Debug>:DEBUG> )
  139. # CMP0063: CMake < 3.3 does not handle hidden visibility for static libraries,
  140. # and 3.3 is backwards compatible when the minimum version is smaller than 3.3.
  141. if( POLICY CMP0063 )
  142. cmake_policy( GET CMP0063 VISIBILITY_POLICY )
  143. if( VISIBILITY_POLICY STREQUAL NEW )
  144. message( WARNING "Compatibility code for CMake < 3.3 can be removed, search for CMP0063" )
  145. else()
  146. cmake_policy( SET CMP0063 NEW )
  147. endif()
  148. else()
  149. if( CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY AND NOT APPLE )
  150. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY}hidden" )
  151. endif()
  152. if( CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN AND NOT APPLE )
  153. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN}" )
  154. endif()
  155. endif()
  156. # Add option to add user directories for linker, if any
  157. LINK_DIRECTORIES( ${LINK_DIRECTORIES_PATH} )
  158. set( KICAD_CONFIG_DIR "kicad" CACHE STRING "Location of user specific KiCad config files" )
  159. mark_as_advanced( KICAD_CONFIG_DIR )
  160. add_definitions( -DKICAD_CONFIG_DIR=${KICAD_CONFIG_DIR} )
  161. # Set default data file path to CMAKE_INSTALL_PREFIX if it wasn't specified during the
  162. # CMake configuration. The value of DEFAULT_INSTALL_PATH is expanded in config.h and
  163. # used in the source code to define the base path for kicad search paths and environment
  164. # variables.
  165. if( NOT DEFAULT_INSTALL_PATH )
  166. set( DEFAULT_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}"
  167. CACHE
  168. PATH
  169. "Location of KiCad data files." )
  170. endif()
  171. message( STATUS "KiCad install dir: <${DEFAULT_INSTALL_PATH}>" )
  172. # Generate build system specific header file.
  173. include( PerformFeatureChecks )
  174. perform_feature_checks()
  175. # Setup the compiler warnings
  176. include( ${CMAKE_MODULE_PATH}/Warnings.cmake )
  177. if( WIN32 )
  178. # define UNICODE and_UNICODE definition on Windows. KiCad uses unicode.
  179. # Both definitions are required
  180. add_definitions(-DUNICODE -D_UNICODE)
  181. # In fully standards-compliant mode, M_PI et al. are defined only if
  182. # _USE_MATH_DEFINES is set.
  183. add_definitions( -D_USE_MATH_DEFINES )
  184. endif()
  185. #================================================
  186. # Provide access to CCACHE
  187. #================================================
  188. if (USE_CCACHE)
  189. find_program(CCACHE_FOUND ccache)
  190. if(CCACHE_FOUND)
  191. get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
  192. set(RULE_LAUNCH_COMPILE "${RULE_LAUNCH_COMPILE} ${CCACHE_FOUND}")
  193. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH_COMPILE})
  194. get_property(RULE_LAUNCH_LINK GLOBAL PROPERTY RULE_LAUNCH_LINK)
  195. set(RULE_LAUNCH_LINK "${RULE_LAUNCH_LINK} ${CCACHE_FOUND}")
  196. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${RULE_LAUNCH_LINK})
  197. message(STATUS "Used ${CCACHE_FOUND} for compilation.")
  198. else(CCACHE_FOUND)
  199. message(STATUS "CCache was requested but not found.")
  200. endif(CCACHE_FOUND)
  201. endif(USE_CCACHE)
  202. #================================================
  203. # Provide access to DISTCC
  204. #================================================
  205. if (USE_DISTCC)
  206. find_program(DISTCC_FOUND distcc)
  207. if(DISTCC_FOUND)
  208. get_property(RULE_LAUNCH_COMPILE GLOBAL PROPERTY RULE_LAUNCH_COMPILE)
  209. set(RULE_LAUNCH_COMPILE "${RULE_LAUNCH_COMPILE} ${DISTCC_FOUND}")
  210. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${RULE_LAUNCH_COMPILE})
  211. message(STATUS "Using ${DISTCC_FOUND} for distributed build.")
  212. else(DISTCC_FOUND)
  213. message(INFO "Distcc was requested but not found.")
  214. endif(DISTCC_FOUND)
  215. endif(USE_DISTCC)
  216. #================================================
  217. # Set flags for GCC, or treat llvm as GCC
  218. #================================================
  219. if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  220. # Set 32-bit flag for GCC to prevent excess precision
  221. if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
  222. set( CMAKE_CXX_FLAGS "-ffloat-store ${CMAKE_CXX_FLAGS}" )
  223. endif()
  224. # Link flags in Debug: -g1 and -ggdb1 or -g1 and -ggdb3 can be used.
  225. # Level 1 produces minimal information, enough for making basic backtraces.
  226. # This includes descriptions of functions and external variables, and line number tables,
  227. # but no information about local variables.
  228. # Level 3 includes full information, but binaries are much larger.
  229. if( BUILD_SMALL_DEBUG_FILES )
  230. set( CMAKE_C_FLAGS_DEBUG "-g1 -ggdb1" )
  231. set( CMAKE_CXX_FLAGS_DEBUG "-g1 -ggdb1" )
  232. else()
  233. set( CMAKE_C_FLAGS_DEBUG "-g3 -ggdb3" )
  234. set( CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3" )
  235. endif()
  236. if( KICAD_SANITIZE )
  237. add_definitions( -DKICAD_SANITIZE )
  238. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_SANITIZE_VECTOR -fsanitize=address -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-pointer" )
  239. # ASAN shouldn't be used with these options (https://github.com/google/sanitizers/wiki/AddressSanitizer#faq)
  240. set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-stack-protector -U_FORTIFY_SOURCE" )
  241. endif()
  242. if( KICAD_STDLIB_DEBUG )
  243. add_definitions( -DKICAD_STDLIB_DEBUG )
  244. set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_GLIBCXX_DEBUG" )
  245. elseif( KICAD_STDLIB_LIGHT_DEBUG )
  246. # useless if KICAD_STDLIB_DEBUG is ON.
  247. # this option makes some controls to trap out of bound memory access.
  248. add_definitions( -DKICAD_STDLIB_LIGHT_DEBUG )
  249. set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wp,-D_GLIBCXX_ASSERTIONS" )
  250. endif()
  251. if( MINGW )
  252. set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
  253. # Since version 2.8.5, Cmake uses a response file (.rsp) to
  254. # pass the list of include paths to gcc
  255. # unfortunately, under mingw32+msys, at least with gcc 4.8 and previous,
  256. # this file is not always expanded and in this case include paths defined in this file
  257. # are not taken in account ( this is the case of wxWidgets includes )
  258. # If it is the case, disable this response file for includes ( See Windows-GNU.cmake module )
  259. if( false ) #set to true to disable the include response file
  260. if( WIN32 AND MSYS AND NOT CMAKE_CROSSCOMPILING )
  261. # fixme: it is needed only with MSYS+MINGW32? or always under MINGW
  262. if( ${CMAKE_SIZEOF_VOID_P} MATCHES 4 )
  263. set( CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0 )
  264. endif()
  265. endif()
  266. endif()
  267. # for some reasons, cmake does do use always a response file to send the list of objects
  268. # to the archiver, and because this list can be very long, and can create issue
  269. # when it is used in a command line, force use of a response file to store it
  270. SET( CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1 )
  271. # The MinGW compiler can use the microsoft system snprintf as standard and it has a broken
  272. # API with respect to the C99 standard, so make sure we force it to use its own compliant
  273. # snprintf
  274. add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
  275. # Allow linking for Boost for the UUID against bcrypt
  276. set( EXTRA_LIBS "bcrypt" )
  277. elseif( NOT APPLE )
  278. # Thou shalt not link vaporware and tell us it's a valid DSO (apple ld doesn't support it)
  279. # temporarily disabled due to breaking ASAN-enabled builds - Tom
  280. # set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
  281. # set( CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined" )
  282. set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
  283. endif()
  284. if( APPLE )
  285. set( CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -headerpad_max_install_names") # needed by fixbundle
  286. endif()
  287. endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
  288. if( MSVC )
  289. # Disallow implicit linking for Boost
  290. add_definitions( -DBOOST_ALL_NO_LIB )
  291. # But allow it for the UUID so that it will link against bcrypt
  292. add_definitions( -DBOOST_UUID_FORCE_AUTO_LINK )
  293. # Disable MSVC's deprecation warnings
  294. add_definitions( -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS )
  295. # Hide Windows's min() and max() macros
  296. add_definitions( -DNOMINMAX )
  297. # source and execution charset are UTF-8
  298. string( APPEND CMAKE_CXX_FLAGS " /utf-8" )
  299. # C4290: throw() is interpreted as declspec(nothrow)
  300. string( APPEND CMAKE_CXX_FLAGS " /wd4290" )
  301. # C4800: non-bool is explicitly cast to bool, forcing value of 0 or 1
  302. string( APPEND CMAKE_CXX_FLAGS " /wd4800" )
  303. # /Zi: create PDB
  304. string( APPEND CMAKE_CXX_FLAGS " /Zi" )
  305. # /GF: enable string pooling
  306. string( APPEND CMAKE_CXX_FLAGS_RELEASE " /GF" )
  307. foreach( type EXE SHARED MODULE)
  308. # /DEBUG: create PDB
  309. string( APPEND CMAKE_${type}_LINKER_FLAGS " /DEBUG" )
  310. # /OPT:REF: omit unreferenced code
  311. string( APPEND CMAKE_${type}_LINKER_FLAGS_RELEASE " /OPT:REF" )
  312. # /OPT:ICF: fold common data
  313. string( APPEND CMAKE_${type}_LINKER_FLAGS_RELEASE " /OPT:ICF" )
  314. endforeach()
  315. # Let cl.exe parallelize builds
  316. if( KICAD_BUILD_PARALLEL_CL_MP )
  317. string( APPEND CMAKE_CXX_FLAGS " /MP" )
  318. endif()
  319. endif()
  320. if( KICAD_SCRIPTING )
  321. add_definitions( -DKICAD_SCRIPTING )
  322. endif()
  323. if( KICAD_SCRIPTING_MODULES )
  324. add_definitions( -DKICAD_SCRIPTING_MODULES )
  325. endif()
  326. if( KICAD_SCRIPTING_PYTHON3 )
  327. add_definitions( -DKICAD_SCRIPTING_PYTHON3 )
  328. endif()
  329. if( KICAD_SCRIPTING_WXPYTHON )
  330. add_definitions( -DKICAD_SCRIPTING_WXPYTHON )
  331. endif()
  332. if( KICAD_SCRIPTING_WXPYTHON_PHOENIX )
  333. add_definitions( -DKICAD_SCRIPTING_WXPYTHON_PHOENIX )
  334. endif()
  335. if( KICAD_SCRIPTING_ACTION_MENU )
  336. add_definitions( -DKICAD_SCRIPTING_ACTION_MENU )
  337. endif()
  338. if( KICAD_SPICE )
  339. add_definitions( -DKICAD_SPICE )
  340. endif()
  341. if( KICAD_USE_OCE )
  342. add_definitions( -DKICAD_USE_OCE )
  343. endif()
  344. if( KICAD_USE_OCC )
  345. add_definitions( -DKICAD_USE_OCC )
  346. remove_definitions( -DKICAD_USE_OCE )
  347. unset( KICAD_USE_OCE CACHE )
  348. endif()
  349. if( KICAD_USE_CUSTOM_PADS )
  350. add_definitions( -DKICAD_USE_CUSTOM_PADS )
  351. endif()
  352. # KIFACE_SUFFIX is the file extension used for top level program modules which
  353. # implement the KIFACE interface. A valid suffix starts with a period '.'.
  354. if( false )
  355. # This is the eventual situation near milestone C) of modular-kicad blueprint.
  356. # Until then we use .kiface extension so we don't collide with python DSO.
  357. set( KIFACE_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX} )
  358. else()
  359. # Temporary situation until we can dovetail the python DSO into the kiface DSO.
  360. set( KIFACE_SUFFIX ".kiface" )
  361. endif()
  362. # KIFACE_PREFIX is a basename prefix used for top level program modules which
  363. # implement the KIFACE.
  364. set( KIFACE_PREFIX "_" )
  365. #message( STATUS "KIFACE_SUFFIX:${KIFACE_SUFFIX} KIFACE_PREFIX:${KIFACE_PREFIX}" )
  366. #================================================
  367. # Locations for install targets.
  368. #================================================
  369. if( NOT APPLE )
  370. # Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
  371. set( KICAD_BIN bin
  372. CACHE PATH "Location of KiCad binaries." )
  373. set( KICAD_DATA ${CMAKE_INSTALL_DATADIR}/kicad
  374. CACHE PATH "Location of KiCad data files." )
  375. if( WIN32 )
  376. set( KICAD_PLUGINS ${KICAD_BIN}/scripting/plugins
  377. CACHE PATH "Location of KiCad plugins." )
  378. set( KICAD_LIB ${KICAD_BIN}
  379. CACHE PATH "Location of KiCad shared objects" )
  380. set( KICAD_USER_PLUGIN ${KICAD_BIN}/plugins
  381. CACHE PATH "Location of KiCad user-loaded plugins" )
  382. else()
  383. set( KICAD_PLUGINS ${KICAD_DATA}/plugins
  384. CACHE PATH "Location of KiCad plugins." )
  385. set( KICAD_LIB ${CMAKE_INSTALL_LIBDIR}
  386. CACHE PATH "Location of KiCad shared objects" )
  387. set( KICAD_USER_PLUGIN ${CMAKE_INSTALL_LIBDIR}/kicad/plugins
  388. CACHE PATH "Location of KiCad user-loaded plugins" )
  389. endif()
  390. set( KICAD_DOCS ${CMAKE_INSTALL_DATADIR}/doc/kicad
  391. CACHE PATH "Location of KiCad documentation files." )
  392. set( KICAD_DEMOS ${KICAD_DATA}/demos
  393. CACHE PATH "Location of KiCad demo files." )
  394. set( KICAD_TEMPLATE ${KICAD_DATA}/template
  395. CACHE PATH "Location of KiCad template files." )
  396. else()
  397. # everything without leading / is relative to CMAKE_INSTALL_PREFIX.
  398. # CMAKE_INSTALL_PREFIX is root of .dmg image
  399. set( KICAD_BIN ${CMAKE_INSTALL_PREFIX}
  400. CACHE PATH "Location of KiCad binaries." FORCE )
  401. # some paths to single app bundle
  402. set( OSX_BUNDLE_MAIN "kicad.app" )
  403. set( OSX_BUNDLE_BIN_DIR "Contents/MacOS" )
  404. set( OSX_BUNDLE_LIB_DIR "Contents/Frameworks" )
  405. set( OSX_BUNDLE_KIFACE_DIR "Contents/PlugIns" )
  406. set( OSX_BUNDLE_SUP_DIR "Contents/SharedSupport" )
  407. set( OSX_BUNDLE_APP_DIR "Contents/Applications" )
  408. set( OSX_BUNDLE_BUILD_DIR "${CMAKE_BINARY_DIR}/kicad/${OSX_BUNDLE_MAIN}" )
  409. set( OSX_BUNDLE_BUILD_BIN_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_BIN_DIR}" )
  410. set( OSX_BUNDLE_BUILD_LIB_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_LIB_DIR}" )
  411. set( OSX_BUNDLE_BUILD_KIFACE_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
  412. set( OSX_BUNDLE_BUILD_PLUGIN_DIR "${OSX_BUNDLE_BUILD_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
  413. set( OSX_BUNDLE_INSTALL_DIR "${KICAD_BIN}/${OSX_BUNDLE_MAIN}" )
  414. set( OSX_BUNDLE_INSTALL_BIN_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_BIN_DIR}" )
  415. set( OSX_BUNDLE_INSTALL_LIB_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_LIB_DIR}" )
  416. set( OSX_BUNDLE_INSTALL_KIFACE_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
  417. set( OSX_BUNDLE_INSTALL_PLUGIN_DIR "${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_KIFACE_DIR}" )
  418. # everything provided with the application bundle goes into
  419. # kicad.app/Contents/SharedSupport => accessible via GetDataDir()
  420. # everything else to the .dmg image
  421. set( KICAD_DATA ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_SUP_DIR}
  422. CACHE PATH "Location of KiCad data files." FORCE )
  423. set( KICAD_LIB ${OSX_BUNDLE_INSTALL_DIR}/${OSX_BUNDLE_LIB_DIR}
  424. CACHE PATH "Location of KiCad shared objects" FORCE )
  425. set( KICAD_USER_PLUGIN ${OSX_BUNDLE_INSTALL_PLUGIN_DIR}
  426. CACHE PATH "Location of KiCad user-loaded plugins" FORCE )
  427. set( KICAD_TEMPLATE ${KICAD_DATA}/template
  428. CACHE PATH "Location of KiCad template files." FORCE )
  429. set( KICAD_PLUGINS ${KICAD_DATA}/plugins
  430. CACHE PATH "Location of KiCad plugins." FORCE )
  431. set( KICAD_DOCS doc
  432. CACHE PATH "Location of KiCad documentation files." FORCE )
  433. set( KICAD_DEMOS demos
  434. CACHE PATH "Location of KiCad demo files." FORCE )
  435. # RPATH setttings for building shared libraries
  436. set( CMAKE_MACOSX_RPATH FALSE )
  437. # Override default paths for fixup_bundle
  438. set( OSX_BUNDLE_OVERRIDE_PATHS "
  439. function( gp_item_default_embedded_path_override item default_embedded_path_var )
  440. # by default, embed things right next to the main bundle executable:
  441. set( path \"@executable_path/../../Contents/MacOS\" )
  442. set( overridden 0 )
  443. # embed .dylibs right next to the main bundle executable:
  444. if( item MATCHES \"\\\\.dylib$\" )
  445. set( path \"@executable_path/../Frameworks\" )
  446. set( overridden 1 )
  447. endif()
  448. set( \${default_embedded_path_var} \"\${path}\" PARENT_SCOPE )
  449. endfunction(gp_item_default_embedded_path_override)
  450. # If `BU_CHMOD_BUNDLE_ITEMS` is not set, `install_name_tool` will fail to re-write some
  451. # loader paths due to lack of writable permissions if the build dependencies were installed
  452. # by brew (or didn't have writable permissions)
  453. set ( BU_CHMOD_BUNDLE_ITEMS ON )
  454. "
  455. )
  456. endif()
  457. mark_as_advanced( KICAD_BIN
  458. KICAD_PLUGINS
  459. KICAD_USER_PLUGIN
  460. KICAD_LIB
  461. KICAD_DATA
  462. KICAD_DOCS
  463. KICAD_DEMOS
  464. KICAD_TEMPLATE )
  465. include( Functions )
  466. include( ExternalProject )
  467. #================================================
  468. # Find libraries that are needed to build KiCad.
  469. #================================================
  470. include( CheckFindPackageResult )
  471. #
  472. # Find OpenGL library, required
  473. #
  474. set( OpenGL_GL_PREFERENCE "LEGACY" ) # CMake 3.11+ setting; see 'cmake --help-policy CMP0072'
  475. find_package( OpenGL REQUIRED )
  476. #
  477. # Find GLEW library, required
  478. #
  479. if( NOT GLEW_FOUND )
  480. find_package( GLEW REQUIRED )
  481. check_find_package_result( GLEW_FOUND "GLEW" )
  482. include_directories( SYSTEM ${GLEW_INCLUDE_DIR} )
  483. endif()
  484. #
  485. # Find GLM library, required
  486. #
  487. find_package( GLM 0.9.8 REQUIRED )
  488. add_definitions( -DGLM_FORCE_CTOR_INIT )
  489. include_directories( SYSTEM ${GLM_INCLUDE_DIR} )
  490. #
  491. # Find zlib library, required
  492. #
  493. find_package(ZLIB REQUIRED)
  494. check_find_package_result( ZLIB_FOUND "ZLIB" )
  495. include_directories( SYSTEM ${ZLIB_INCLUDE_DIRS} )
  496. #
  497. # Find CURL library, required
  498. #
  499. find_package( CURL REQUIRED )
  500. include_directories( SYSTEM ${CURL_INCLUDE_DIRS} )
  501. #
  502. # Find Cairo library, required
  503. #
  504. find_package( Cairo 1.12 REQUIRED )
  505. include_directories( SYSTEM ${CAIRO_INCLUDE_DIR} )
  506. find_package( Pixman 0.30 REQUIRED )
  507. include_directories( SYSTEM ${PIXMAN_INCLUDE_DIR} )
  508. #
  509. # Find Boost headers, required.
  510. find_package( Boost 1.59.0 REQUIRED )
  511. include_directories( SYSTEM ${Boost_INCLUDE_DIR} )
  512. # Include MinGW resource compiler.
  513. include( MinGWResourceCompiler )
  514. if( WIN32 )
  515. # we need the gdiplus library for cairo printing on windows
  516. set( GDI_PLUS_LIBRARIES gdiplus )
  517. endif()
  518. # Find ngspice library, required for integrated circuit simulator
  519. if( KICAD_SPICE )
  520. find_package( ngspice REQUIRED )
  521. endif()
  522. # Find OpenCascade Community Edition, required for STEP plugin and tools
  523. if( KICAD_USE_OCE )
  524. set( OCC_LIBRARIES TKBinXCAF TKPCAF TKSTEP TKXDESTEP TKIGES TKXDEIGES )
  525. find_package( OCE 0.18 REQUIRED ${OCC_LIBRARIES} )
  526. include_directories( SYSTEM ${OCE_INCLUDE_DIRS} )
  527. elseif( KICAD_USE_OCC )
  528. find_package(OpenCASCADE)
  529. if( NOT OCC_FOUND )
  530. MESSAGE( FATAL_ERROR "================================================================\n"
  531. " KICAD_USE_OCC=True but OpenCASCADE was not found!\n"
  532. "================================================================\n")
  533. endif()
  534. if( OCC_VERSION_STRING VERSION_LESS 6.9.0 )
  535. MESSAGE( FATAL_ERROR "================================================================\n"
  536. "OpenCASCADE version ${OCC_VERSION_STRING} was found.\n"
  537. " KiCad requires a minimum version of 6.9.0\n"
  538. "================================================================\n")
  539. endif()
  540. include_directories( SYSTEM ${OCC_INCLUDE_DIR} )
  541. endif()
  542. # Assist with header file searching optimization:
  543. # INC_BEFORE and INC_AFTER are two lists which go at the front and back of the
  544. # header file search lists, respectively.
  545. # INC_BEFORE is for use with "include_directories( BEFORE ...)", which _reverses_
  546. # the order during insertion. (So put first wanted last, which is
  547. # ${CMAKE_SOURCE_DIR/include.) Use '.' for current source dir since
  548. # we don't want expansion here and now, which would happen if using ${CMAKE_CURRENT_SOURCE_DIR}.
  549. # Instead we use '.' which is applicable to any source directory below here as a result of
  550. # this lack of expansion.
  551. set( INC_BEFORE
  552. .
  553. ${CMAKE_SOURCE_DIR}/include
  554. )
  555. set( INC_AFTER
  556. ${CMAKE_BINARY_DIR}
  557. )
  558. #
  559. # Find Python and other scripting resources
  560. #
  561. if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
  562. # SWIG 3.0 or later require for C++11 support.
  563. find_package( SWIG 3.0 REQUIRED )
  564. include( ${SWIG_USE_FILE} )
  565. if( KICAD_SCRIPTING_PYTHON3 )
  566. set( PythonInterp_FIND_VERSION 3.3 )
  567. set( PythonLibs_FIND_VERSION 3.3 )
  568. else()
  569. # force a python version < 3.0
  570. set( PythonInterp_FIND_VERSION 2.6 )
  571. set( PythonLibs_FIND_VERSION 2.6 )
  572. endif()
  573. find_package( PythonInterp )
  574. check_find_package_result( PYTHONINTERP_FOUND "Python Interpreter" )
  575. if( NOT KICAD_SCRIPTING_PYTHON3 AND NOT PYTHON_VERSION_MAJOR EQUAL 2 )
  576. message( FATAL_ERROR "Python 2.x is required." )
  577. endif()
  578. # Get the correct Python site package install path from the Python interpreter found by
  579. # FindPythonInterp unless the user specifically defined a custom path.
  580. if( NOT PYTHON_SITE_PACKAGE_PATH )
  581. execute_process( COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig;print(\"%s\"%distutils.sysconfig.get_python_lib(plat_specific=0, standard_lib=0, prefix=''))"
  582. OUTPUT_VARIABLE PYTHON_SITE_PACKAGE_PATH
  583. OUTPUT_STRIP_TRAILING_WHITESPACE
  584. )
  585. if( NOT PYTHON_SITE_PACKAGE_PATH )
  586. message( FATAL_ERROR "Error occurred while attempting to find the Python site library path." )
  587. endif()
  588. endif()
  589. if( NOT APPLE )
  590. set( PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}"
  591. CACHE PATH "Python module install path."
  592. )
  593. else()
  594. # relative path for python in bundle
  595. set( PYTHON_LIB_DIR "python/site-packages" )
  596. # install into bundle Frameworks folder
  597. set( PYTHON_DEST "${OSX_BUNDLE_BUILD_LIB_DIR}/${PYTHON_LIB_DIR}"
  598. CACHE PATH "Python module install path."
  599. )
  600. endif()
  601. mark_as_advanced( PYTHON_DEST )
  602. message( STATUS "Python module install path: ${PYTHON_DEST}" )
  603. if( KICAD_SCRIPTING_PYTHON3 )
  604. find_package( PythonLibs 3.3 REQUIRED )
  605. else()
  606. find_package( PythonLibs 2.6 REQUIRED )
  607. endif()
  608. # Infrequently needed headers go at end of search paths, append to INC_AFTER which
  609. # although is used for all components, should be a harmless hit for something like eeschema
  610. # so long as unused search paths are at the end like this.
  611. set( INC_AFTER ${INC_AFTER} ${PYTHON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/scripting )
  612. endif()
  613. # Find the wxPython installation if requested
  614. if( KICAD_SCRIPTING_WXPYTHON )
  615. find_package( wxPython REQUIRED )
  616. if( KICAD_SCRIPTING_WXPYTHON_PHOENIX AND WXPYTHON_VERSION VERSION_LESS 4.0.0 )
  617. message( FATAL_ERROR
  618. "Unable to find wxPython Phoenix,"
  619. " instead found wxPython Classic ${WXPYTHON_VERSION}" )
  620. endif()
  621. # The test VERSION_GREATER_EQUAL is only available in cmake >3.7, so use the max possible
  622. # version for the 3.0 line as the basis of the comparison
  623. if( NOT KICAD_SCRIPTING_WXPYTHON_PHOENIX AND WXPYTHON_VERSION VERSION_GREATER 3.9.999 )
  624. message( FATAL_ERROR
  625. "Unable to find wxPython Classic,"
  626. " instead found wxPython Phoenix ${WXPYTHON_VERSION}" )
  627. endif()
  628. # GTK3 is required on Linux
  629. if( UNIX AND NOT APPLE )
  630. if( NOT "${WXPYTHON_TOOLKIT}" STREQUAL "gtk3" )
  631. message( FATAL_ERROR "GTK3-based wxPython/Phoenix toolkit is required.")
  632. endif()
  633. endif()
  634. message( STATUS "Found ${WXPYTHON_FLAVOR} "
  635. "${WXPYTHON_VERSION}/${WXPYTHON_TOOLKIT} "
  636. "(wxWidgets ${WXPYTHON_WXVERSION})" )
  637. endif()
  638. #
  639. # Find wxWidgets library, required
  640. #
  641. # Turn on wxWidgets compatibility mode for some classes
  642. add_definitions( -DWX_COMPATIBILITY )
  643. if( KICAD_SCRIPTING_WXPYTHON )
  644. # Check if '--toolkit=xxx' option has been passed
  645. string( REGEX MATCH "--toolkit=([a-zA-Z0-9]+)"
  646. WXWIDGETS_REQUESTED_TOOLKIT "${wxWidgets_CONFIG_OPTIONS}" )
  647. if( WXWIDGETS_REQUESTED_TOOLKIT
  648. AND NOT WXWIDGETS_REQUESTED_TOOLKIT STREQUAL "--toolkit=${WXPYTHON_TOOLKIT}" )
  649. message( WARNING "wxWidgets and wxPython must be based on the same toolkit.\n"
  650. "It will be fixed automatically if you skip the '--toolkit=xxx' "
  651. "wxWidgets_CONFIG_OPTIONS parameter.")
  652. elseif( UNIX AND NOT APPLE )
  653. # Force the use of GTK3 on Linux
  654. set( wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} "--toolkit=gtk3" )
  655. else()
  656. # Use the same toolkit as wxPython otherwise there will be a symbol conflict
  657. set( wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} "--toolkit=${WXPYTHON_TOOLKIT}" )
  658. endif()
  659. # Require the same wxWidgets version as is used by wxPython
  660. set( wxWidgets_REQ_VERSION ${WXPYTHON_WXVERSION} )
  661. else()
  662. # Require wxWidgets 3.0.0 as the minimum when wxPython is disabled
  663. set( wxWidgets_REQ_VERSION 3.0.0 )
  664. endif()
  665. # See line 49 of CMakeModules/FindwxWidgets.cmake
  666. set( wxWidgets_CONFIG_OPTIONS ${wxWidgets_CONFIG_OPTIONS} --static=no )
  667. find_package( wxWidgets ${wxWidgets_REQ_VERSION} COMPONENTS gl aui adv html core net base propgrid xml stc REQUIRED )
  668. # Include wxWidgets macros.
  669. include( ${wxWidgets_USE_FILE} )
  670. if( KICAD_SCRIPTING_WXPYTHON AND NOT KICAD_SCRIPTING_WXPYTHON_PHOENIX )
  671. # wxPython appears to be installed and valid so make sure the headers are available.
  672. foreach( path ${wxWidgets_INCLUDE_DIRS} )
  673. #message( STATUS "Searching for wx/wxPython/wxPython.h in ${path}" )
  674. find_path( wxPYTHON_INCLUDE_DIRS wx/wxPython/wxPython.h
  675. PATHS "${path}" )
  676. if( wxPYTHON_INCLUDE_DIRS )
  677. message( STATUS "Found wxPython.h in ${path}/wx/wxPython" )
  678. break()
  679. endif()
  680. endforeach()
  681. if( NOT wxPYTHON_INCLUDE_DIRS )
  682. message( FATAL_ERROR "Cannot find wxPython.h" )
  683. endif()
  684. endif()
  685. if( APPLE )
  686. # Remove app bundles in ${KICAD_BIN} before installing anything new.
  687. # Must be defined before all includes so that it is executed first.
  688. install( CODE "
  689. message( STATUS \"Removing existing application bundles...\" )
  690. # Remove links to standalone apps
  691. file( REMOVE ${KICAD_BIN}/bitmap2component.app )
  692. file( REMOVE ${KICAD_BIN}/eeschema.app )
  693. file( REMOVE ${KICAD_BIN}/gerbview.app )
  694. file( REMOVE ${KICAD_BIN}/pcb_calculator.app )
  695. file( REMOVE ${KICAD_BIN}/pcbnew.app )
  696. file( REMOVE ${KICAD_BIN}/pl_editor.app )
  697. # Remove main bundle
  698. file( REMOVE_RECURSE ${KICAD_BIN}/${OSX_BUNDLE_MAIN} )
  699. " COMPONENT Runtime
  700. )
  701. endif()
  702. #================================================
  703. # Add the documentation
  704. #================================================
  705. find_package( Doxygen )
  706. add_subdirectory( Documentation )
  707. # Generate config.h.
  708. configure_file( ${PROJECT_SOURCE_DIR}/CMakeModules/config.h.cmake
  709. ${CMAKE_BINARY_DIR}/config.h )
  710. ###
  711. # Generate Map file
  712. ###
  713. if( KICAD_MAKE_LINK_MAPS )
  714. # Currently only works on linux/gcc
  715. if( UNIX AND NOT APPLE )
  716. set( MAKE_LINK_MAPS true )
  717. else()
  718. set( MAKE_LINK_MAPS false )
  719. endif()
  720. endif()
  721. #================================================
  722. # "make uninstall" rules
  723. #================================================
  724. configure_file(
  725. "${CMAKE_MODULE_PATH}/cmake_uninstall.cmake.in"
  726. "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
  727. IMMEDIATE @ONLY )
  728. add_custom_target( uninstall
  729. "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )
  730. #################################################
  731. # Generate platform metadata files
  732. #################################################
  733. if( APPLE )
  734. include( ${CMAKE_MODULE_PATH}/WritePlatformMetadata_macos.cmake )
  735. elseif( UNIX )
  736. include( ${CMAKE_MODULE_PATH}/WritePlatformMetadata_linux.cmake )
  737. endif()
  738. #================================================
  739. # Installation
  740. #================================================
  741. ###
  742. # Install scripts
  743. ###
  744. if( UNIX AND NOT APPLE )
  745. install( DIRECTORY scripts
  746. DESTINATION ${KICAD_DOCS}
  747. COMPONENT resources
  748. PATTERN "*.bat" EXCLUDE
  749. )
  750. endif()
  751. ###
  752. # FreeDesktop .desktop and MIME resources
  753. ###
  754. if( UNIX AND NOT APPLE )
  755. # Set paths
  756. set( UNIX_MIME_DIR resources/linux/mime )
  757. set( UNIX_MIME_FILES ${UNIX_MIME_DIR}/mime )
  758. set( UNIX_ICON_FILES ${UNIX_MIME_DIR}/icons )
  759. set( UNIX_APPLICATIONS_FILES ${UNIX_MIME_DIR}/applications )
  760. set( UNIX_APPDATA_FILES ${PROJECT_BINARY_DIR}/resources/linux/appdata )
  761. # Install Mime directory
  762. install( DIRECTORY ${UNIX_ICON_FILES}
  763. DESTINATION share
  764. COMPONENT resources
  765. )
  766. # Install Icons
  767. install( DIRECTORY ${UNIX_MIME_FILES}
  768. DESTINATION share
  769. COMPONENT resources
  770. )
  771. # Install Applications directory (.desktop files)
  772. install( DIRECTORY ${UNIX_APPLICATIONS_FILES}
  773. DESTINATION share
  774. COMPONENT resources
  775. )
  776. # Install AppStream directory (app store entry)
  777. install( DIRECTORY ${UNIX_APPDATA_FILES}
  778. DESTINATION share
  779. COMPONENT resources
  780. FILES_MATCHING
  781. PATTERN "*appdata.xml"
  782. PATTERN "*.in" EXCLUDE
  783. )
  784. endif()
  785. include( CTest )
  786. enable_testing()
  787. if( UNIX AND NOT APPLE )
  788. # Create a *.deb file:
  789. set( CPACK_GENERATOR "DEB" )
  790. set( CPACK_DEBIAN_PACKAGE_MAINTAINER "http://launchpad.net/kicad" )
  791. set( CPACK_PACKAGE_VERSION_MAJOR 1 )
  792. set( CPACK_PACKAGE_VERSION_MINOR 0 )
  793. set( CPACK_PACKAGE_VERSION_PATCH 0 )
  794. #set( CPACK_PACKAGE_CONTACT Firstname Lastname <email@company.com> )
  795. set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "KiCad built by CMake build system." )
  796. include( CPack )
  797. endif()
  798. #================================================
  799. # Let CMake look in these directories for nested
  800. # 'CMakeLists.txt' files to process
  801. #================================================
  802. # Binaries ( CMake targets )
  803. add_subdirectory( thirdparty )
  804. add_subdirectory( bitmaps_png )
  805. add_subdirectory( libs )
  806. add_subdirectory( common )
  807. add_subdirectory( 3d-viewer )
  808. add_subdirectory( eeschema )
  809. add_subdirectory( gerbview )
  810. add_subdirectory( pcbnew )
  811. add_subdirectory( pagelayout_editor )
  812. add_subdirectory( bitmap2component )
  813. add_subdirectory( pcb_calculator )
  814. add_subdirectory( plugins ) # 3D plugins must be built before kicad
  815. add_subdirectory( cvpcb ) # must be after pcbnew
  816. add_subdirectory( kicad ) # should follow pcbnew, eeschema
  817. add_subdirectory( tools )
  818. add_subdirectory( utils )
  819. add_subdirectory( qa )
  820. # Resources
  821. if ( KICAD_INSTALL_DEMOS )
  822. add_subdirectory( demos )
  823. endif ( KICAD_INSTALL_DEMOS )
  824. add_subdirectory( template )