Commit e4d09b96 authored by Dick Hollenbeck's avatar Dick Hollenbeck
Browse files

add -fPIC for all builds, even cross comiling to Windows from Linux, even non...

add -fPIC for all builds, even cross comiling to Windows from Linux, even non Debug and Release builds
parent 89f590a1
Loading
Loading
Loading
Loading
+82 −72
Original line number Original line Diff line number Diff line
@@ -5,9 +5,9 @@ if(WIN32)
    cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)   # win32 and win64
    cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)   # win32 and win64
elseif(APPLE)
elseif(APPLE)
    cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)   # OSX
    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.
    cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)   # Linux, Unix, and everything else.
endif(WIN32)
endif()


# Path to local CMake modules.
# Path to local CMake modules.
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
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)
elif(KICAD_STABLE_VERSION)
    add_definitions(-DKICAD_STABLE_VERSION)
    add_definitions(-DKICAD_STABLE_VERSION)
    message( "Build stable version of KiCad")
    message( "Build stable version of KiCad")
else(KICAD_STABLE_VERSION AND KICAD_TESTING_VERSION)
else()
    add_definitions(-DKICAD_TESTING_VERSION)
    add_definitions(-DKICAD_TESTING_VERSION)
    message("Build testing (unstable) version of KiCad")
    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)
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_BUILD_FLAGS "-O2")
    set(KICAD_GCC_RELEASE_DEBUG_FLAGS "")
    set(KICAD_GCC_RELEASE_DEBUG_FLAGS "")


