##// END OF EJS Templates
Add PythonQt*Config.cmake
Orochimarufan -
r211:6242b5a89014
parent child
Show More
@@ -0,0 +1,24
1 cmake_policy(SET CMP0007 OLD)
2
3 if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
4 message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
5 endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
6
7 file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
8 string(REGEX REPLACE "\n" ";" files "${files}")
9 list(REVERSE files)
10 foreach (file ${files})
11 message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
12 if (EXISTS "$ENV{DESTDIR}${file}")
13 execute_process(
14 COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
15 OUTPUT_VARIABLE rm_out
16 RESULT_VARIABLE rm_retval
17 )
18 if(NOT ${rm_retval} EQUAL 0)
19 message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
20 endif (NOT ${rm_retval} EQUAL 0)
21 else (EXISTS "$ENV{DESTDIR}${file}")
22 message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
23 endif (EXISTS "$ENV{DESTDIR}${file}")
24 endforeach(file)
@@ -0,0 +1,21
1 # - Config file for the PythonQt package
2 # It defines the following variables
3 # PythonQt - the PythonQt core target (PythonQt PythonQt_3 PythonQt5 PythonQt5_3)
4 # PythonQt_QtAll - the PythonQt QtAll target
5 # PythonQt_QtAll_INCLUDE_DIRS - include directories for PythonQt
6 # PythonQt_QtAll_LIBRARIES - libraries to link against
7
8 set(PythonQt @PythonQt@)
9 set(PythonQt_QtAll @PythonQt_QtAll@)
10
11 # Compute paths
12 get_filename_component(PYTHONQT_QTALL_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
13 set(PythonQt_QtAll_INCLUDE_DIRS "@INCLUDE_DIRS@")
14
15 # Our library dependencies (contains definitions for IMPORTED targets)
16 if(NOT TARGET @PythonQt_QtAll@)
17 include("${PYTHONQT_QTALL_CMAKE_DIR}/@PythonQt_QtAll@Targets.cmake")
18 endif()
19
20 # These are IMPORTED targets created by @PythonQt_QtAll@Targets.cmake
21 set(PythonQt_QtAll_LIBRARIES @PythonQt_QtAll@)
@@ -0,0 +1,11
1 set(PACKAGE_VERSION "@PythonQt_VERSION@")
2
3 # Check whether the requested PACKAGE_FIND_VERSION is compatible
4 if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
5 set(PACKAGE_VERSION_COMPATIBLE FALSE)
6 else()
7 set(PACKAGE_VERSION_COMPATIBLE TRUE)
8 if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
9 set(PACKAGE_VERSION_EXACT TRUE)
10 endif()
11 endif()
@@ -0,0 +1,22
1 # - Config file for the PythonQt package
2 # It defines the following variables
3 # PythonQt - the PythonQt core target (PythonQt PythonQt_3 PythonQt5 PythonQt5_3)
4 # PythonQt_INCLUDE_DIRS - include directories for PythonQt
5 # PythonQt_LIBRARIES - libraries to link against
6
7 set(PythonQt @PythonQt@)
8 set(PythonQt_Qt5 @PythonQt_Qt5@)
9 set(PythonQt_Python3 @PythonQt_Python3@)
10 set(PythonQt_Python @PYTHON_VERSION@)
11
12 # Compute paths
13 get_filename_component(PYTHONQT_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
14 set(PythonQt_INCLUDE_DIRS "@INCLUDE_DIRS@")
15
16 # Our library dependencies (contains definitions for IMPORTED targets)
17 if(NOT TARGET @PythonQt@)
18 include("${PYTHONQT_CMAKE_DIR}/@PythonQt@Targets.cmake")
19 endif()
20
21 # These are IMPORTED targets created by @PythonQt@Targets.cmake
22 set(PythonQt_LIBRARIES @PythonQt@)
@@ -0,0 +1,11
1 set(PACKAGE_VERSION "@PythonQt_VERSION@")
2
3 # Check whether the requested PACKAGE_FIND_VERSION is compatible
4 if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
5 set(PACKAGE_VERSION_COMPATIBLE FALSE)
6 else()
7 set(PACKAGE_VERSION_COMPATIBLE TRUE)
8 if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
9 set(PACKAGE_VERSION_EXACT TRUE)
10 endif()
11 endif()
@@ -14,6 +14,10 else()
14 remove_definitions(-DPYTHONQT_DEBUG)
14 remove_definitions(-DPYTHONQT_DEBUG)
15 endif()
15 endif()
16
16
17 if(NOT CMAKE_BUILD_TYPE)
18 set(CMAKE_BUILD_TYPE Release)
19 endif()
20
17 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
18 # Qt
22 # Qt
19 option(PythonQt_Qt5 "Use Qt 5.x (5.1+)" OFF)
23 option(PythonQt_Qt5 "Use Qt 5.x (5.1+)" OFF)
@@ -110,6 +114,12 else()
110 find_package(Python 2.6 REQUIRED)
114 find_package(Python 2.6 REQUIRED)
111 endif()
115 endif()
112
116
117 if(NOT ${PYTHON_VERSION} VERSION_LESS 3)
118 set(PythonQt_Python3 ON)
119 else()
120 set(PythonQt_Python3 OFF)
121 endif()
122
113 include_directories(${PYTHON_INCLUDE_DIRS})
123 include_directories(${PYTHON_INCLUDE_DIRS})
114 add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
124 add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK)
115
125
@@ -124,11 +134,11 if(PythonQt_Qt5)
124 set(PythonQt_LibraryName ${PythonQt_LibraryName}5)
134 set(PythonQt_LibraryName ${PythonQt_LibraryName}5)
125 endif()
135 endif()
126
136
127 if(NOT ${PYTHON_VERSION} VERSION_LESS 3)
137 if(PythonQt_Python3)
128 set(PythonQt_LibraryName ${PythonQt_LibraryName}_3)
138 set(PythonQt_LibraryName ${PythonQt_LibraryName}_3)
129 endif()
139 endif()
130
140
131 if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
141 if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
132 set(PythonQt_LibrarySuffix _d)
142 set(PythonQt_LibrarySuffix _d)
133 endif()
143 endif()
134
144
@@ -147,13 +157,23 add_dependencies(test PythonQtTest)
147
157
148 #-----------------------------------------------------------------------------
158 #-----------------------------------------------------------------------------
149 # Extenseions (QtAll)
159 # Extenseions (QtAll)
150 add_subdirectory(extensions EXCLUDE_FROM_ALL)
160 add_subdirectory(extensions)
151 # QtAll alias
161 # QtAll alias
152 add_custom_target(QtAll)
162 add_custom_target(QtAll)
153 add_dependencies(QtAll PythonQt_QtAll)
163 add_dependencies(QtAll ${PythonQt_QtAll})
154
164
155 #-----------------------------------------------------------------------------
165 #-----------------------------------------------------------------------------
156 # Examples
166 # Examples
157 include_directories(src)
167 include_directories(src)
158 include_directories(extensions/PythonQt_QtAll)
168 include_directories(extensions/PythonQt_QtAll)
159 add_subdirectory(examples EXCLUDE_FROM_ALL)
169 add_subdirectory(examples EXCLUDE_FROM_ALL)
170
171 #-----------------------------------------------------------------------------
172 # uninstall target
173 configure_file(
174 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
175 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
176 IMMEDIATE @ONLY)
177
178 add_custom_target(uninstall
179 COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
@@ -27,6 +27,8 SET(DIRS
27 pygments
27 pygments
28 )
28 )
29
29
30 find_package(${PythonQt})
31
30 qt_wrap_cpp(GEN_MOC ${HEADERS})
32 qt_wrap_cpp(GEN_MOC ${HEADERS})
31
33
32 add_executable(NicePyConsole ${SOURCES} ${GEN_MOC})
34 add_executable(NicePyConsole ${SOURCES} ${GEN_MOC})
@@ -36,9 +38,7 else()
36 qt_use_modules(NicePyConsole Core Gui)
38 qt_use_modules(NicePyConsole Core Gui)
37 endif()
39 endif()
38
40
39 get_property(PythonQt_lib TARGET ${PythonQt} PROPERTY LOCATION)
41 target_link_libraries(NicePyConsole ${PythonQt} ${PythonQt_QtAll} ${PYTHON_LIBRARIES})
40 get_property(PythonQt_QtAll_lib TARGET ${PythonQt_QtAll} PROPERTY LOCATION)
41 target_link_libraries(NicePyConsole ${PythonQt_lib} ${PythonQt_QtAll_lib} ${PYTHON_LIBRARIES})
42
42
43 foreach(FILE ${FILES})
43 foreach(FILE ${FILES})
44 SET(OUT "${CMAKE_CURRENT_BINARY_DIR}/${FILE}")
44 SET(OUT "${CMAKE_CURRENT_BINARY_DIR}/${FILE}")
@@ -138,6 +138,8 endforeach()
138 # Build
138 # Build
139 set(PythonQt_QtAll ${PythonQt_LibraryName}_QtAll${PythonQt_LibrarySuffix} CACHE INTERNAL "")
139 set(PythonQt_QtAll ${PythonQt_LibraryName}_QtAll${PythonQt_LibrarySuffix} CACHE INTERNAL "")
140
140
141 find_package(${PythonQt})
142
141 include_directories(../../src)
143 include_directories(../../src)
142 add_definitions(-DPYTHONQT_QTALL_EXPORTS)
144 add_definitions(-DPYTHONQT_QTALL_EXPORTS)
143 qt_wrap_cpp(GEN_MOC ${HEADERS})
145 qt_wrap_cpp(GEN_MOC ${HEADERS})
@@ -151,10 +153,36 endif()
151 add_library(${PythonQt_QtAll} SHARED ${SOURCES} ${GEN_MOC})
153 add_library(${PythonQt_QtAll} SHARED ${SOURCES} ${GEN_MOC})
152 qt_use_modules(${PythonQt_QtAll} ${QT})
154 qt_use_modules(${PythonQt_QtAll} ${QT})
153
155
154 get_property(PythonQt_lib TARGET ${PythonQt} PROPERTY LOCATION)
156 target_link_libraries(${PythonQt_QtAll} ${PythonQt} ${PYTHON_LIBRARIES})
155 target_link_libraries(${PythonQt_QtAll} ${PythonQt_lib} ${PYTHON_LIBRARIES})
156
157
157 install(TARGETS ${PythonQt_QtAll}
158 install(TARGETS ${PythonQt_QtAll} EXPORT ${PythonQt_QtAll}Targets COMPONENT QtAll
158 RUNTIME DESTINATION bin
159 RUNTIME DESTINATION bin
159 LIBRARY DESTINATION lib
160 LIBRARY DESTINATION lib
160 ARCHIVE DESTINATION lib)
161 ARCHIVE DESTINATION lib)
162
163 #-----------------------------------------------------------------------------
164 # Export CMake Config
165
166 if(WIN32 AND NOT CYGWIN)
167 set(LIB_CMAKE_PATH "cmake")
168 else()
169 set(LIB_CMAKE_PATH "lib/cmake/${PythonQt_QtAll}")
170 endif()
171
172 export(TARGETS ${PythonQt_QtAll} ${PythonQt} FILE "${PROJECT_BINARY_DIR}/${PythonQt_QtAll}Targets.cmake")
173 export(PACKAGE ${PythonQt_QtAll})
174
175 # build tree
176 set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}")
177 configure_file(PythonQt_QtAllConfig.cmake.in "${PROJECT_BINARY_DIR}/${PythonQt_QtAll}Config.cmake" @ONLY)
178 # install tree
179 set(INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include/PythonQt/QtAll")
180 configure_file(PythonQt_QtAllConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PythonQt_QtAll}Config.cmake" @ONLY)
181 # both
182 configure_file(PythonQt_QtAllConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/${PythonQt_QtAll}ConfigVersion.cmake" @ONLY)
183
184 install(EXPORT ${PythonQt_QtAll}Targets DESTINATION "${LIB_CMAKE_PATH}" COMPONENT QtAll-dev)
185 install(FILES ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PythonQt_QtAll}Config.cmake
186 ${PROJECT_BINARY_DIR}/${PythonQt_QtAll}ConfigVersion.cmake
187 DESTINATION "${LIB_CMAKE_PATH}" COMPONENT QtAll-dev)
188
@@ -86,7 +86,7 include_directories(${CMAKE_CURRENT_SOURCE_DIR})
86 qt_wrap_cpp(GEN_MOC ${SOURCES_MOC})
86 qt_wrap_cpp(GEN_MOC ${SOURCES_MOC})
87 qt_add_resources(GEN_QRC ${SOURCES_QRC})
87 qt_add_resources(GEN_QRC ${SOURCES_QRC})
88
88
89 add_library(${PythonQt} SHARED ${SOURCES} ${GEN_MOC} ${GEN_QRC} ${HEADERS})
89 add_library(${PythonQt} SHARED ${SOURCES} ${GEN_MOC} ${GEN_QRC})
90 if(PythonQt_Qt5)
90 if(PythonQt_Qt5)
91 qt_use_modules(${PythonQt} Core Gui Widgets)
91 qt_use_modules(${PythonQt} Core Gui Widgets)
92 else()
92 else()
@@ -103,8 +103,37 set_target_properties(${PythonQt} PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_P
103 #-----------------------------------------------------------------------------
103 #-----------------------------------------------------------------------------
104 # Install library (on windows, put the dll in 'bin' and the archive in 'lib')
104 # Install library (on windows, put the dll in 'bin' and the archive in 'lib')
105
105
106 install(TARGETS ${PythonQt}
106 set_target_properties(${PythonQt} PROPERTIES PUBLIC_HEADER "${HEADERS}")
107 RUNTIME DESTINATION bin
107
108 LIBRARY DESTINATION lib
108 install(TARGETS ${PythonQt} EXPORT ${PythonQt}Targets COMPONENT core-dev
109 ARCHIVE DESTINATION lib)
109 RUNTIME DESTINATION bin COMPONENT core
110 install(FILES ${headers} DESTINATION include/PythonQt)
110 LIBRARY DESTINATION lib COMPONENT core
111 ARCHIVE DESTINATION lib COMPONENT core
112 PUBLIC_HEADER DESTINATION include/PythonQt)
113
114 #-----------------------------------------------------------------------------
115 # Export CMake Config
116
117 if(WIN32 AND NOT CYGWIN)
118 set(LIB_CMAKE_PATH "cmake")
119 else()
120 set(LIB_CMAKE_PATH "lib/cmake/${PythonQt}")
121 endif()
122
123 export(TARGETS ${PythonQt} FILE "${PROJECT_BINARY_DIR}/${PythonQt}Targets.cmake")
124 export(PACKAGE ${PythonQt})
125
126 # build tree
127 set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}")
128 configure_file(PythonQtConfig.cmake.in "${PROJECT_BINARY_DIR}/${PythonQt}Config.cmake" @ONLY)
129 # install tree
130 set(INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include/PythonQt")
131 configure_file(PythonQtConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PythonQt}Config.cmake" @ONLY)
132 # both
133 configure_file(PythonQtConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/${PythonQt}ConfigVersion.cmake" @ONLY)
134
135 install(EXPORT ${PythonQt}Targets DESTINATION "${LIB_CMAKE_PATH}" COMPONENT core-dev)
136 install(FILES ${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PythonQt}Config.cmake
137 ${PROJECT_BINARY_DIR}/${PythonQt}ConfigVersion.cmake
138 DESTINATION "${LIB_CMAKE_PATH}" COMPONENT core-dev)
139
General Comments 0
You need to be logged in to leave comments. Login now