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
|
@ -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)
|
||||
|
@ -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 "")
|
||||
|
||||
|
@ -112,12 +119,12 @@ 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)
|
||||
else()
|
||||
message(STATUS
|
||||
"Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_RELEASE_BUILD_FLAGS}\"")
|
||||
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
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.")
|
||||
|
@ -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()
|
||||
|
||||
|
@ -406,9 +413,11 @@ add_custom_target(uninstall
|
|||
install(FILES INSTALL.txt
|
||||
DESTINATION ${KICAD_DOCS}
|
||||
COMPONENT resources)
|
||||
|
||||
install(FILES resources/freeroute.jnlp
|
||||
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
|
||||
###
|
||||
|
@ -452,6 +462,6 @@ if(UNIX)
|
|||
DESTINATION ${CMAKE_INSTALL_PREFIX}/share
|
||||
COMPONENT resources
|
||||
PATTERN ".svn" EXCLUDE)
|
||||
endif(UNIX)
|
||||
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