1
1
cmake_minimum_required (VERSION 3.6 )
2
2
3
- project (pyrunner )
3
+ project (python-runner )
4
4
5
5
find_package (ECM 0.0.11 REQUIRED NO_MODULE )
6
6
set (CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} )
7
7
8
8
include (KDEInstallDirs )
9
9
include (KDECMakeSettings )
10
- # include(KDECompilerSettings)
11
10
include (FeatureSummary )
12
11
13
12
find_package (Qt5 REQUIRED COMPONENTS Widgets )
14
13
find_package (KF5 REQUIRED COMPONENTS CoreAddons Solid KIO Runner I18n )
15
14
16
15
find_package (PythonLibs 3.5 REQUIRED )
16
+ find_program (PYTHON "python" REQUIRED )
17
17
include_directories (${PYTHON_INCLUDE_DIRS} )
18
18
19
19
find_package (Boost COMPONENTS python3 REQUIRED )
20
20
include_directories (${Boost_INCLUDE_DIR} )
21
21
22
22
add_definitions (-DQT_NO_KEYWORDS )
23
+ add_definitions (-DNDEBUG )
24
+ include (CheckCXXCompilerFlag )
23
25
24
- include_directories (src )
25
-
26
- set (example_SRCS src/pyrunner.cpp )
27
-
28
- add_library (plasma_runner_pyrunner MODULE ${example_SRCS} )
29
- target_link_libraries (plasma_runner_pyrunner KF5::Runner KF5::KIOCore KF5::KIOWidgets KF5::I18n KF5::CoreAddons )
30
- target_link_libraries (plasma_runner_pyrunner Qt5::Widgets )
31
- target_link_libraries (plasma_runner_pyrunner ${Boost_LIBRARIES} )
32
- target_link_libraries (plasma_runner_pyrunner ${PYTHON_LIBRARIES} )
26
+ # http://stackoverflow.com/a/33266748/3946766
27
+ function (enable_cxx_compiler_flag_if_supported flag )
28
+ string (FIND "${CMAKE_CXX_FLAGS} " "${flag} " flag_already_set )
29
+ if (flag_already_set EQUAL -1 )
30
+ check_cxx_compiler_flag ("${flag} " flag_supported )
31
+ if (flag_supported )
32
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag} " PARENT_SCOPE )
33
+ endif ()
34
+ endif ()
35
+ endfunction ()
33
36
37
+ enable_cxx_compiler_flag_if_supported ("-Wall" )
38
+ enable_cxx_compiler_flag_if_supported ("-Wextra" )
39
+ enable_cxx_compiler_flag_if_supported ("-pedantic" )
34
40
35
41
# https://github.com/lxde/lxqt-qtplugin/blob/master/src/CMakeLists.txt
36
42
get_target_property (QT_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION )
@@ -49,12 +55,40 @@ else()
49
55
message (FATAL_ERROR "Qt5 plugin directory cannot be detected." )
50
56
endif ()
51
57
58
+ set (SETUP_PY ${CMAKE_CURRENT_SOURCE_DIR} /setup.py )
59
+
60
+ execute_process (COMMAND ${PYTHON} -config --ldflags
61
+ OUTPUT_VARIABLE PYTHON_LDFLAGS
62
+ OUTPUT_STRIP_TRAILING_WHITESPACE
63
+ ERROR_QUIET )
64
+ string (STRIP "${PYTHON_LDFLAGS} " PYTHON_LDFLAGS )
65
+
66
+
67
+ add_custom_target (sip_krunner DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /config.py )
68
+ add_custom_command (TARGET sip_krunner
69
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR} /sip_krunnerpart0.cpp ${CMAKE_CURRENT_BINARY_DIR} /sipAPI_krunner.cpp
70
+ PRE_BUILD
71
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /config.py
72
+ COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR} /config.py )
73
+
74
+ add_library (plasma_runner_python MODULE src/python-krunner.cpp ${CMAKE_CURRENT_BINARY_DIR} /sip_krunnerpart0.cpp )
75
+ add_dependencies (plasma_runner_python sip_krunner )
76
+ target_link_libraries (plasma_runner_python KF5::Runner KF5::KIOCore KF5::KIOWidgets KF5::I18n KF5::CoreAddons )
77
+ target_link_libraries (plasma_runner_python Qt5::Widgets )
78
+ target_link_libraries (plasma_runner_python ${Boost_LIBRARIES} )
79
+ target_link_libraries (plasma_runner_python ${PYTHON_LDFLAGS} )
80
+
81
+ add_custom_target (link_target ALL COMMAND ${CMAKE_COMMAND} -E create_symlink plasma_runner_python.so _krunner.so )
82
+ add_dependencies (link_target plasma_runner_python )
52
83
53
84
# Install the library and .desktop file
54
- install (TARGETS plasma_runner_pyrunner DESTINATION ${QT_PLUGINS_DIR} )
85
+ # TODO make the qt plugin a symlink
86
+ install (TARGETS plasma_runner_python DESTINATION ${QT_PLUGINS_DIR} )
55
87
install (FILES plasma-runner-pyrunner-a.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
56
88
install (FILES plasma-runner-pyrunner-b.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
57
- #
89
+
90
+ install (CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)" )
91
+
58
92
# get_cmake_property(_variableNames VARIABLES)
59
93
# foreach (_variableName ${_variableNames})
60
94
# message(STATUS "${_variableName}=${${_variableName}}")
0 commit comments