add -fPIC for all builds, even cross comiling to Windows from Linux, even non Debug and Release builds
This commit is contained in:
parent
89f590a1fc
commit
e4d09b96bc
154
CMakeLists.txt
154
CMakeLists.txt
|
@ -5,9 +5,9 @@ if(WIN32)
|
|||
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) # win32 and win64
|
||||
elseif(APPLE)
|
||||
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) # OSX
|
||||
else(WIN32)
|
||||
else()
|
||||
cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR) # Linux, Unix, and everything else.
|
||||
endif(WIN32)
|
||||
endif()
|
||||
|
||||
# Path to local CMake modules.
|
||||
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
|
||||
|
@ -21,7 +21,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
|
|||
#
|
||||
|
||||
option(USE_PCBNEW_NANOMETRES
|
||||
"Use nanometers for Pcbnew internal units instead of deci-mils (default ON)." ON)
|
||||
"Use nanometers for Pcbnew internal units instead of deci-mils (default ON)." ON)
|
||||
|
||||
# Russian GOST patch
|
||||
option(wxUSE_UNICODE "enable/disable building unicode (default OFF)")
|
||||
|
@ -31,31 +31,31 @@ option(KICAD_GOST "enable/disable building using GOST notation for multiple gate
|
|||
option(KICAD_KEEPCASE "turn-off automatic component name conversion to uppercase if selected")
|
||||
|
||||
option(USE_WX_GRAPHICS_CONTEXT
|
||||
"Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental")
|
||||
"Use wxGraphicsContext for rendering (default OFF). Warning, this is experimental")
|
||||
|
||||
option(USE_WX_OVERLAY
|
||||
"Use wxOverlay: Always ON for MAC (default OFF). Warning, this is experimental")
|
||||
"Use wxOverlay: Always ON for MAC (default OFF). Warning, this is experimental")
|
||||
|
||||
#One of these 2 option *must* be set to ON:
|
||||
option(KICAD_STABLE_VERSION
|
||||
"set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)"
|
||||
)
|
||||
"set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)"
|
||||
)
|
||||
|
||||
option(KICAD_TESTING_VERSION
|
||||
"set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)"
|
||||
)
|
||||
"set this option to ON to build the stable version of KICAD. mainly used to set version ID (default OFF)"
|
||||
)
|
||||
|
||||
option(KICAD_SCRIPTING
|
||||
"set this option ON to build the scripting support inside kicad binaries"
|
||||
)
|
||||
"set this option ON to build the scripting support inside kicad binaries"
|
||||
)
|
||||
|
||||
option(KICAD_SCRIPTING_MODULES
|
||||
"set this option ON to build kicad modules that can be used from scripting languages"
|
||||
)
|
||||
"set this option ON to build kicad modules that can be used from scripting languages"
|
||||
)
|
||||
|
||||
option(KICAD_SCRIPTING_WXPYTHON
|
||||
"set this option ON to build wxpython implementation for wx interface building in python and py.shell"
|
||||
)
|
||||
"set this option ON to build wxpython implementation for wx interface building in python and py.shell"
|
||||
)
|
||||
|
||||
# when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
|
||||
# PYTHON_EXECUTABLE can be defined when invoking cmake
|
||||
|
@ -73,10 +73,10 @@ elif(NOT KICAD_STABLE_VERSION AND NOT KICAD_TESTING_VERSION)
|
|||
elif(KICAD_STABLE_VERSION)
|
||||
add_definitions(-DKICAD_STABLE_VERSION)
|
||||
message( "Build stable version of KiCad")
|
||||
else(KICAD_STABLE_VERSION AND KICAD_TESTING_VERSION)
|
||||
else()
|
||||
add_definitions(-DKICAD_TESTING_VERSION)
|
||||
message("Build testing (unstable) version of KiCad")
|
||||
endif(KICAD_STABLE_VERSION AND KICAD_TESTING_VERSION)
|
||||
endif()
|
||||
|
||||
|
||||
#================================================
|
||||
|
@ -84,6 +84,13 @@ endif(KICAD_STABLE_VERSION AND KICAD_TESTING_VERSION)
|
|||
#================================================
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
# We build DLL/DSOs from static libraries, so create position independent code
|
||||
# for all cases, since we do not have DLL/DSO specific static libraries.
|
||||
# This flag could be localized to any object file going into a DLL/DSO in the future.
|
||||
set( CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
|
||||
|
||||
set(KICAD_GCC_RELEASE_BUILD_FLAGS "-O2")
|
||||
set(KICAD_GCC_RELEASE_DEBUG_FLAGS "")
|
||||
|
||||
|
@ -111,13 +118,13 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
|||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
message(STATUS
|
||||
"Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_DEBUG_BUILD_FLAGS}\"")
|
||||
else(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
"Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_DEBUG_BUILD_FLAGS}\"")
|
||||
else()
|
||||
message(STATUS
|
||||
"Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_RELEASE_BUILD_FLAGS}\"")
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
"Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_RELEASE_BUILD_FLAGS}\"")
|
||||
endif()
|
||||
|
||||
if(WIN32) # under Windows/mingw, -fPIC option is enabled by default
|
||||
if(MINGW) # under Windows/mingw, -fPIC option is enabled by default
|
||||
# Set default flags for Release build.
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG")
|
||||
|
@ -128,54 +135,54 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
|||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "-static-libgcc -static-libstdc++") # SWIG macros on Windows
|
||||
|
||||
else(WIN32)
|
||||
else()
|
||||
# Thou shalt not link vaporware and tell us it's a valid DSO:
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined") # needed by SWIG macros on linux
|
||||
|
||||
# Set default flags for Release build.
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG -fPIC")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG -fPIC")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${KICAD_GCC_RELEASE_BUILD_FLAGS} -Wall -DNDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${KICAD_GCC_RELEASE_BUILD_FLAGS} -Wall -DNDEBUG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")
|
||||
|
||||
# Set default flags for Debug build.
|
||||
set(CMAKE_C_FLAGS_DEBUG "-Wall ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG -fPIC")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-Wall ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG -fPIC")
|
||||
endif(WIN32)
|
||||
set(CMAKE_C_FLAGS_DEBUG "${KICAD_GCC_DEBUG_BUILD_FLAGS} -Wall -g3 -ggdb3 -DDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${KICAD_GCC_DEBUG_BUILD_FLAGS} -Wall -g3 -ggdb3 -DDEBUG")
|
||||
endif()
|
||||
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
if(wxUSE_UNICODE)
|
||||
add_definitions(-DwxUSE_UNICODE)
|
||||
endif(wxUSE_UNICODE)
|
||||
endif()
|
||||
|
||||
if(KICAD_GOST)
|
||||
add_definitions(-DKICAD_GOST)
|
||||
endif(KICAD_GOST)
|
||||
endif()
|
||||
|
||||
if(KICAD_KEEPCASE)
|
||||
add_definitions(-DKICAD_KEEPCASE)
|
||||
endif(KICAD_KEEPCASE)
|
||||
endif()
|
||||
|
||||
if(USE_WX_OVERLAY OR APPLE)
|
||||
add_definitions(-DUSE_WX_OVERLAY)
|
||||
endif(USE_WX_OVERLAY OR APPLE)
|
||||
endif()
|
||||
|
||||
if(KICAD_SCRIPTING)
|
||||
add_definitions(-DKICAD_SCRIPTING)
|
||||
endif(KICAD_SCRIPTING)
|
||||
endif()
|
||||
|
||||
if(KICAD_SCRIPTING_MODULES)
|
||||
add_definitions(-DKICAD_SCRIPTING_MODULES)
|
||||
endif(KICAD_SCRIPTING_MODULES)
|
||||
endif()
|
||||
|
||||
if(KICAD_SCRIPTING_WXPYTHON)
|
||||
add_definitions(-DKICAD_SCRIPTING_WXPYTHON)
|
||||
endif(KICAD_SCRIPTING_WXPYTHON)
|
||||
endif()
|
||||
|
||||
if(USE_WX_GRAPHICS_CONTEXT)
|
||||
add_definitions(-DUSE_WX_GRAPHICS_CONTEXT)
|
||||
endif(USE_WX_GRAPHICS_CONTEXT)
|
||||
endif()
|
||||
|
||||
# Allow user to override the default settings for adding images to menu items. By default
|
||||
# images in menu items are enabled on all platforms except OSX. This can be over ridden by
|
||||
|
@ -183,12 +190,12 @@ endif(USE_WX_GRAPHICS_CONTEXT)
|
|||
if(NOT DEFINED USE_IMAGES_IN_MENUS)
|
||||
if(NOT APPLE)
|
||||
set(USE_IMAGES_IN_MENUS ON)
|
||||
endif(NOT APPLE)
|
||||
else(NOT DEFINED USE_IMAGES_IN_MENUS)
|
||||
endif()
|
||||
else()
|
||||
if(USE_IMAGES_IN_MENUS)
|
||||
set(USE_IMAGES_IN_MENUS ON)
|
||||
endif(USE_IMAGES_IN_MENUS)
|
||||
endif(NOT DEFINED USE_IMAGES_IN_MENUS)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Locations for install targets.
|
||||
set(KICAD_BIN bin
|
||||
|
@ -202,9 +209,9 @@ if(UNIX)
|
|||
CACHE PATH "Location of KiCad data files.")
|
||||
set(KICAD_DOCS share/doc/kicad
|
||||
CACHE PATH "Location of KiCad documentation files.")
|
||||
endif(UNIX)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(MINGW)
|
||||
# Like all variables, CMAKE_INSTALL_PREFIX can be over-ridden on the command line.
|
||||
set(CMAKE_INSTALL_PREFIX c:/kicad
|
||||
CACHE PATH "")
|
||||
|
@ -215,7 +222,7 @@ if(WIN32)
|
|||
CACHE PATH "Location of KiCad data files.")
|
||||
set(KICAD_DOCS doc
|
||||
CACHE PATH "Location of KiCad documentation files.")
|
||||
endif(WIN32)
|
||||
endif()
|
||||
|
||||
set(KICAD_DEMOS ${KICAD_DATA}/demos
|
||||
CACHE PATH "Location of KiCad demo files.")
|
||||
|
@ -223,11 +230,11 @@ set(KICAD_TEMPLATE ${KICAD_DATA}/template
|
|||
CACHE PATH "Location of KiCad template files.")
|
||||
|
||||
mark_as_advanced(KICAD_BIN
|
||||
KICAD_PLUGINS
|
||||
KICAD_DATA
|
||||
KICAD_DOCS
|
||||
KICAD_DEMOS
|
||||
KICAD_TEMPLATE)
|
||||
KICAD_PLUGINS
|
||||
KICAD_DATA
|
||||
KICAD_DOCS
|
||||
KICAD_DEMOS
|
||||
KICAD_TEMPLATE)
|
||||
|
||||
include(Functions)
|
||||
|
||||
|
@ -278,10 +285,10 @@ include(PerformFeatureChecks)
|
|||
perform_feature_checks()
|
||||
|
||||
# Find GDI+ on windows if wxGraphicsContext is available.
|
||||
if(WIN32 AND USE_WX_GRAPHICS_CONTEXT)
|
||||
if(MINGW AND USE_WX_GRAPHICS_CONTEXT)
|
||||
find_package(GdiPlus)
|
||||
check_find_package_result(GDI_PLUS_FOUND "GDI+")
|
||||
endif(WIN32 AND USE_WX_GRAPHICS_CONTEXT)
|
||||
endif()
|
||||
|
||||
# Find Python and other scripting resources
|
||||
if(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
|
||||
|
@ -299,8 +306,8 @@ if(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
|
|||
|
||||
if(NOT PYTHON_SITE_PACKAGE_PATH)
|
||||
message(FATAL_ERROR "Error occurred while attemping to find the Python site library path.")
|
||||
endif(NOT PYTHON_SITE_PACKAGE_PATH)
|
||||
endif(NOT PYTHON_SITE_PACKAGE_PATH)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}" CACHE PATH "Python module install path.")
|
||||
mark_as_advanced(PYTHON_DEST)
|
||||
|
@ -322,7 +329,7 @@ if(EXISTS ${CMAKE_SOURCE_DIR}/include/config.h)
|
|||
# This directive means the about box will have the svn date & revision in it,
|
||||
# but the hard coded release date (program version) will be preserved.
|
||||
add_definitions(-DHAVE_SVN_REVISION)
|
||||
endif(EXISTS ${CMAKE_SOURCE_DIR}/include/config.h)
|
||||
endif()
|
||||
|
||||
# For include_directories(BEFORE ...), which _reverses_
|
||||
# the order during insertion, so put first wanted last, which is
|
||||
|
@ -383,7 +390,7 @@ if(DOXYGEN_FOUND)
|
|||
DEPENDS Doxyfile
|
||||
COMMENT "building doxygen docs into directory Documentation/doxygen/html"
|
||||
)
|
||||
else(DOXYGEN_FOUND)
|
||||
else()
|
||||
message( STATUS "WARNING: Doxygen not found - doxygen-docs (Source Docs) target not created" )
|
||||
endif()
|
||||
|
||||
|
@ -404,11 +411,13 @@ add_custom_target(uninstall
|
|||
# Installation parameters
|
||||
#================================================
|
||||
install(FILES INSTALL.txt
|
||||
DESTINATION ${KICAD_DOCS}
|
||||
COMPONENT resources)
|
||||
DESTINATION ${KICAD_DOCS}
|
||||
COMPONENT resources)
|
||||
|
||||
install(FILES resources/freeroute.jnlp
|
||||
DESTINATION ${KICAD_BIN}
|
||||
COMPONENT resources)
|
||||
DESTINATION ${KICAD_BIN}
|
||||
COMPONENT resources)
|
||||
|
||||
###
|
||||
# Install scripts
|
||||
###
|
||||
|
@ -417,7 +426,8 @@ if(UNIX)
|
|||
DESTINATION ${KICAD_DOCS}
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
endif(UNIX)
|
||||
endif()
|
||||
|
||||
###
|
||||
# FreeDesktop .desktop and MIME resources
|
||||
###
|
||||
|
@ -431,27 +441,27 @@ if(UNIX)
|
|||
|
||||
# Install Mimelnk directory
|
||||
install(DIRECTORY ${UNIX_MIMELNK_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
|
||||
# Install Mime directory
|
||||
install(DIRECTORY ${UNIX_ICONS_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
|
||||
# Install Icons
|
||||
install(DIRECTORY ${UNIX_MIME_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
|
||||
# Install Applications directory (.desktop files)
|
||||
install(DIRECTORY ${UNIX_APPLICATIONS_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
endif(UNIX)
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
endif()
|
||||
|
||||
include(CTest)
|
||||
|
|
|
@ -2,12 +2,13 @@ Introduction
|
|||
------------
|
||||
|
||||
This document details how to build KiCad from source on Windows. The current
|
||||
supported method of building KiCad on Windows systems is to use MinGW,
|
||||
either from MSYS or cross compiling from Linux. Visual Studio is not
|
||||
supported, and don't ask about it, it is not supported and will not be.
|
||||
supported method of building KiCad for Windows systems is to use the MinGW
|
||||
compiler, either from Windows or cross compiling from Linux. MSYS can be
|
||||
used on Windows to extend the range of subprojects that you can build, but
|
||||
is not needed to build KiCad itself.
|
||||
|
||||
If you add or remove any of the KiCad build dependencies, please update this
|
||||
document.
|
||||
Visual Studio is not supported, and don't ask about it, it is not supported
|
||||
and will not be, ever.
|
||||
|
||||
Install Build Tools
|
||||
-------------------
|
||||
|
|
Loading…
Reference in New Issue