1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2025-02-19 12:04:54 +00:00

Allow user to set c++11 abi if using gcc 5

This commit is contained in:
King_DuckZ 2016-02-10 20:55:52 +01:00
parent 4cbc1c0df6
commit f094f31477
2 changed files with 47 additions and 8 deletions

View file

@ -5,9 +5,13 @@ list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
include(GetGitRevisionDescription)
include(Buildlibpqtypes)
include(gccversion)
option(DINDEXER_DEBUG_CFG_FILE "Enable to set the config file path to the build path" OFF)
option(DINDEXER_WITH_MEDIA_AUTODETECT "Enable code that tries to autodetect the media type and sets --type automatically" ON)
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION_MAJOR EQUAL "5")
option(DINDEXER_CXX11_ABI "Controls if _GLIBCXX_USE_CXX11_ABI gets set to 0 or not" ON)
endif()
set(ACTIONS_PATH "${CMAKE_CURRENT_BINARY_DIR}/src" CACHE STRING "Actions search path")
set(DB_OWNER_NAME "$ENV{USER}" CACHE STRING "Name that will be used as the DB owner name")
set(PROJECT_VERSION_BETA "1")
@ -54,14 +58,18 @@ target_include_directories(${bare_name}-inc
INTERFACE ${CMAKE_SOURCE_DIR}/include
)
add_definitions(
#workaround for a bug in gcc 5.3 that is causing exceptions to slip
#through try/catch blocks.
#WARNING: this will likely cause linking erros with boost and
#yaml-cpp unless they are also built with this option or with an
#older version of gcc.
-D_GLIBCXX_USE_CXX11_ABI=0
)
if (NOT DINDEXER_CXX11_ABI AND CMAKE_CXX_COMPILER_VERSION_MAJOR EQUAL "5")
message(STATUS "CXX11 ABI disabled (_GLIBCXX_USE_CXX11_ABI=0)")
add_definitions(
#workaround for a bug in gcc 5.3 that is causing exceptions to slip
#through try/catch blocks.
#WARNING: this will likely cause linking erros with boost and
#yaml-cpp unless they are also built with this option or with an
#older version of gcc.
-D_GLIBCXX_USE_CXX11_ABI=0
)
endif()
#Libraries
add_subdirectory(src/pq)

View file

@ -0,0 +1,31 @@
if (CMAKE_COMPILER_IS_GNUCXX)
exec_program(${CMAKE_CXX_COMPILER} ARGS --version OUTPUT_VARIABLE version_string)
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CMAKE_CXX_COMPILER_VERSION "${version_string}")
string(REGEX MATCHALL "[0-9]+" version_nums "${CMAKE_CXX_COMPILER_VERSION}")
list(GET version_nums 0 CMAKE_CXX_COMPILER_VERSION_MAJOR)
list(GET version_nums 1 CMAKE_CXX_COMPILER_VERSION_MINOR)
list(GET version_nums 2 CMAKE_CXX_COMPILER_VERSION_PATCH)
unset(version_nums)
unset(version_string)
else()
set(CMAKE_CXX_COMPILER_VERSION "0.0.0")
set(CMAKE_CXX_COMPILER_VERSION_MAJOR "0")
set(CMAKE_CXX_COMPILER_VERSION_MINOR "0")
set(CMAKE_CXX_COMPILER_VERSION_PATCH "0")
endif()
if (CMAKE_COMPILER_IS_GNUCC)
exec_program(${CMAKE_C_COMPILER} ARGS --version OUTPUT_VARIABLE version_string)
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CMAKE_C_COMPILER_VERSION "${version_string}")
string(REGEX MATCHALL "[0-9]+" version_nums "${CMAKE_C_COMPILER_VERSION}")
list(GET version_nums 0 CMAKE_C_COMPILER_VERSION_MAJOR)
list(GET version_nums 1 CMAKE_C_COMPILER_VERSION_MINOR)
list(GET version_nums 2 CMAKE_C_COMPILER_VERSION_PATCH)
unset(version_nums)
unset(version_string)
else()
set(CMAKE_C_COMPILER_VERSION "0.0.0")
set(CMAKE_C_COMPILER_VERSION_MAJOR "0")
set(CMAKE_C_COMPILER_VERSION_MINOR "0")
set(CMAKE_C_COMPILER_VERSION_PATCH "0")
endif()