Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 472348 | Differences between
and this patch

Collapse All | Expand All

(-)CMakeLists.txt (-15 / +20 lines)
Lines 1-9 Link Here
1
project(kig)
1
project(kig)
2
2
3
#
3
option(WITH_SCRIPTING "Enable python scripting support" ON)
4
# taken from kdeedu/CMakeList.txt
5
# from here...
6
set(CMAKE_MODULE_PATH ${kig_SOURCE_DIR}/cmake )
7
4
8
# search packages used by KDE
5
# search packages used by KDE
9
find_package(KDE4 4.3.80 REQUIRED)
6
find_package(KDE4 4.3.80 REQUIRED)
Lines 29-35 Link Here
29
include_directories (${QDBUS_INCLUDE_DIRS}  ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
26
include_directories (${QDBUS_INCLUDE_DIRS}  ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES})
30
27
31
# ...to here
28
# ...to here
32
find_package(BoostPython)
29
if(WITH_SCRIPTING)
30
  set(PythonLibs_FIND_VERSION "2.2")
31
  find_package(PythonLibs)
32
  find_package(Boost COMPONENTS python)
33
endif(WITH_SCRIPTING)
34
35
if(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
36
  set(KIG_ENABLE_PYTHON_SCRIPTING 1)
37
endif(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
33
38
34
kde4_no_enable_final(kig)
39
kde4_no_enable_final(kig)
35
40
Lines 44-59 Link Here
44
#add_subdirectory( kfile )
49
#add_subdirectory( kfile )
45
add_subdirectory( data )
50
add_subdirectory( data )
46
add_subdirectory( pykig )
51
add_subdirectory( pykig )
47
if(BOOST_PYTHON_FOUND)
52
if(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
48
  add_subdirectory( scripting )
53
  add_subdirectory( scripting )
49
endif(BOOST_PYTHON_FOUND)
54
endif(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
50
55
51
macro_display_feature_log()
56
macro_display_feature_log()
52
57
53
include_directories( ${CMAKE_SOURCE_DIR}/modes )
58
include_directories( ${CMAKE_SOURCE_DIR}/modes )
54
if(BOOST_PYTHON_FOUND)
59
if(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
55
  include_directories(${BOOST_PYTHON_INCLUDES})
60
  include_directories(${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
56
endif(BOOST_PYTHON_FOUND)
61
endif(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
57
62
58
# kigpart
63
# kigpart
59
64
Lines 182-188 Link Here
182
   misc/kigcoordinateprecisiondialog.ui
187
   misc/kigcoordinateprecisiondialog.ui
183
)
188
)
184
189
185
if(BOOST_PYTHON_FOUND)
190
if(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
186
  set(kigpart_PART_SRCS ${kigpart_PART_SRCS}
191
  set(kigpart_PART_SRCS ${kigpart_PART_SRCS}
187
     modes/popup/scriptactionsprovider.cc
192
     modes/popup/scriptactionsprovider.cc
188
     scripting/newscriptwizard.cc
193
     scripting/newscriptwizard.cc
Lines 193-207 Link Here
193
  )
198
  )
194
199
195
  set_source_files_properties(scripting/python_scripter.cc PROPERTIES COMPILE_FLAGS "${KDE4_ENABLE_EXCEPTIONS}")
200
  set_source_files_properties(scripting/python_scripter.cc PROPERTIES COMPILE_FLAGS "${KDE4_ENABLE_EXCEPTIONS}")
196
endif(BOOST_PYTHON_FOUND)
201
endif(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
197
202
198
203
199
kde4_add_plugin(kigpart ${kigpart_PART_SRCS})
204
kde4_add_plugin(kigpart ${kigpart_PART_SRCS})
200
205
201
target_link_libraries(kigpart ${KDE4_KPARTS_LIBS} ${KDE4_KUTILS_LIBS} )
206
target_link_libraries(kigpart ${KDE4_KPARTS_LIBS} ${KDE4_KUTILS_LIBS} )
202
if(BOOST_PYTHON_FOUND)
207
if(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
203
  target_link_libraries(kigpart ${BOOST_PYTHON_LIBS} ${KDE4_KTEXTEDITOR_LIBS})
208
  target_link_libraries(kigpart ${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES} ${KDE4_KTEXTEDITOR_LIBS})
204
endif(BOOST_PYTHON_FOUND)
209
endif(Boost_PYTHON_FOUND AND PYTHONLIBS_FOUND)
205
210
206
install(TARGETS kigpart DESTINATION ${PLUGIN_INSTALL_DIR})
211
install(TARGETS kigpart DESTINATION ${PLUGIN_INSTALL_DIR})
207
212
(-)KigConfigureChecks.cmake (-3 / +1 lines)
Lines 9-16 check_function_exists(trunc HAVE_TRUNC) Link Here
9
set(CMAKE_REQUIRED_INCLUDES)
9
set(CMAKE_REQUIRED_INCLUDES)
10
set(CMAKE_REQUIRED_LIBRARIES)
10
set(CMAKE_REQUIRED_LIBRARIES)
11
11
12
macro_optional_find_package(BoostPython)
13
14
# at the end, output the configuration
12
# at the end, output the configuration
15
configure_file(
13
configure_file(
16
   ${CMAKE_CURRENT_SOURCE_DIR}/config-kig.h.cmake
14
   ${CMAKE_CURRENT_SOURCE_DIR}/config-kig.h.cmake
Lines 18-24 configure_file( Link Here
18
)
16
)
19
17
20
macro_log_feature(
18
macro_log_feature(
21
   BOOST_PYTHON_FOUND
19
   Boost_PYTHON_FOUND
22
   "Boost.Python"
20
   "Boost.Python"
23
   "Kig can optionally use Boost.Python for Python scripting"
21
   "Kig can optionally use Boost.Python for Python scripting"
24
   "http://www.boost.org/"
22
   "http://www.boost.org/"
(-)cmake/COPYING-CMAKE-SCRIPTS (-22 lines)
Lines 1-22 Link Here
1
Redistribution and use in source and binary forms, with or without
2
modification, are permitted provided that the following conditions
3
are met:
4
5
1. Redistributions of source code must retain the copyright
6
   notice, this list of conditions and the following disclaimer.
7
2. Redistributions in binary form must reproduce the copyright
8
   notice, this list of conditions and the following disclaimer in the
9
   documentation and/or other materials provided with the distribution.
10
3. The name of the author may not be used to endorse or promote products 
11
   derived from this software without specific prior written permission.
12
13
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(-)cmake/FindBoostPython.cmake (-163 lines)
Lines 1-163 Link Here
1
# - Try to find the a valid boost+python combination
2
# Once done this will define
3
#
4
#  BOOST_PYTHON_FOUND - system has a valid boost+python combination
5
#  BOOST_PYTHON_INCLUDES - the include directory for boost+python
6
#  BOOST_PYTHON_LIBS - the needed libs for boost+python
7
8
# Copyright (c) 2006, Pino Toscano, <toscano.pino@tiscali.it>
9
#
10
# Redistribution and use is allowed according to the terms of the BSD license.
11
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
12
13
if(BOOST_PYTHON_INCLUDES AND BOOST_PYTHON_LIBS)
14
    # Already in cache, be silent
15
	set(BOOST_PYTHON_FIND_QUIETLY TRUE)
16
endif(BOOST_PYTHON_INCLUDES AND BOOST_PYTHON_LIBS)
17
18
# some needed includes
19
include(CheckCXXSourceCompiles)
20
include(CheckIncludeFileCXX)
21
include(CheckLibraryExists)
22
23
find_package(PkgConfig)
24
25
# reset vars
26
set(BOOST_PYTHON_INCLUDES)
27
set(BOOST_PYTHON_LIBS)
28
29
# handy arrays
30
set(PYTHON_VERSIONS "python;python2.7;python2.6;python2.5;python2.4;python2.3;python2.2")
31
set(PYTHON_INCLUDE_DIRS "/usr/include/$pyver;/usr/local/include/$pyver;/usr/$pyver/include;/usr/local/$pyver/include;$prefix/include/$pyver;$prefix/$pyver/include")
32
set(PYTHON_LIBRARY_DIRS "/usr/lib${LIB_SUFFIX};/usr/local/lib${LIB_SUFFIX};/usr/lib${LIB_SUFFIX}/$pyver/config")
33
set(PYTHON_LIBS "boost_python-gcc-mt;boost_python-mt;boost_python-gcc-mt-1_33;boost_python-gcc-mt-1_33_1;boost_python;boost_python-gcc-mt-1_32;boost_python")
34
35
if(WIN32)
36
    set(PythonLibs_FIND_VERSION 2.7.0)
37
    find_package(PythonLibs)
38
    find_package(Boost COMPONENTS python QUIET)
39
    if(PYTHONLIBS_FOUND AND Boost_FOUND)
40
        set(BOOST_PYTHON_INCLUDES ${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
41
        set(BOOST_PYTHON_LIBS ${Boost_PYTHON_LIBRARY} ${PYTHON_LIBRARIES})
42
    endif(PYTHONLIBS_FOUND AND Boost_FOUND)
43
else(WIN32)
44
# 1st: check for boost/shared_ptr.hpp
45
check_include_file_cxx(boost/shared_ptr.hpp HAVE_BOOST_SHARED_PTR_HPP)
46
47
if(HAVE_BOOST_SHARED_PTR_HPP)
48
49
  # try pkg-config next
50
  set(_found FALSE)
51
  foreach(_pyver ${PYTHON_VERSIONS})
52
    if(NOT _found)
53
      pkg_check_modules(_python QUIET ${_pyver})
54
      if (_python_FOUND)
55
	find_package(Boost 1.33 COMPONENTS python)
56
	if (Boost_PYTHON_FOUND)
57
	  set(_found TRUE)
58
	  set(BOOST_PYTHON_INCLUDES "${_python_INCLUDE_DIRS};${Boost_INCLUDE_DIRS}")
59
          set(BOOST_PYTHON_LIBS "${_python_LDFLAGS} ${Boost_PYTHON_LIBRARY}")
60
	endif(Boost_PYTHON_FOUND)
61
      endif(_python_FOUND)
62
    endif(NOT _found)
63
  endforeach(_pyver ${PYTHON_VERSIONS})
64
65
endif(HAVE_BOOST_SHARED_PTR_HPP)
66
67
if(HAVE_BOOST_SHARED_PTR_HPP AND NOT _found)
68
  # save the old flags and setting the new ones
69
  set(_save_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
70
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
71
72
  foreach(_pyver ${PYTHON_VERSIONS})
73
    if(NOT _found)
74
      foreach(_pydir ${PYTHON_INCLUDE_DIRS})
75
76
        if(NOT _found)
77
          string(REPLACE "$pyver" "${_pyver}" _pydir ${_pydir})
78
          string(REPLACE "$prefix" "${CMAKE_INSTALL_PREFIX}" _pydir ${_pydir})
79
80
          if(EXISTS ${_pydir})
81
          if(EXISTS ${_pydir}/Python.h)
82
83
            foreach(_pylibdir ${PYTHON_LIBRARY_DIRS})
84
85
              if(NOT _found)
86
                string(REPLACE "$pyver" ${_pyver} _pylibdir ${_pylibdir})
87
88
                foreach(_pblib ${PYTHON_LIBS})
89
90
                  if(NOT _found)
91
92
                    set(CMAKE_REQUIRED_FLAGS "-L${_pylibdir}")
93
                    set(CMAKE_REQUIRED_INCLUDES ${_pydir})
94
                    set(CMAKE_REQUIRED_LIBRARIES ${_pblib} ${_pyver})
95
96
                    check_cxx_source_compiles("
97
#include <boost/python.hpp>
98
const char* greet() { return \"Hello world!\"; }
99
BOOST_PYTHON_MODULE(hello) { boost::python::def(\"greet\", greet); }
100
101
int main() { return 0; }
102
103
// some vars, in case of the compilation fail...
104
// python include dir: ${_pydir}
105
// python lib dir: ${_pylibdir}
106
// boost python lib: ${_pblib}
107
108
" boost_python_${_pylibdir}_${_pydir}_${_pblib}_compile )
109
110
                    set(CMAKE_REQUIRED_FLAGS)
111
                    set(CMAKE_REQUIRED_INCLUDES)
112
                    set(CMAKE_REQUIRED_LIBRARIES)
113
114
                    if(boost_python_${_pylibdir}_${_pydir}_${_pblib}_compile)
115
116
                        set(_found TRUE)
117
118
                        set(BOOST_PYTHON_INCLUDES ${_pydir})
119
                        set(BOOST_PYTHON_LIBS "-l${_pyver} -L${_pylibdir} -l${_pblib}")
120
121
                    endif(boost_python_${_pylibdir}_${_pydir}_${_pblib}_compile)
122
123
                  endif(NOT _found)
124
125
                endforeach(_pblib ${PYTHON_LIBS})
126
127
              endif(NOT _found)
128
129
            endforeach(_pylibdir ${PYTHON_LIBRARY_DIRS})
130
131
          endif(EXISTS ${_pydir}/Python.h)
132
          endif(EXISTS ${_pydir})
133
134
        endif(NOT _found)
135
136
      endforeach(_pydir ${PYTHON_INCLUDE_DIRS})
137
138
    endif(NOT _found)
139
140
  endforeach(_pyver ${PYTHON_VERSIONS})
141
142
  set(CMAKE_CXX_FLAGS ${_save_CMAKE_CXX_FLAGS})
143
144
endif(HAVE_BOOST_SHARED_PTR_HPP AND NOT _found)
145
endif(WIN32)
146
147
if(BOOST_PYTHON_INCLUDES AND BOOST_PYTHON_LIBS)
148
  set(BOOST_PYTHON_FOUND TRUE)
149
endif(BOOST_PYTHON_INCLUDES AND BOOST_PYTHON_LIBS)
150
151
if(BOOST_PYTHON_FOUND)
152
  if(NOT BoostPython_FIND_QUIETLY)
153
    message(STATUS "Found Boost+Python: libs ${BOOST_PYTHON_LIBS}, headers ${BOOST_PYTHON_INCLUDES}")
154
  endif(NOT BoostPython_FIND_QUIETLY)
155
  set(KIG_ENABLE_PYTHON_SCRIPTING 1)
156
else (BOOST_PYTHON_FOUND)
157
  if (BoostPython_FIND_REQUIRED)
158
    message(FATAL_ERROR "Could NOT find Boost+Python")
159
  endif(BoostPython_FIND_REQUIRED)
160
  set(KIG_ENABLE_PYTHON_SCRIPTING 0)
161
endif(BOOST_PYTHON_FOUND)
162
163
mark_as_advanced(BOOST_PYTHON_INCLUDES BOOST_PYTHON_LIBS)
(-)cmake/modules/FindBoostPython.cmake (-134 lines)
Lines 1-134 Link Here
1
# - Try to find the a valid boost+python combination
2
# Once done this will define
3
#
4
#  BOOST_PYTHON_FOUND - system has a valid boost+python combination
5
#  BOOST_PYTHON_INCLUDES - the include directory for boost+python
6
#  BOOST_PYTHON_LIBS - the needed libs for boost+python
7
8
# Copyright (c) 2006, Pino Toscano, <toscano.pino@tiscali.it>
9
#
10
# Redistribution and use is allowed according to the terms of the BSD license.
11
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
12
13
if(BOOST_PYTHON_INCLUDES AND BOOST_PYTHON_LIBS)
14
    # Already in cache, be silent
15
	set(BOOST_PYTHON_FIND_QUIETLY TRUE)
16
endif(BOOST_PYTHON_INCLUDES AND BOOST_PYTHON_LIBS)
17
18
# some needed includes
19
include(CheckCXXSourceCompiles)
20
include(CheckIncludeFileCXX)
21
include(CheckLibraryExists)
22
23
# reset vars
24
set(BOOST_PYTHON_INCLUDES)
25
set(BOOST_PYTHON_LIBS)
26
27
# handy arrays
28
set(PYTHON_VERSIONS "python;python2.7;python2.6;python2.5;python2.4;python2.3;python2.2")
29
set(PYTHON_INCLUDE_DIRS "/usr/include/$pyver;/usr/local/include/$pyver;/usr/$pyver/include;/usr/local/$pyver/include;$prefix/include/$pyver;$prefix/$pyver/include")
30
set(PYTHON_LIBRARY_DIRS "/usr/lib${LIB_SUFFIX};/usr/local/lib${LIB_SUFFIX};/usr/lib${LIB_SUFFIX}/$pyver/config")
31
set(PYTHON_LIBS "boost_python-gcc-mt;boost_python-mt;boost_python-gcc-mt-1_33;boost_python-gcc-mt-1_33_1;boost_python;boost_python-gcc-mt-1_32;boost_python")
32
33
# 1st: check for boost/shared_ptr.hpp
34
check_include_file_cxx(boost/shared_ptr.hpp HAVE_BOOST_SHARED_PTR_HPP)
35
36
if(HAVE_BOOST_SHARED_PTR_HPP)
37
38
  set(_found FALSE)
39
40
  # save the old flags and setting the new ones
41
  set(_save_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
42
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
43
44
  foreach(_pyver ${PYTHON_VERSIONS})
45
    if(NOT _found)
46
      foreach(_pydir ${PYTHON_INCLUDE_DIRS})
47
48
        if(NOT _found)
49
          string(REPLACE "$pyver" "${_pyver}" _pydir ${_pydir})
50
          string(REPLACE "$prefix" "${CMAKE_INSTALL_PREFIX}" _pydir ${_pydir})
51
52
          if(EXISTS ${_pydir})
53
          if(EXISTS ${_pydir}/Python.h)
54
55
            foreach(_pylibdir ${PYTHON_LIBRARY_DIRS})
56
57
              if(NOT _found)
58
                string(REPLACE "$pyver" ${_pyver} _pylibdir ${_pylibdir})
59
60
                foreach(_pblib ${PYTHON_LIBS})
61
62
                  if(NOT _found)
63
64
                    set(CMAKE_REQUIRED_FLAGS "-L${_pylibdir}")
65
                    set(CMAKE_REQUIRED_INCLUDES ${_pydir})
66
                    set(CMAKE_REQUIRED_LIBRARIES ${_pblib} ${_pyver})
67
68
                    check_cxx_source_compiles("
69
#include <boost/python.hpp>
70
const char* greet() { return \"Hello world!\"; }
71
BOOST_PYTHON_MODULE(hello) { boost::python::def(\"greet\", greet); }
72
73
int main() { return 0; }
74
75
// some vars, in case of the compilation fail...
76
// python include dir: ${_pydir}
77
// python lib dir: ${_pylibdir}
78
// boost python lib: ${_pblib}
79
80
" boost_python_${_pylibdir}_${_pydir}_${_pblib}_compile )
81
82
                    set(CMAKE_REQUIRED_FLAGS)
83
                    set(CMAKE_REQUIRED_INCLUDES)
84
                    set(CMAKE_REQUIRED_LIBRARIES)
85
86
                    if(boost_python_${_pylibdir}_${_pydir}_${_pblib}_compile)
87
88
                        set(_found TRUE)
89
90
                        set(BOOST_PYTHON_INCLUDES ${_pydir})
91
                        set(BOOST_PYTHON_LIBS "-l${_pyver} -L${_pylibdir} -l${_pblib}")
92
93
                    endif(boost_python_${_pylibdir}_${_pydir}_${_pblib}_compile)
94
95
                  endif(NOT _found)
96
97
                endforeach(_pblib ${PYTHON_LIBS})
98
99
              endif(NOT _found)
100
101
            endforeach(_pylibdir ${PYTHON_LIBRARY_DIRS})
102
103
          endif(EXISTS ${_pydir}/Python.h)
104
          endif(EXISTS ${_pydir})
105
106
        endif(NOT _found)
107
108
      endforeach(_pydir ${PYTHON_INCLUDE_DIRS})
109
110
    endif(NOT _found)
111
112
  endforeach(_pyver ${PYTHON_VERSIONS})
113
114
  set(CMAKE_CXX_FLAGS ${_save_CMAKE_CXX_FLAGS})
115
116
endif(HAVE_BOOST_SHARED_PTR_HPP)
117
118
if(BOOST_PYTHON_INCLUDES AND BOOST_PYTHON_LIBS)
119
  set(BOOST_PYTHON_FOUND TRUE)
120
endif(BOOST_PYTHON_INCLUDES AND BOOST_PYTHON_LIBS)
121
122
if(BOOST_PYTHON_FOUND)
123
  if(NOT BoostPython_FIND_QUIETLY)
124
    message(STATUS "Found Boost+Python: ${BOOST_PYTHON_LIBS}")
125
  endif(NOT BoostPython_FIND_QUIETLY)
126
  set(KIG_ENABLE_PYTHON_SCRIPTING 1)
127
else (BOOST_PYTHON_FOUND)
128
  if (BoostPython_FIND_REQUIRED)
129
    message(FATAL_ERROR "Could NOT find Boost+Python")
130
  endif(BoostPython_FIND_REQUIRED)
131
  set(KIG_ENABLE_PYTHON_SCRIPTING 0)
132
endif(BOOST_PYTHON_FOUND)
133
134
mark_as_advanced(BOOST_PYTHON_INCLUDES BOOST_PYTHON_LIBS)

Return to bug 472348