|
|
@ -25,7 +25,9 @@ include_directories(include) |
|
|
|
|
|
|
|
|
|
|
|
# Checking compiler options |
|
|
|
# Checking compiler options |
|
|
|
set(default_options -Wall) |
|
|
|
set(default_options -Wall) |
|
|
|
|
|
|
|
set(linker_options -Wall) |
|
|
|
include(CheckCXXCompilerFlag) |
|
|
|
include(CheckCXXCompilerFlag) |
|
|
|
|
|
|
|
set(saved_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) |
|
|
|
# C++11 is required |
|
|
|
# C++11 is required |
|
|
|
CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X) |
|
|
@ -37,28 +39,58 @@ else() |
|
|
|
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") |
|
|
|
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") |
|
|
|
endif() |
|
|
|
endif() |
|
|
|
# Link time optimization check |
|
|
|
# Link time optimization check |
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS -flto) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-flto COMPILER_SUPPORTS_FLTO) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-flto COMPILER_SUPPORTS_FLTO) |
|
|
|
if(COMPILER_SUPPORTS_FLTO AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
|
|
|
if(COMPILER_SUPPORTS_FLTO AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
|
|
|
set(default_options ${default_options} -flto) |
|
|
|
set(default_options ${default_options} -flto) |
|
|
|
|
|
|
|
set(linker_options ${linker_options} -flto) |
|
|
|
endif() |
|
|
|
endif() |
|
|
|
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS) |
|
|
|
|
|
|
|
# Clang can use lto only with gold linker |
|
|
|
|
|
|
|
if(NOT COMPILER_SUPPORTS_FLTO) |
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS -flto\ -fuse-ld=gold) |
|
|
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG(-flto\ -fuse-ld=gold COMPILER_SUPPORTS_FLTO_GOLD) |
|
|
|
|
|
|
|
if(COMPILER_SUPPORTS_FLTO_GOLD AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
|
|
|
|
|
|
|
set(default_options ${default_options} -flto) |
|
|
|
|
|
|
|
set(linker_options ${linker_options} -flto\ -fuse-ld=gold) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
# Dwarf-4 support check |
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS -gdwarf-4) |
|
|
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG(-gdwarf-4 COMPILER_SUPPORTS_DWARF4) |
|
|
|
|
|
|
|
if(COMPILER_SUPPORTS_DWARF4 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")) |
|
|
|
|
|
|
|
set(default_options ${default_options} -gdwarf-4) |
|
|
|
|
|
|
|
set(linker_options ${linker_options} -gdwarf-4) |
|
|
|
|
|
|
|
endif() |
|
|
|
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS) |
|
|
|
# -ipo flag check (Intel compiler link time optimization) |
|
|
|
# -ipo flag check (Intel compiler link time optimization) |
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS -ipo) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-ipo COMPILER_SUPPORTS_IPO) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-ipo COMPILER_SUPPORTS_IPO) |
|
|
|
if(COMPILER_SUPPORTS_IPO AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
|
|
|
if(COMPILER_SUPPORTS_IPO AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug") |
|
|
|
set(default_options ${default_options} -ipo) |
|
|
|
set(default_options ${default_options} -ipo) |
|
|
|
|
|
|
|
set(linker_options ${linker_options} -ipo) |
|
|
|
endif() |
|
|
|
endif() |
|
|
|
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS) |
|
|
|
# Default hidden visibility check |
|
|
|
# Default hidden visibility check |
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS -fvisibility=hidden) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-fvisibility=hidden COMPILER_SUPPORTS_HIDDEN) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-fvisibility=hidden COMPILER_SUPPORTS_HIDDEN) |
|
|
|
if(COMPILER_SUPPORTS_HIDDEN) |
|
|
|
if(COMPILER_SUPPORTS_HIDDEN) |
|
|
|
set(default_options ${default_options} -fvisibility=hidden) |
|
|
|
set(default_options ${default_options} -fvisibility=hidden) |
|
|
|
|
|
|
|
set(linker_options ${linker_options} -fvisibility=hidden) |
|
|
|
endif() |
|
|
|
endif() |
|
|
|
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS) |
|
|
|
# Export dynamic. Required as modules mast call functions from main programm |
|
|
|
# Export dynamic. Required as modules mast call functions from main programm |
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS -Wl,--export-dynamic) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-Wl,--export-dynamic COMPILER_SUPPORTS_EXPORTDYNAMIC) |
|
|
|
CHECK_CXX_COMPILER_FLAG(-Wl,--export-dynamic COMPILER_SUPPORTS_EXPORTDYNAMIC) |
|
|
|
if(COMPILER_SUPPORTS_EXPORTDYNAMIC) |
|
|
|
if(COMPILER_SUPPORTS_EXPORTDYNAMIC) |
|
|
|
set(default_options ${default_options} -Wl,--export-dynamic) |
|
|
|
set(linker_options ${linker_options} -Wl,--export-dynamic) |
|
|
|
else() |
|
|
|
else() |
|
|
|
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no support of --export-dynamic. Please use a different C++ compiler.") |
|
|
|
message(FATAL_ERROR "The compiler ${CMAKE_CXX_COMPILER} has no support of --export-dynamic. Please use a different C++ compiler.") |
|
|
|
endif() |
|
|
|
endif() |
|
|
|
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS) |
|
|
|
add_compile_options(${default_options}) |
|
|
|
add_compile_options(${default_options}) |
|
|
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${saved_CMAKE_REQUIRED_FLAGS}) |
|
|
|
|
|
|
|
|
|
|
|
file(GLOB modules modules/*) |
|
|
|
file(GLOB modules modules/*) |
|
|
|
file(GLOB extramodules extramodules/*) |
|
|
|
file(GLOB extramodules extramodules/*) |
|
|
|