| 1 |
Include(icecc.cmake) |
| 2 |
project(shiboken) |
| 3 |
|
| 4 |
cmake_minimum_required(VERSION 2.6) |
| 5 |
|
| 6 |
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules/ |
| 7 |
${CMAKE_MODULE_PATH}) |
| 8 |
|
| 9 |
find_package(Qt4 4.5.0) |
| 10 |
|
| 11 |
add_definitions(${QT_DEFINITIONS}) |
| 12 |
|
| 13 |
set(shiboken_MAJOR_VERSION "1") |
| 14 |
set(shiboken_MINOR_VERSION "1") |
| 15 |
set(shiboken_MICRO_VERSION "2") |
| 16 |
set(shiboken_VERSION "${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}.${shiboken_MICRO_VERSION}") |
| 17 |
|
| 18 |
option(BUILD_TESTS "Build tests." TRUE) |
| 19 |
option(USE_PYTHON3 "Use python3 libraries to build shiboken." FALSE) |
| 20 |
|
| 21 |
if (USE_PYTHON3) |
| 22 |
find_package(Python3Libs) |
| 23 |
find_package(Python3InterpWithDebug) |
| 24 |
#use commom vars |
| 25 |
set(PYTHONLIBS_FOUND ${PYTHON3LIBS_FOUND}) |
| 26 |
set(PYTHON_LIBRARIES ${PYTHON3_LIBRARIES}) |
| 27 |
set(PYTHON_INCLUDE_DIRS ${PYTHON3_INCLUDE_DIRS}) |
| 28 |
set(PYTHON_DEBUG_LIBRARIES ${PYTHON3_DEBUG_LIBRARIES}) |
| 29 |
set(PYTHONINTERP_FOUND ${PYTHON3INTERP_FOUND}) |
| 30 |
set(PYTHON_EXECUTABLE ${PYTHON3_EXECUTABLE}) |
| 31 |
else() |
| 32 |
find_package(PythonLibs 2.6) |
| 33 |
find_package(PythonInterpWithDebug) |
| 34 |
endif() |
| 35 |
|
| 36 |
if (NOT PYTHON_SITE_PACKAGES) |
| 37 |
execute_process( |
| 38 |
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; \\ |
| 39 |
print(sysconfig.get_python_lib(1,0,prefix='${CMAKE_INSTALL_PREFIX}'))" |
| 40 |
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES |
| 41 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 42 |
if (NOT PYTHON_SITE_PACKAGES) |
| 43 |
message(FATAL_ERROR "Could not detect Python module installation directory.") |
| 44 |
elseif (APPLE) |
| 45 |
message(STATUS "!!! The generated bindings will be installed on ${PYTHON_SITE_PACKAGES}, is it right!?") |
| 46 |
endif() |
| 47 |
endif() |
| 48 |
|
| 49 |
if(MSVC) |
| 50 |
set(CMAKE_CXX_FLAGS "/Zc:wchar_t- /GR /EHsc /DWIN32 /D_WINDOWS /D_SCL_SECURE_NO_WARNINGS") |
| 51 |
else() |
| 52 |
if(CMAKE_HOST_UNIX AND NOT CYGWIN) |
| 53 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing") |
| 54 |
endif() |
| 55 |
set(CMAKE_CXX_FLAGS_DEBUG "-g") |
| 56 |
option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0) |
| 57 |
if(ENABLE_GCC_OPTIMIZATION) |
| 58 |
set(CMAKE_BUILD_TYPE Release) |
| 59 |
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Os -Wl,-O1") |
| 60 |
if(NOT CMAKE_HOST_APPLE) |
| 61 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--hash-style=gnu") |
| 62 |
endif() |
| 63 |
endif() |
| 64 |
endif() |
| 65 |
|
| 66 |
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)" ) |
| 67 |
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) |
| 68 |
|
| 69 |
if (WIN32) |
| 70 |
set(PATH_SEP "\;") |
| 71 |
else() |
| 72 |
set(PATH_SEP ":") |
| 73 |
endif() |
| 74 |
|
| 75 |
add_subdirectory(ApiExtractor) |
| 76 |
|
| 77 |
set(generator_plugin_DIR ${LIB_INSTALL_DIR}/generatorrunner${generator_SUFFIX}) |
| 78 |
|
| 79 |
# uninstall target |
| 80 |
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake" |
| 81 |
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" |
| 82 |
IMMEDIATE @ONLY) |
| 83 |
add_custom_target(uninstall "${CMAKE_COMMAND}" |
| 84 |
-P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") |
| 85 |
|
| 86 |
set(SHIBOKEN_BUILD_TYPE "Release") |
| 87 |
if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
| 88 |
if(NOT PYTHON_DEBUG_LIBRARIES) |
| 89 |
message(FATAL_ERROR "Python debug library not found. Try compile shiboken with -DCMAKE_BUILD_TYPE=Release") |
| 90 |
endif() |
| 91 |
if(NOT PYTHON_WITH_DEBUG) |
| 92 |
message(WARNING "Compiling shiboken with debug enabled, but the python executable was not compiled with debug support.") |
| 93 |
else() |
| 94 |
add_definitions("-DPy_DEBUG") |
| 95 |
set(SBK_ADD_PY_DEBUG_DEFINITION "add_definitions(\"-DPy_DEBUG\")") |
| 96 |
set(SBK_PKG_CONFIG_PY_DEBUG_DEFINITION " -DPy_DEBUG") |
| 97 |
endif() |
| 98 |
set(SBK_PYTHON_LIBRARIES ${PYTHON_DEBUG_LIBRARIES}) |
| 99 |
set(SHIBOKEN_BUILD_TYPE "Debug") |
| 100 |
else() |
| 101 |
set(SBK_PYTHON_LIBRARIES ${PYTHON_LIBRARIES}) |
| 102 |
add_definitions("-DNDEBUG") |
| 103 |
endif() |
| 104 |
if(APPLE) |
| 105 |
set(SBK_PYTHON_LIBRARIES "-undefined dynamic_lookup") |
| 106 |
endif() |
| 107 |
|
| 108 |
if(CMAKE_VERSION VERSION_LESS 2.8) |
| 109 |
set(SBK_PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_PATH}) |
| 110 |
else() |
| 111 |
set(SBK_PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIRS}) |
| 112 |
endif() |
| 113 |
|
| 114 |
add_subdirectory(libshiboken) |
| 115 |
add_subdirectory(doc) |
| 116 |
|
| 117 |
# deps found, compile the generator. |
| 118 |
if (QT4_FOUND AND PYTHONLIBS_FOUND AND PYTHONINTERP_FOUND) |
| 119 |
add_subdirectory(generator) |
| 120 |
add_subdirectory(shibokenmodule) |
| 121 |
|
| 122 |
if (BUILD_TESTS) |
| 123 |
enable_testing() |
| 124 |
add_subdirectory(tests) |
| 125 |
endif() |
| 126 |
else() |
| 127 |
message(WARNING "Some dependencies were not found, shiboken generator compilation disabled!") |
| 128 |
endif() |
| 129 |
|
| 130 |
add_subdirectory(data) |
| 131 |
|
| 132 |
# dist target |
| 133 |
set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${shiboken_VERSION}) |
| 134 |
add_custom_target(dist |
| 135 |
COMMAND mkdir -p "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}" && |
| 136 |
git log > "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}/ChangeLog" && |
| 137 |
git archive --prefix=${ARCHIVE_NAME}/ HEAD --format=tar --output="${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" && |
| 138 |
tar -C "${CMAKE_BINARY_DIR}" --owner=root --group=root -r "${ARCHIVE_NAME}/ChangeLog" -f "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" && |
| 139 |
bzip2 -f9 "${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar" && |
| 140 |
echo "Source package created at ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2.\n" |
| 141 |
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) |