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.

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