@@ -112,12 +119,12 @@ if(CMAKE_COMPILER_IS_GNUCXX)
    if(CMAKE_BUILD_TYPE STREQUAL Debug)
    if(CMAKE_BUILD_TYPE STREQUAL Debug)
        message(STATUS
        message(STATUS
            "Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_DEBUG_BUILD_FLAGS}\"")
            "Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_DEBUG_BUILD_FLAGS}\"")
    else(CMAKE_BUILD_TYPE STREQUAL Debug)
    else()
        message(STATUS
        message(STATUS
            "Setting GCC version ${GCC_VERSION} build flags \"${KICAD_GCC_RELEASE_BUILD_FLAGS}\"")
            "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 default flags for Release build.
        set(CMAKE_C_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG")
        set(CMAKE_C_FLAGS_RELEASE "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG")
        set(CMAKE_CXX_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_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
        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:
        # Thou shalt not link vaporware and tell us it's a valid DSO:
        set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
        set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined")
        set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined") # needed by SWIG macros on linux
        set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined") # needed by SWIG macros on linux


        # Set default flags for Release build.
        # Set default flags for Release build.
        set(CMAKE_C_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 "-Wall ${KICAD_GCC_RELEASE_BUILD_FLAGS} -DNDEBUG -fPIC")
        set(CMAKE_CXX_FLAGS_RELEASE "${KICAD_GCC_RELEASE_BUILD_FLAGS} -Wall -DNDEBUG")
        set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")
        set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-s")


        # Set default flags for Debug build.
        # Set default flags for Debug build.
        set(CMAKE_C_FLAGS_DEBUG "-Wall  ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG -fPIC")
        set(CMAKE_C_FLAGS_DEBUG "${KICAD_GCC_DEBUG_BUILD_FLAGS} -Wall  -g3 -ggdb3 -DDEBUG")
        set(CMAKE_CXX_FLAGS_DEBUG "-Wall  ${KICAD_GCC_DEBUG_BUILD_FLAGS} -g3 -ggdb3 -DDEBUG -fPIC")
        set(CMAKE_CXX_FLAGS_DEBUG "${KICAD_GCC_DEBUG_BUILD_FLAGS} -Wall -g3 -ggdb3 -DDEBUG")
    endif(WIN32)
    endif()


endif(CMAKE_COMPILER_IS_GNUCXX)
endif(CMAKE_COMPILER_IS_GNUCXX)


if(wxUSE_UNICODE)
if(wxUSE_UNICODE)
    add_definitions(-DwxUSE_UNICODE)
    add_definitions(-DwxUSE_UNICODE)
endif(wxUSE_UNICODE)
endif()


if(KICAD_GOST)
if(KICAD_GOST)
    add_definitions(-DKICAD_GOST)
    add_definitions(-DKICAD_GOST)
endif(KICAD_GOST)
endif()


if(KICAD_KEEPCASE)
if(KICAD_KEEPCASE)
    add_definitions(-DKICAD_KEEPCASE)
    add_definitions(-DKICAD_KEEPCASE)
endif(KICAD_KEEPCASE)
endif()


if(USE_WX_OVERLAY OR APPLE)
if(USE_WX_OVERLAY OR APPLE)
    add_definitions(-DUSE_WX_OVERLAY)
    add_definitions(-DUSE_WX_OVERLAY)
endif(USE_WX_OVERLAY OR APPLE)
endif()


if(KICAD_SCRIPTING)
if(KICAD_SCRIPTING)
    add_definitions(-DKICAD_SCRIPTING)
    add_definitions(-DKICAD_SCRIPTING)
endif(KICAD_SCRIPTING)
endif()


if(KICAD_SCRIPTING_MODULES)
if(KICAD_SCRIPTING_MODULES)
    add_definitions(-DKICAD_SCRIPTING_MODULES)
    add_definitions(-DKICAD_SCRIPTING_MODULES)
endif(KICAD_SCRIPTING_MODULES)
endif()


if(KICAD_SCRIPTING_WXPYTHON)
if(KICAD_SCRIPTING_WXPYTHON)
    add_definitions(-DKICAD_SCRIPTING_WXPYTHON)
    add_definitions(-DKICAD_SCRIPTING_WXPYTHON)
endif(KICAD_SCRIPTING_WXPYTHON)
endif()


if(USE_WX_GRAPHICS_CONTEXT)
if(USE_WX_GRAPHICS_CONTEXT)
    add_definitions(-DUSE_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
# 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
# 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 DEFINED USE_IMAGES_IN_MENUS)
    if(NOT APPLE)
    if(NOT APPLE)
        set(USE_IMAGES_IN_MENUS ON)
        set(USE_IMAGES_IN_MENUS ON)
    endif(NOT APPLE)
    endif()
else(NOT DEFINED USE_IMAGES_IN_MENUS)
else()
    if(USE_IMAGES_IN_MENUS)
    if(USE_IMAGES_IN_MENUS)
        set(USE_IMAGES_IN_MENUS ON)
        set(USE_IMAGES_IN_MENUS ON)
    endif(USE_IMAGES_IN_MENUS)
    endif()
endif(NOT DEFINED USE_IMAGES_IN_MENUS)
endif()


# Locations for install targets.
# Locations for install targets.
set(KICAD_BIN bin
set(KICAD_BIN bin
@@ -202,9 +209,9 @@ if(UNIX)
        CACHE PATH "Location of KiCad data files.")
        CACHE PATH "Location of KiCad data files.")
    set(KICAD_DOCS share/doc/kicad
    set(KICAD_DOCS share/doc/kicad
        CACHE PATH "Location of KiCad documentation files.")
        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.
    # 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 "")
        CACHE PATH "")
@@ -215,7 +222,7 @@ if(WIN32)
        CACHE PATH "Location of KiCad data files.")
        CACHE PATH "Location of KiCad data files.")
    set(KICAD_DOCS doc
    set(KICAD_DOCS doc
        CACHE PATH "Location of KiCad documentation files.")
        CACHE PATH "Location of KiCad documentation files.")
endif(WIN32)
endif()


set(KICAD_DEMOS ${KICAD_DATA}/demos
set(KICAD_DEMOS ${KICAD_DATA}/demos
    CACHE PATH "Location of KiCad demo files.")
    CACHE PATH "Location of KiCad demo files.")
@@ -278,10 +285,10 @@ include(PerformFeatureChecks)
perform_feature_checks()
perform_feature_checks()


# Find GDI+ on windows if wxGraphicsContext is available.
# 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)
    find_package(GdiPlus)
    check_find_package_result(GDI_PLUS_FOUND "GDI+")
    check_find_package_result(GDI_PLUS_FOUND "GDI+")
endif(WIN32 AND USE_WX_GRAPHICS_CONTEXT)
endif()


# Find Python and other scripting resources
# Find Python and other scripting resources
if(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
if(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)
@@ -299,8 +306,8 @@ if(KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES)


        if(NOT PYTHON_SITE_PACKAGE_PATH)
        if(NOT PYTHON_SITE_PACKAGE_PATH)
            message(FATAL_ERROR "Error occurred while attemping to find the Python site library path.")
            message(FATAL_ERROR "Error occurred while attemping to find the Python site library path.")
        endif(NOT PYTHON_SITE_PACKAGE_PATH)
        endif()
    endif(NOT PYTHON_SITE_PACKAGE_PATH)
    endif()


    set(PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}" CACHE PATH "Python module install path.")
    set(PYTHON_DEST "${PYTHON_SITE_PACKAGE_PATH}" CACHE PATH "Python module install path.")
    mark_as_advanced(PYTHON_DEST)
    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,
    # 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.
    # but the hard coded release date (program version) will be preserved.
    add_definitions(-DHAVE_SVN_REVISION)
    add_definitions(-DHAVE_SVN_REVISION)
endif(EXISTS ${CMAKE_SOURCE_DIR}/include/config.h)
endif()


# For include_directories(BEFORE ...), which _reverses_
# For include_directories(BEFORE ...), which _reverses_
# the order during insertion, so put first wanted last, which is
# the order during insertion, so put first wanted last, which is
@@ -383,7 +390,7 @@ if(DOXYGEN_FOUND)
        DEPENDS Doxyfile
        DEPENDS Doxyfile
        COMMENT "building doxygen docs into directory Documentation/doxygen/html"
        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" )
    message( STATUS "WARNING: Doxygen not found - doxygen-docs (Source Docs) target not created" )
endif()
endif()


@@ -406,9 +413,11 @@ add_custom_target(uninstall
install(FILES INSTALL.txt
install(FILES INSTALL.txt
    DESTINATION ${KICAD_DOCS}
    DESTINATION ${KICAD_DOCS}
    COMPONENT resources)
    COMPONENT resources)

install(FILES resources/freeroute.jnlp
install(FILES resources/freeroute.jnlp
    DESTINATION ${KICAD_BIN}
    DESTINATION ${KICAD_BIN}
    COMPONENT resources)
    COMPONENT resources)

###
###
# Install scripts
# Install scripts
###
###
@@ -417,7 +426,8 @@ if(UNIX)
            DESTINATION ${KICAD_DOCS}
            DESTINATION ${KICAD_DOCS}
            COMPONENT resources
            COMPONENT resources
            PATTERN ".svn" EXCLUDE)
            PATTERN ".svn" EXCLUDE)
endif(UNIX)
endif()

###
###
# FreeDesktop .desktop and MIME resources
# FreeDesktop .desktop and MIME resources
###
###
@@ -452,6 +462,6 @@ if(UNIX)
        DESTINATION ${CMAKE_INSTALL_PREFIX}/share
        DESTINATION ${CMAKE_INSTALL_PREFIX}/share
        COMPONENT resources
        COMPONENT resources
        PATTERN ".svn" EXCLUDE)
        PATTERN ".svn" EXCLUDE)
endif(UNIX)
endif()


include(CTest)
include(CTest)
+6 −5
Original line number Original line Diff line number Diff line
@@ -2,12 +2,13 @@ Introduction
------------
------------


This document details how to build KiCad from source on Windows. The current
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,
supported method of building KiCad for Windows systems is to use the MinGW
either from MSYS or cross compiling from Linux. Visual Studio is not
compiler, either from Windows or cross compiling from Linux. MSYS can be
supported, and don't ask about it, it is not supported and will not 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
Visual Studio is not supported, and don't ask about it, it is not supported
document.
and will not be, ever.


Install Build Tools
Install Build Tools
-------------------
-------------------