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.

273 lines
8.5 KiB

18 years ago
18 years ago
16 years ago
18 years ago
18 years ago
18 years ago
  1. project(kicad)
  2. # test the minimum Cmake version requirement (could be different under unix or Windows
  3. if(WIN32)
  4. cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
  5. else(WIN32)
  6. cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
  7. endif(WIN32)
  8. # Path to local CMake modules.
  9. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
  10. # Command line option to enable or disable building minizip. Minizip
  11. # building is enabled by default. Use -DKICAD_MINZIP=OFF to disable
  12. # building minizip.
  13. option(KICAD_MINIZIP "enable/disable building minizip (default ON)" ON)
  14. # Russian GOST patch
  15. option(wxUSE_UNICODE "enable/disable building unicode (default OFF)")
  16. option(KICAD_GOST "enable/disable building using GOST notation for multiple gates per package (default OFF)")
  17. option(USE_WX_ZOOM "Use wxDC to perform zooming (default OFF). Warning, this is experimental" )
  18. option(USE_WX_GRAPHICS_CONTEXT
  19. "Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental")
  20. option(USE_BOOST_POLYGON_LIBRARY
  21. "Use boost polygon library instead of Kbool to calculate filled areas in zones (default OFF). Warning, this is experimental")
  22. #================================================
  23. # Set flags for GCC.
  24. #================================================
  25. if(CMAKE_COMPILER_IS_GNUCXX)
  26. # Set default flags for Release build.
  27. set(CMAKE_C_FLAGS_RELEASE "-Wall -O2 -DNDEBUG")
  28. set(CMAKE_CXX_FLAGS_RELEASE "-Wall -O2 -DNDEBUG")
  29. set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")
  30. # Set default flags for Debug build.
  31. set(CMAKE_C_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
  32. set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
  33. endif(CMAKE_COMPILER_IS_GNUCXX)
  34. if(wxUSE_UNICODE)
  35. add_definitions(-DwxUSE_UNICODE)
  36. endif(wxUSE_UNICODE)
  37. if(KICAD_GOST)
  38. add_definitions(-DKICAD_GOST)
  39. endif(KICAD_GOST)
  40. if(USE_WX_ZOOM)
  41. add_definitions(-DUSE_WX_ZOOM)
  42. endif(USE_WX_ZOOM)
  43. if(USE_WX_GRAPHICS_CONTEXT)
  44. set( USE_WX_ZOOM ON )
  45. add_definitions(-DUSE_WX_ZOOM)
  46. add_definitions(-DUSE_WX_GRAPHICS_CONTEXT)
  47. endif(USE_WX_GRAPHICS_CONTEXT)
  48. if(USE_BOOST_POLYGON_LIBRARY)
  49. set( USE_BOOST_POLYGON_LIBRARY ON )
  50. add_definitions(-DUSE_BOOST_POLYGON_LIBRARY)
  51. endif(USE_BOOST_POLYGON_LIBRARY)
  52. # Locations for install targets.
  53. set(KICAD_BIN bin
  54. CACHE PATH "Location of KiCad binaries.")
  55. if(UNIX)
  56. # Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
  57. set(KICAD_PLUGINS lib/kicad/plugins
  58. CACHE PATH "Location of KiCad plugins.")
  59. set(KICAD_DATA share/kicad
  60. CACHE PATH "Location of KiCad data files.")
  61. set(KICAD_DOCS share/doc/kicad
  62. CACHE PATH "Location of KiCad documentation files.")
  63. endif(UNIX)
  64. if(WIN32)
  65. # Like all variables, CMAKE_INSTALL_PREFIX can be over-ridden on the command line.
  66. set(CMAKE_INSTALL_PREFIX c:/kicad
  67. CACHE PATH "")
  68. # Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
  69. set(KICAD_PLUGINS ${KICAD_BIN}/plugins
  70. CACHE PATH "Location of KiCad plugins.")
  71. set(KICAD_DATA share
  72. CACHE PATH "Location of KiCad data files.")
  73. set(KICAD_DOCS doc
  74. CACHE PATH "Location of KiCad documentation files.")
  75. endif(WIN32)
  76. set(KICAD_DEMOS ${KICAD_DATA}/demos
  77. CACHE PATH "Location of KiCad demo files.")
  78. set(KICAD_TEMPLATE ${KICAD_DATA}/template
  79. CACHE PATH "Location of KiCad template files.")
  80. mark_as_advanced(KICAD_BIN
  81. KICAD_PLUGINS
  82. KICAD_DATA
  83. KICAD_DOCS
  84. KICAD_DEMOS
  85. KICAD_TEMPLATE)
  86. #================================================
  87. # Find libraries that are needed to build KiCad.
  88. #================================================
  89. include(CheckFindPackageResult)
  90. #######################
  91. # Find OpenGL library #
  92. #######################
  93. find_package(OpenGL QUIET)
  94. check_find_package_result(OPENGL_FOUND "OpenGL")
  95. ######################
  96. # Find Boost library #
  97. ######################
  98. # kicad now includes needed boost files.
  99. # the two next lines can be uncommented to use the native boost lib.
  100. # but this is not a good idea
  101. #find_package(Boost 1.36 QUIET)
  102. #check_find_package_result(Boost_FOUND "Boost")
  103. ##########################
  104. # Find wxWidgets library #
  105. ##########################
  106. # Here you can define what libraries of wxWidgets you need for your
  107. # application. You can figure out what libraries you need here;
  108. # http://www.wxwidgets.org/manuals/2.8/wx_librarieslist.html
  109. # On Apple only wxwidgets 2.9 or higher doesn't need to find aui part of base
  110. if(APPLE)
  111. find_package(wxWidgets COMPONENTS gl adv html core net base xml QUIET)
  112. else(APPLE)
  113. find_package(wxWidgets COMPONENTS gl aui adv html core net base xml QUIET)
  114. endif(APPLE)
  115. check_find_package_result(wxWidgets_FOUND "wxWidgets")
  116. # Include wxWidgets macros.
  117. include(${wxWidgets_USE_FILE})
  118. # Include MinGW resource compiler.
  119. include(MinGWResourceCompiler)
  120. # Generate build system specific header file.
  121. include(PerformFeatureChecks)
  122. perform_feature_checks()
  123. # Find GDI+ on windows if wxGraphicsContext is available.
  124. if(WIN32 AND USE_WX_GRAPHICS_CONTEXT)
  125. find_package(GdiPlus)
  126. check_find_package_result(GDI_PLUS_FOUND "GDI+")
  127. endif(WIN32 AND USE_WX_GRAPHICS_CONTEXT)
  128. # Automagically create version header file.
  129. include(CreateBzrVersionHeader)
  130. create_bzr_version_header()
  131. if(EXISTS ${CMAKE_SOURCE_DIR}/include/config.h)
  132. # This file may exist (created by an alternate process to the svn test above),
  133. # e.g. could be created by a checkout script that produces a source tar file.
  134. # This directive means the about box will have the svn date & revision in it,
  135. # but the hard coded release date (program version) will be preserved.
  136. add_definitions(-DHAVE_SVN_REVISION)
  137. endif(EXISTS ${CMAKE_SOURCE_DIR}/include/config.h)
  138. # Include paths.
  139. include_directories(${CMAKE_SOURCE_DIR}/include
  140. ${CMAKE_SOURCE_DIR}/share
  141. ${CMAKE_BINARY_DIR})
  142. #================================================
  143. # Let CMake look in these directories for nested
  144. # 'CMakeLists.txt' files to process
  145. #================================================
  146. ############
  147. # Binaries #
  148. ############
  149. add_subdirectory(3d-viewer)
  150. add_subdirectory(bitmaps)
  151. add_subdirectory(common)
  152. add_subdirectory(cvpcb)
  153. add_subdirectory(eeschema)
  154. add_subdirectory(gerbview)
  155. add_subdirectory(kicad)
  156. add_subdirectory(pcbnew)
  157. add_subdirectory(polygon)
  158. add_subdirectory(polygon/kbool/src)
  159. add_subdirectory(potrace)
  160. add_subdirectory(bitmap2component)
  161. #############
  162. # Resources #
  163. #############
  164. add_subdirectory(demos)
  165. add_subdirectory(template)
  166. #================================================
  167. # Doxygen Output
  168. #================================================
  169. find_package(Doxygen)
  170. if(DOXYGEN_FOUND)
  171. add_custom_target( doxygen-docs ${DOXYGEN_EXECUTABLE}
  172. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  173. DEPENDS Doxyfile )
  174. else(DOXYGEN_FOUND)
  175. message( STATUS "WARNING: Doxygen not found - doxygen-docs (Source Docs) target not created" )
  176. endif()
  177. #================================================
  178. # Installation parameters
  179. #================================================
  180. install(FILES INSTALL.txt
  181. DESTINATION ${KICAD_DOCS}
  182. COMPONENT resources)
  183. install(FILES resources/freeroute.jnlp
  184. DESTINATION ${KICAD_BIN}
  185. COMPONENT resources)
  186. ###
  187. # Install scripts
  188. ###
  189. if(UNIX)
  190. install(DIRECTORY scripts
  191. DESTINATION ${KICAD_DOCS}
  192. COMPONENT resources
  193. PATTERN ".svn" EXCLUDE)
  194. endif(UNIX)
  195. ###
  196. # FreeDesktop .desktop and MIME resources
  197. ###
  198. if(UNIX)
  199. # Set paths
  200. set(UNIX_MIME_DIR resources/linux/mime)
  201. set(UNIX_MIMELNK_FILES ${UNIX_MIME_DIR}/mimelnk)
  202. set(UNIX_MIME_FILES ${UNIX_MIME_DIR}/mime)
  203. set(UNIX_ICONS_FILES ${UNIX_MIME_DIR}/icons)
  204. set(UNIX_APPLICATIONS_FILES ${UNIX_MIME_DIR}/applications)
  205. # Install Mimelnk directory
  206. install(DIRECTORY ${UNIX_MIMELNK_FILES}
  207. DESTINATION ${CMAKE_INSTALL_PREFIX}/share
  208. COMPONENT resources
  209. PATTERN ".svn" EXCLUDE)
  210. # Install Mime directory
  211. install(DIRECTORY ${UNIX_ICONS_FILES}
  212. DESTINATION ${CMAKE_INSTALL_PREFIX}/share
  213. COMPONENT resources
  214. PATTERN ".svn" EXCLUDE)
  215. # Install Icons
  216. install(DIRECTORY ${UNIX_MIME_FILES}
  217. DESTINATION ${CMAKE_INSTALL_PREFIX}/share
  218. COMPONENT resources
  219. PATTERN ".svn" EXCLUDE)
  220. # Install Applications directory (.desktop files)
  221. install(DIRECTORY ${UNIX_APPLICATIONS_FILES}
  222. DESTINATION ${CMAKE_INSTALL_PREFIX}/share
  223. COMPONENT resources
  224. PATTERN ".svn" EXCLUDE)
  225. endif(UNIX)
  226. include(CTest)