Force wxWidgets 2.x with CMake

时间:2016-04-04 18:50:54

标签: cmake codeblocks wxwidgets

I'm compiling a Code::Blocks plugin. Due to incompatibilites with wxWidgets 3.0, Code::Blocks is compiled against wxWidgets 2.8.

The CMakeLists.txt for the plugin is:

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(cbvike)

SET(VERSION_SERIES 0)
SET(VERSION_MAJOR 2)
SET(VERSION_MINOR 1)

FIND_PACKAGE(wxWidgets REQUIRED)

INCLUDE_DIRECTORIES(${wxWidgets_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(/usr/include/codeblocks)
INCLUDE_DIRECTORIES(/usr/include/codeblocks/wxscintilla/include)

ADD_DEFINITIONS(-D __WXGTK__)
ADD_DEFINITIONS(-D __linux__)
ADD_DEFINITIONS(-std=c++11)

This find wxgtk 3.0 which causes some problems. I'm using Arch, so I can't only remove the development package for wxgtk 3.0 - the headers are already bundled.

How can I force wxgtk 2.x in CMake?

1 个答案:

答案 0 :(得分:1)

好吧,我曾经尝试制作一个兼容的2.x / 3.x wxWidgets系列......我从来没有发现它是否有用......所以告诉我这是否按预期工作:

# Look for wxwidgets
list (APPEND _COMP adv core base)
if (UNIX)
    set (TOOLKIT_VERSION_NEED "3.0") # change here to desired version
    set (wxWidgets_CONFIG_OPTIONS --version=${TOOLKIT_VERSION_NEED})
endif ()
find_package (wxWidgets COMPONENTS ${_COMP})
if (wxWidgets_FOUND)
    include (${wxWidgets_USE_FILE})
endif ()