Commit ceef480e authored by Rafael Kitover's avatar Rafael Kitover
Browse files

improve wx GCC ABI check #142

Following some suggestions from @ArtiiP, first check if there are no
issues without an -fabi-version flag, and then instead of incrementing
from 0, decrement from 15 to find the highest working ABI version.

This is very slow if the needed ABI version is 2 for example, but not
much to do about that for the time being.
parent b1937fe9
......@@ -110,20 +110,36 @@ ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX)
INCLUDE(CheckCXXSourceRuns)
UNSET(WX_ABI_MATCHES)
SET(WX_ABI_VERSION 0)
CHECK_CXX_SOURCE_RUNS("
#include <cstdlib>
#include <wx/wx.h>
SET(CURRENT_DEFS ${CMAKE_REQUIRED_DEFINITIONS})
SET(CURRENT_LIBS ${CMAKE_REQUIRED_LIBRARIES})
class MyApp : public wxAppConsole {
public:
virtual bool OnInit();
};
# currently goes up to 11 with gcc7, but we give it some room
WHILE(NOT WX_ABI_VERSION GREATER 15)
SET(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS} "-fabi-version=${WX_ABI_VERSION}")
SET(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS} "-fabi-version=${WX_ABI_VERSION}")
bool MyApp::OnInit() {
exit(0);
}
SET(WX_ABI_VAR "WX_ABI_VERSION_${WX_ABI_VERSION}")
wxIMPLEMENT_APP(MyApp);
" WX_DEFAULT_ABI_VERSION_COMPATIBLE)
CHECK_CXX_SOURCE_RUNS("
IF(NOT WX_DEFAULT_ABI_VERSION_COMPATIBLE)
# currently goes up to 11 with gcc7, but we give it some room
SET(WX_ABI_VERSION 15)
SET(CURRENT_DEFS ${CMAKE_REQUIRED_DEFINITIONS})
SET(CURRENT_LIBS ${CMAKE_REQUIRED_LIBRARIES})
WHILE(NOT WX_ABI_VERSION EQUAL -1)
SET(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS} "-fabi-version=${WX_ABI_VERSION}")
SET(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS} "-fabi-version=${WX_ABI_VERSION}")
SET(WX_ABI_VAR "WX_ABI_VERSION_${WX_ABI_VERSION}")
CHECK_CXX_SOURCE_RUNS("
#include <cstdlib>
#include <wx/wx.h>
......@@ -137,22 +153,23 @@ bool MyApp::OnInit() {
}
wxIMPLEMENT_APP(MyApp);
" ${WX_ABI_VAR})
" ${WX_ABI_VAR})
IF(${${WX_ABI_VAR}})
BREAK()
ENDIF()
IF(${${WX_ABI_VAR}})
BREAK()
ENDIF()
MATH(EXPR WX_ABI_VERSION "${WX_ABI_VERSION} + 1")
ENDWHILE()
MATH(EXPR WX_ABI_VERSION "${WX_ABI_VERSION} - 1")
ENDWHILE()
SET(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS})
SET(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS})
SET(CMAKE_REQUIRED_DEFINITIONS ${CURRENT_DEFS})
SET(CMAKE_REQUIRED_LIBRARIES ${CURRENT_LIBS})
IF(${${WX_ABI_VAR}} AND (NOT WX_ABI_VERSION EQUAL 0))
# add C++ flags
STRING(REGEX REPLACE "<FLAGS>" "<FLAGS> -fabi-version=${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -fabi-version=${WX_ABI_VERSION}")
IF(${${WX_ABI_VAR}})
# add C++ flags
STRING(REGEX REPLACE "<FLAGS>" "<FLAGS> -fabi-version=${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -fabi-version=${WX_ABI_VERSION}")
ENDIF()
ENDIF()
ENDIF()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment