CMake: use CMake's position independent code handling.
* Bump minimum CMake revision to 2.8.12. The CMake position independent code handling was introduced in CMake 2.8.9 but 2.8.12 is current version in Ubuntu 14.04 LTS which is a very popular distro. * CMake provides a simple declarative statement to enable PIC, so no compiler dependent handling is required. * There is also no need to tell Boost to build with -fPIC, their build system is smart enough.
This commit is contained in:
parent
893e018bc9
commit
32d4dae5ef
|
@ -9,7 +9,7 @@ endif()
|
|||
|
||||
project( kicad )
|
||||
|
||||
cmake_minimum_required( VERSION 2.8.4 FATAL_ERROR )
|
||||
cmake_minimum_required( VERSION 2.8.12 FATAL_ERROR )
|
||||
# because of http://public.kitware.com/Bug/view.php?id=10395
|
||||
|
||||
# Path to local CMake modules.
|
||||
|
@ -80,6 +80,10 @@ set( CMAKE_CXX_VISIBILITY_PRESET "hidden" )
|
|||
set( CMAKE_VISIBILITY_INLINES_HIDDEN ON )
|
||||
|
||||
|
||||
# Global setting: build everything position independent
|
||||
set( CMAKE_POSITION_INDEPENDENT_CODE ON )
|
||||
|
||||
|
||||
# CMP0063: CMake < 3.3 does not handle hidden visibility for static libraries,
|
||||
# and 3.3 is backwards compatible when the minimum version is smaller than 3.3.
|
||||
if( POLICY CMP0063 )
|
||||
|
@ -226,15 +230,6 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
|||
add_definitions(-D__USE_MINGW_ANSI_STDIO=1)
|
||||
|
||||
else()
|
||||
# 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. Subdirectories via add_subdirectores() reference this
|
||||
# variable, and it is either set or empty, empty for Windows.
|
||||
set( PIC_FLAG -fPIC )
|
||||
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PIC_FLAG}" )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PIC_FLAG}" )
|
||||
|
||||
if( NOT APPLE )
|
||||
# Thou shalt not link vaporware and tell us it's a valid DSO (apple ld doesn't support it)
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "${TO_LINKER},--no-undefined" )
|
||||
|
|
|
@ -132,8 +132,6 @@ else()
|
|||
|
||||
set( bootstrap ./bootstrap.sh --with-libraries=${libs_csv} )
|
||||
# pass to *both* C and C++ compilers
|
||||
set( BOOST_CFLAGS "cflags=${PIC_FLAG}" )
|
||||
set( BOOST_CXXFLAGS "cxxflags=${PIC_FLAG}" )
|
||||
set( BOOST_INCLUDE "${BOOST_ROOT}/include" )
|
||||
unset( b2_libs )
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue