Commit 338e0db7 authored by f3nix's avatar f3nix

Debug build should be easier now. See how-to-build-kicad.txt. Tested on linux only.

parent f77e47dc
FIND_PACKAGE(OpenGL)
IF(OPENGL_FOUND)
MESSAGE(STATUS "Check for installed OpenGL -- found")
ELSE(OPENGL_FOUND)
MESSAGE(STATUS "Check for installed OpenGL -- not found")
MESSAGE(FATAL_ERROR "OpenGL was not found - it is required to build KiCad")
ENDIF(OPENGL_FOUND)
ADD_DEFINITIONS(-DPCBNEW)
INCLUDE_DIRECTORIES(
......
TODO:
* Fix minizip build on windows.
* Add install targets for binaries, docs, translations, libraries on Mac.
Linux version has a preliminary support.
Windows version has a preliminary support.
* Add DEBUG.
* Add PYTHON.
* Add shared/static.
* Testing.
......
# Our project is called 'kicad'. This is what it will be called in
# Visual Studio and in our makefiles.
# our makefiles.
PROJECT(kicad)
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)
# Uncomment this line if you want verbose build messages.
#SET(CMAKE_VERBOSE_MAKEFILE ON)
# Path to local CMake modules
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
# List of variables that may be set from command line:
# CMAKE_VERBOSE_MAKEFILE ON/OFF (OPTIONAL)
# Turns ON/OFF verbose build messages.
#
# CMAKE_BUILD_TYPE Release/Debug (REQUIRED)
#
#
# wxWidgets_USE_DEBUG ON/OFF (REQUIRED)
# Should be set to ON only when CMAKE_BUILD_TYPE=Debug.
#
# CMAKE_INSTALL_PREFIX (OPTIONAL)
#
# Comment this out if you don't want to build minizip.
SET(BUILD_MINIZIP ON CACHE BOOL "Build minizip?")
SET(KICAD_MINIZIP ON CACHE BOOL "Build minizip?")
# Set default flags for Debug build.
SET(CMAKE_C_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
SET(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
# Comment this out if you don't want to build with Python support.
# SET(KICAD_PYTHON ON CACHE BOOL "Build with Python support?")
# Set default flags for Release build.
SET(CMAKE_C_FLAGS_RELEASE "-Wall -O2 -DNDEBUG")
SET(CMAKE_CXX_FLAGS_RELEASE "-Wall -O2 -DNDEBUG")
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")
# Here you can define what libraries of wxWidgets you need for your
# application. You can figure out what libraries you need here;
# http://www.wxwidgets.org/manuals/2.8/wx_librarieslist.html
SET(wxWidgets_USE_LIBS base core adv gl html net)
# OpenGL support
SET(WXWINDOWS_USE_GL 1)
# We need the Find package for wxWidgets to work.
FIND_PACKAGE(wxWidgets REQUIRED)
# Set default flags for Debug build.
SET(CMAKE_C_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
SET(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -ggdb3 -DDEBUG")
# Locations for install targets.
IF(UNIX)
......@@ -49,7 +55,7 @@ ENDIF(UNIX)
IF(WIN32)
# Like all variables, CMAKE_INSTALL_PREFIX can be over-ridden on the command line.
SET(CMAKE_INSTALL_PREFIX c:/kicad)
SET(CMAKE_INSTALL_PREFIX c:/kicad CACHE PATH "")
# When used later, "winexe" and others with no leading / is relative to CMAKE_INSTALL_PREFIX.
SET(KICAD_BIN winexe CACHE PATH "Location of KiCad binaries.")
SET(KICAD_PLUGINS ${KICAD_BIN}/plugins)
......@@ -60,37 +66,45 @@ IF(WIN32)
SET(KICAD_TEMPLATE template)
ENDIF(WIN32)
# Did we find wxWidgets ? This condition will fail
# for as long as the internal vars do not point to
# the proper wxWidgets configuration.
FIND_PACKAGE(OpenGL)
IF(OPENGL_FOUND)
MESSAGE(STATUS "Check for installed OpenGL -- found")
ELSE(OPENGL_FOUND)
MESSAGE(STATUS "Check for installed OpenGL -- not found")
MESSAGE(FATAL_ERROR "OpenGL was not found - it is required to build KiCad")
ENDIF(OPENGL_FOUND)
# Here you can define what libraries of wxWidgets you need for your
# application. You can figure out what libraries you need here;
# http://www.wxwidgets.org/manuals/2.8/wx_librarieslist.html
SET(wxWidgets_USE_LIBS base core adv gl html net)
FIND_PACKAGE(wxWidgetsCVS)
IF(wxWidgets_FOUND)
MESSAGE(STATUS "Check for installed wxWidgets -- found")
# Include wxWidgets macros.
INCLUDE(${wxWidgets_USE_FILE})
# We define the include paths here.
# Include dirs for wxWidgets was defined before.
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/share)
# CMake will look in these dirs for nested 'CMakeLists.txt' files.
ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(3d-viewer)
ADD_SUBDIRECTORY(cvpcb)
ADD_SUBDIRECTORY(eeschema)
ADD_SUBDIRECTORY(gerbview)
ADD_SUBDIRECTORY(kicad)
ADD_SUBDIRECTORY(pcbnew)
ADD_SUBDIRECTORY(polygon)
ELSE(wxWidgets_FOUND)
# For convenience. When we cannot continue, inform the user.
MESSAGE(STATUS "Check for installed wxWidgets -- not found")
MESSAGE(FATAL_ERROR "wxWidgets was not found - it is required to build KiCad")
ENDIF(wxWidgets_FOUND)
# CMake will look at this dirs for nested 'CMakeLists.txt' files.
# Include wxWidgets macros.
INCLUDE(${wxWidgets_USE_FILE})
# Include paths.
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/share)
# CMake will look in these dirs for nested 'CMakeLists.txt' files.
# Binaries.
ADD_SUBDIRECTORY(common)
ADD_SUBDIRECTORY(3d-viewer)
ADD_SUBDIRECTORY(cvpcb)
ADD_SUBDIRECTORY(eeschema)
ADD_SUBDIRECTORY(gerbview)
ADD_SUBDIRECTORY(kicad)
ADD_SUBDIRECTORY(pcbnew)
ADD_SUBDIRECTORY(polygon)
# Resources.
ADD_SUBDIRECTORY(internat)
ADD_SUBDIRECTORY(help)
ADD_SUBDIRECTORY(library)
......
# CMake CVS r1.3
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (DEFAULT_MSG|"Custom failure message") VAR1 ... )
# This macro is intended to be used in FindXXX.cmake modules files.
# It handles the REQUIRED and QUIET argument to FIND_PACKAGE() and
# it also sets the <UPPERCASED_NAME>_FOUND variable.
# The package is found if all variables listed are TRUE.
# Example:
#
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR)
#
# LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and
# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
# If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
# independent whether QUIET was used or not.
# If it is found, the location is reported using the VAR1 argument, so
# here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out.
# If the second argument is DEFAULT_MSG, the message in the failure case will
# be "Could NOT find LibXml2", if you don't like this message you can specify
# your own custom failure message there.
MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 )
IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
SET(_FAIL_MESSAGE "Could NOT find ${_NAME}")
ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
SET(_FAIL_MESSAGE "${_FAIL_MSG}")
ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
STRING(TOUPPER ${_NAME} _NAME_UPPER)
SET(${_NAME_UPPER}_FOUND TRUE)
IF(NOT ${_VAR1})
SET(${_NAME_UPPER}_FOUND FALSE)
ENDIF(NOT ${_VAR1})
FOREACH(_CURRENT_VAR ${ARGN})
IF(NOT ${_CURRENT_VAR})
SET(${_NAME_UPPER}_FOUND FALSE)
ENDIF(NOT ${_CURRENT_VAR})
ENDFOREACH(_CURRENT_VAR)
IF (${_NAME_UPPER}_FOUND)
IF (NOT ${_NAME}_FIND_QUIETLY)
MESSAGE(STATUS "Found ${_NAME}: ${${_VAR1}}")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ELSE (${_NAME_UPPER}_FOUND)
IF (${_NAME}_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}")
ELSE (${_NAME}_FIND_REQUIRED)
IF (NOT ${_NAME}_FIND_QUIETLY)
MESSAGE(STATUS "${_FAIL_MESSAGE}")
ENDIF (NOT ${_NAME}_FIND_QUIETLY)
ENDIF (${_NAME}_FIND_REQUIRED)
ENDIF (${_NAME_UPPER}_FOUND)
ENDMACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS)
This diff is collapsed.
# CMake CVS r1.5
# - Convenience include for using wxWidgets library
# Finds if wxWidgets is installed
# and set the appropriate libs, incdirs, flags etc.
# INCLUDE_DIRECTORIES, LINK_DIRECTORIES and ADD_DEFINITIONS
# are called.
#
# USAGE
# SET( wxWidgets_USE_LIBS gl xml xrc ) # optionally: more than wx std libs
# FIND_PACKAGE(wxWidgets REQUIRED)
# INCLUDE( ${xWidgets_USE_FILE} )
# ... add your targets here, e.g. ADD_EXECUTABLE/ ADD_LIBRARY ...
# TARGET_LINK_LIBRARIERS( <yourWxDependantTarget> ${wxWidgets_LIBRARIES})
#
# DEPRECATED
# LINK_LIBRARIES is not called in favor of adding dependencies per target.
#
# AUTHOR
# Jan Woetzel <jw -at- mip.informatik.uni-kiel.de>
# debug message and logging.
# comment these out for distribution
IF (NOT LOGFILE )
# SET(LOGFILE "${PROJECT_BINARY_DIR}/CMakeOutput.log")
ENDIF (NOT LOGFILE )
MACRO(MSG _MSG)
# FILE(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}\n")
# MESSAGE(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}")
ENDMACRO(MSG)
MSG("wxWidgets_FOUND=${wxWidgets_FOUND}")
IF (wxWidgets_FOUND)
IF (wxWidgets_INCLUDE_DIRS)
IF(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
ELSE(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
INCLUDE_DIRECTORIES(SYSTEM ${wxWidgets_INCLUDE_DIRS})
ENDIF(wxWidgets_INCLUDE_DIRS_NO_SYSTEM)
MSG("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}")
ENDIF(wxWidgets_INCLUDE_DIRS)
IF (wxWidgets_LIBRARY_DIRS)
LINK_DIRECTORIES(${wxWidgets_LIBRARY_DIRS})
MSG("wxWidgets_LIBRARY_DIRS=${wxWidgets_LIBRARY_DIRS}")
ENDIF(wxWidgets_LIBRARY_DIRS)
IF (wxWidgets_DEFINITIONS)
ADD_DEFINITIONS( ${wxWidgets_DEFINITIONS} )
MSG("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}")
ENDIF(wxWidgets_DEFINITIONS)
IF (wxWidgets_CXX_FLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS}")
MSG("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}")
ENDIF(wxWidgets_CXX_FLAGS)
# DEPRECATED JW
# just for backward compatibility: add deps to all targets
# library projects better use advanced FIND_PACKAGE(wxWidgets) directly.
#IF(wxWidgets_LIBRARIES)
# LINK_LIBRARIES(${wxWidgets_LIBRARIES})
# # BUG: str too long: MSG("wxWidgets_LIBRARIES=${wxWidgets_LIBRARIES}")
# IF(LOGFILE)
# FILE(APPEND ${LOGFILE} "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${wxWidgets_LIBRARIES}\n")
# ENDIF(LOGFILE)
#ENDIF(wxWidgets_LIBRARIES)
ELSE (wxWidgets_FOUND)
MESSAGE("wxWidgets requested but not found.")
ENDIF(wxWidgets_FOUND)
......@@ -74,6 +74,6 @@ ENDIF(APPLE)
ADD_EXECUTABLE(cvpcb WIN32 MACOSX_BUNDLE ${CVPCB_SRCS} ${CVPCB_EXTRA_SRCS} ${CVPCB_RESOURCES})
TARGET_LINK_LIBRARIES(cvpcb common 3d-viewer polygon ${wxWidgets_LIBRARIES})
TARGET_LINK_LIBRARIES(cvpcb common 3d-viewer polygon ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES})
INSTALL(TARGETS cvpcb RUNTIME DESTINATION ${KICAD_BIN} COMPONENT binary)
......@@ -12,4 +12,3 @@ INSTALL(DIRECTORY pt COMPONENT doc-pt
DESTINATION ${KICAD_DOCS} PATTERN ".svn" EXCLUDE)
INSTALL(DIRECTORY ru COMPONENT doc-ru
DESTINATION ${KICAD_DOCS} PATTERN ".svn" EXCLUDE)
How to build kicad using CMAKE.
--== How to build kicad using CMAKE ==--
First Written: 19-Dec-2007
Last Revised: 05-Jan-2008
Last Revised: 06-Jan-2008
Kicad needs wxWidgets, the multi platform G.U.I.
......@@ -46,12 +44,6 @@ If windows, then try running g++ and make from within your msys bash shell.
-----------------------------------------------------------------------------
4) Install wxWidgets [and build it if on windows].
If on linux, use your package manager to install shared object libraries and the
development versions of the wxWidgets packages which include the C++ headers. An
alternative is to build static libaries from source. Verify that wx-config is in
your path by running it from a command prompt. Linux users then go to next step.
If on windows, download
http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.7.zip or a newer version.
Start msys so you have a bash shell. Decide where your wxWidgets build directory
......@@ -77,6 +69,12 @@ Verify that wx-config is in your path. Modify your PATH environment variable
if need be so you can run wx-config from a command prompt. You may have to
restart your msys shell, depending on how you modify your PATH.
If on linux, use your package manager to install shared object libraries and the
development versions of the wxWidgets packages which include the C++ headers. An
alternative is to build static libaries from source. Verify that wx-config is in
your path by running it from a command prompt. Linux users then go to next step.
-----------------------------------------------------------------------------
5) Install zlib [and build it if on windows].
......@@ -90,6 +88,7 @@ build directory. Change directories into there, and then:
make
make install
If linux, use your package manager to install zlib.
-----------------------------------------------------------------------------
......@@ -100,6 +99,7 @@ Install that and choose to add cmake to your path during installation. You
will have to restart and command shells for the new path to take effect.
Verify that cmake is in your path by trying to run it from a command prompt.
If linux, use your package manager to install cmake. You should get cmake 2.4.7
or later. If only an older one is available in your package repository, build
2.4.7 from source. Verify that cmake is in your path by trying to run it from a
......@@ -116,19 +116,18 @@ You can use the subversion repository or a tar file for this. See the wiki.
If windows, go into your msys shell. Linux and windows users both then make
two "out of source" build directories:
cd <kicadSource>
mkdir release
mkdir debug
cd release
mkdir -p Build/Release
mkdir Build/Debug
cd Build/Release
On either cmake command line shown below, you can optionally include
-DCMAKE_INSTALL_PREFIX=<finallInstallDir>
before the final .. argument.
If windows, run the following command:
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DwxWidgets_ROOT_DIR=<wxInstallDir> ..
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
If linux, run instead the following command:
cmake -DCMAKE_BUILD_TYPE=Release ../
cmake -DCMAKE_BUILD_TYPE=Release ../../
Take a look at CMakeCache.txt, and in particular CMAKE_INSTALL_PREFIX, which
gives the final install directory. If not what you want, edit it with a text
......@@ -141,7 +140,7 @@ editor and re-run the same cmake command again, but with no
You compile Kicad here. You will only need to do step 8) again when one of the
CMakeLists.txt files change. If windows, you must be in your msys shell.
On either platform then:
cd <kicadSource>/release
cd <kicadSource>/Build/Release
make
[sudo] make install
......@@ -151,34 +150,25 @@ You are now done unless you want to make a Debug build.
10) Making a "Debug" build.
cd <kicadSource>/debug
cd <kicadSource>/Build/Debug
On either cmake command line shown below, you can optionally include
-DCMAKE_INSTALL_PREFIX=<finallInstallDir> before the final .. argument. Although
-DCMAKE_INSTALL_PREFIX=<finallInstallDir> before the final ../../ argument. Although
normally you do not install the Debug binaries, you can debug them where they
were built.
If windows, run the following command:
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_ROOT_DIR=<wxInstallDir> ..
cmake -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_USE_DEBUG=ON -DwxWidgets_ROOT_DIR=<wxInstallDir> ../../
If linux, run instead the following command:
cmake -DCMAKE_BUILD_TYPE=Debug ../
Edit CMakeCache.txt, and look for the line that defines wxWidgets_CONFIG_EXECUTABLE:
wxWidgets_CONFIG_EXECUTABLE:FILEPATH=E:/usr/local/bin/wx-config
If you have debug libaries for wxWidgets, which should be the case if you installed
them in linux or if you built them on windows, then add "--debug" to the end of
the wx-config command, for example:
wxWidgets_CONFIG_EXECUTABLE:FILEPATH=E:/usr/local/bin/wx-config --debug
Re-run the same cmake command again as given above for your respective platform.
cmake -DCMAKE_BUILD_TYPE=Debug -DwxWidgets_USE_DEBUG=ON ../../
Make the Debug binaries:
make
Note that it is easy to build only a specific binary such as pcbnew alone:
-----------------------------------------------------------------------------
Note: that it is easy to build only a specific binary such as pcbnew alone:
make pcbnew
-----------------------------------------------------------------------------
......@@ -333,4 +323,3 @@ line 410
if ( !pItem->IsOwnerDrawn() )
must be
if ( !pItem->IsOwnerDrawn() && !pItem->IsSeparator() )
......@@ -38,6 +38,6 @@ TARGET_LINK_LIBRARIES(kicad common ${wxWidgets_LIBRARIES})
INSTALL(TARGETS kicad RUNTIME DESTINATION ${KICAD_BIN} COMPONENT binary)
IF(BUILD_MINIZIP)
IF(KICAD_MINIZIP)
ADD_SUBDIRECTORY(minizip)
ENDIF(BUILD_MINIZIP)
ENDIF(KICAD_MINIZIP)
......@@ -175,6 +175,6 @@ ADD_EXECUTABLE(specctra_test EXCLUDE_FROM_ALL specctra.cpp dsn.cpp )
TARGET_LINK_LIBRARIES(specctra_test common ${wxWidgets_LIBRARIES})
TARGET_LINK_LIBRARIES(pcbnew common 3d-viewer polygon ${wxWidgets_LIBRARIES})
TARGET_LINK_LIBRARIES(pcbnew common 3d-viewer polygon ${wxWidgets_LIBRARIES} ${OPENGL_LIBRARIES})
INSTALL(TARGETS pcbnew RUNTIME DESTINATION ${KICAD_BIN} COMPONENT binary)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment