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.

295 lines
9.0 KiB

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