foobinding
CMakeLists.txt 文件内容
project(foobinding) cmake_minimum_required(VERSION 2.6) find_package(PythonLibs REQUIRED) find_package(Shiboken REQUIRED) find_package(PySide REQUIRED) find_package(Qt4 REQUIRED) include(${QT_USE_FILE}) find_program(GENERATOR generatorrunner REQUIRED) if (NOT GENERATOR) message(FATAL_ERROR "You need to specify GENERATOR variable (-DGENERATOR=value)") endif() if(MSVC) set(CMAKE_CXX_FLAGS "/Zc:wchar_t- /GR /EHsc /DNOCOLOR /DWIN32 /D_WINDOWS /D_SCL_SECURE_NO_WARNINGS") else() if(CMAKE_HOST_UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing") endif() set(CMAKE_CXX_FLAGS_DEBUG "-g") option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0) if(ENABLE_GCC_OPTIMIZATION) set(CMAKE_BUILD_TYPE Release) set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Os -Wl,-O1") if(NOT CMAKE_HOST_APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--hash-style=gnu") endif() endif() if(CMAKE_HOST_APPLE) if (NOT QT_INCLUDE_DIR) set(QT_INCLUDE_DIR "/Library/Frameworks") endif() if(ALTERNATIVE_QT_INCLUDE_DIR) set(QT_INCLUDE_DIR ${ALTERNATIVE_QT_INCLUDE_DIR}) endif() string(REPLACE " " ":" QT_INCLUDE_DIR ${QT_INCLUDE_DIR}) endif() endif() set(GENERATOR_EXTRA_FLAGS --generator-set=shiboken --enable-parent-ctor-heuristic --enable-pyside-extensions --enable-return-value-heuristic --use-isnull-as-nb_nonzero) if(WIN32 OR DEFINED AVOID_PROTECTED_HACK) message(STATUS "PySide will be generated avoiding the protected hack!") set(GENERATOR_EXTRA_FLAGS ${GENERATOR_EXTRA_FLAGS} --avoid-protected-hack) add_definitions(-DAVOID_PROTECTED_HACK) else() message(STATUS "PySide will be generated using the protected hack!") endif() if (WIN32) set(PATH_SEP "\;") else() set(PATH_SEP ":") endif() enable_testing() add_subdirectory(foo) add_subdirectory(tests)和它的前任比较,它复杂很多
除了查找python和shiboken的开发包,它还需要PySide开发环境
除了查找可执行程序generatorrunner,还需要注意它的选项(对Win下,必须 --avoid-protected-hack) 因为要用到多路径,注意不同平台的路径分割符!