@ -7,15 +7,16 @@ cmake_minimum_required(VERSION 2.8)
option ( USE_LZMA "Build lzma decompression support." ON )
option ( DEBUG_EXTRA "Expensive debug options" OFF )
option ( SET_WARNING_FLAGS "Adjust compiler warning flags" ON )
option ( SET_OPTIMIZATION_FLAGS "Adjust compiler optimization flags" ON )
set ( MAN_DIR "share/man" CACHE STRING "Install location for man pages (relative to prefix)." )
set ( MAN_DIR "share/man" CACHE STRING "Install path for man pages (relative to prefix)." )
mark_as_advanced ( MAN_DIR )
# H e l p e r s c r i p s
# F o r c u s t o m c m a k e m o d u l e s .
set ( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" )
set ( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ) # F o r c u s t o m c m a k e m o d u l e s
include ( CompileCheck )
include ( VersionString )
include ( CheckSymbolExists )
@ -27,14 +28,16 @@ include(TestBigEndian)
# F i n d r e q u i r e d l i b r a r i e s
# F o r c e r e - c h e c k i n g l i b r a r i e s i f t h e c o m p i l e r o r c o m p i l e r f l a g s c h a n g e .
# F o r c e r e - c h e c k i n g l i b r a r i e s i f t h e c o m p i l e r o r c o m p i l e r f l a g s c h a n g e
if ( ( NOT LAST_CMAKE_CXX_FLAGS STREQUAL CMAKE_CXX_FLAGS )
OR ( NOT LAST_CMAKE_CXX_COMPILER STREQUAL CMAKE_CXX_COMPILER ) )
force_recheck_library ( LZMA )
force_recheck_library ( Boost )
unset ( Boost_INCLUDE_DIR CACHE )
set ( LAST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE INTERNAL "The last C++ compiler flags." )
set ( LAST_CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER}" CACHE INTERNAL "The last C++ compiler." )
set ( LAST_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE INTERNAL
" T h e l a s t C + + c o m p i l e r f l a g s " )
set ( LAST_CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER}" CACHE INTERNAL
" T h e l a s t C + + c o m p i l e r " )
endif ( )
unset ( LIBRARIES )
@ -73,44 +76,53 @@ check_link_library(iconv iconv_LIBRARIES)
if ( ${ Boost_VERSION } LESS 104800 )
# O l d e r B o o s t v e r s i o n s d o n ' t w o r k w i t h C + + 1 1
add_cxxflag ( "-std=c++03" )
else ( )
add_cxxflag ( "-std=c++11" )
endif ( )
add_cxxflag ( "-Wall" )
add_cxxflag ( "-Wextra" )
add_cxxflag ( "-Wformat=2" )
add_cxxflag ( "-Wundef" )
add_cxxflag ( "-Wpointer-arith" )
add_cxxflag ( "-Wcast-qual" )
add_cxxflag ( "-Woverloaded-virtual" )
add_cxxflag ( "-Wlogical-op" )
add_cxxflag ( "-Wliteral-conversion" )
add_cxxflag ( "-Wshift-overflow" )
add_cxxflag ( "-Woverflow" )
add_cxxflag ( "-Wbool-conversions" )
add_cxxflag ( "-Wconversion" )
add_cxxflag ( "-Wsign-conversion" )
add_cxxflag ( "-Wmissing-declarations" )
add_cxxflag ( "-Wredundant-decls" )
if ( SET_WARNING_FLAGS )
# GCC ( and compatible )
add_cxxflag ( "-Wall" )
add_cxxflag ( "-Wextra" )
add_cxxflag ( "-Wformat=2" )
add_cxxflag ( "-Wundef" )
add_cxxflag ( "-Wpointer-arith" )
add_cxxflag ( "-Wcast-qual" )
add_cxxflag ( "-Woverloaded-virtual" )
add_cxxflag ( "-Wlogical-op" )
add_cxxflag ( "-Woverflow" )
add_cxxflag ( "-Wconversion" )
add_cxxflag ( "-Wsign-conversion" )
add_cxxflag ( "-Wmissing-declarations" )
add_cxxflag ( "-Wredundant-decls" )
# c l a n g
add_cxxflag ( "-Wliteral-conversion" )
add_cxxflag ( "-Wshift-overflow" )
add_cxxflag ( "-Wbool-conversions" )
# i c c
if ( NOT DEBUG_EXTRA )
add_cxxflag ( "-wd1418" ) # ' e x t e r n a l f u n c t i o n d e f i n i t i o n w i t h n o p r i o r d e c l a r a t i o n '
endif ( )
endif ( )
if ( DEBUG_EXTRA )
add_cxxflag ( "-ftrapv" ) # t o a d d c h e c k s for ( undefined ) s i g n e d i n t e g e r o v e r f l o w
add_cxxflag ( "-fbounds-checking" )
add_cxxflag ( "-fcatch-undefined-behavior" )
add_cxxflag ( "-Wstrict-aliasing=1" )
else ( )
# - W u n i n i t i a l i z e d c a u s e s t o o m a n y f a l s e p o s i t i v e s - t h a n k s v e r y m u c h , g c c
add_cxxflag ( "-Wno-uninitialized" )
# ( c l a n g o n l y ) C o n f l i c t s w i t h u s i n g c o n s t v a r i a b l e s f o r c o n f i g u r a t i o n .
add_cxxflag ( "-Wno-constant-logical-operand" )
add_cxxflag ( "-Wno-unneeded-internal-declaration" )
add_cxxflag ( "-Wno-unused-function" )
endif ( )
# L i n k a s f e w l i b r a r i e s a s p o s s i b l e
# T h i s i s m u c h e a s i e r t h a n t r y i n g t o d e c i d e w h i c h l i b r a r i e s a r e n e e d e d f o r e a c h s y s t e m
add_ldflag ( "-Wl,--as-needed" )
if ( SET_OPTIMIZATION_FLAGS )
# L i n k a s f e w l i b r a r i e s a s p o s s i b l e
# T h i s i s m u c h e a s i e r t h a n t r y i n g t o d e c i d e w h i c h l i b r a r i e s a r e n e e d e d f o r e a c h s y s t e m
# S p e c i f i c a l l y , t h e n n e e d f o r l i b b o o s t _ s y s t e m d e p e n d s o n t h e B o o s t v e r s i o n
add_ldflag ( "-Wl,--as-needed" )
endif ( )
# C h e c k f o r o p t i o n a l f u n c t i o n a l i t y a n d s y s t e m c o n f i g u r a t i o n