From 00d0962ac01d51a9b3d2759fede3ad483454df1e 2013-08-02 16:14:25 From: Orochimarufan Date: 2013-08-02 16:14:25 Subject: [PATCH] Fix PythonQt*Config*.cmake --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ad55cdd..f0d62ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,10 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) #----------------------------------------------------------------------------- # Debug +SET(PythonQt_VERSION 2.2.0) + +#----------------------------------------------------------------------------- +# Debug option(PythonQt_DEBUG "Enable/Disable PythonQt debug output" OFF) if(PythonQt_DEBUG) add_definitions(-DPYTHONQT_DEBUG) @@ -20,7 +24,7 @@ endif() #----------------------------------------------------------------------------- # Qt -option(PythonQt_Qt5 "Use Qt 5.x (5.1+)" OFF) +option(PythonQt_Qt5 "Use Qt 5.x" OFF) if(PythonQt_Qt5) include(PythonQt_Qt_5x) else(PythonQt_Qt5) @@ -125,24 +129,21 @@ add_definitions(-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK) #----------------------------------------------------------------------------- # Library Name -# The variable PythonQt_LibraryName contains the PythonQt core library name +# The variable PythonQt contains the PythonQt core library name # It incorporates library mayor versions -# The variable PythonQt_LibrarySuffix is "" or "_d", if it is a debug build -set(PythonQt_LibraryName PythonQt) +set(PythonQt PythonQt) if(PythonQt_Qt5) - set(PythonQt_LibraryName ${PythonQt_LibraryName}5) + set(PythonQt ${PythonQt}5) endif() if(PythonQt_Python3) - set(PythonQt_LibraryName ${PythonQt_LibraryName}_3) + set(PythonQt ${PythonQt}_3) endif() -if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") - set(PythonQt_LibrarySuffix _d) -endif() +set(CMAKE_DEBUG_POSTFIX "_d") -message(STATUS "Building ${PythonQt_LibraryName}${PythonQt_LibrarySuffix} (Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} + Python ${PYTHON_VERSION} | ${CMAKE_BUILD_TYPE})") +message(STATUS "Building ${PythonQt} (Qt ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} + Python ${PYTHON_VERSION} | ${CMAKE_BUILD_TYPE})") #----------------------------------------------------------------------------- # Core diff --git a/examples/NicePyConsole/CMakeLists.txt b/examples/NicePyConsole/CMakeLists.txt index ced1dbb..5636adb 100644 --- a/examples/NicePyConsole/CMakeLists.txt +++ b/examples/NicePyConsole/CMakeLists.txt @@ -27,8 +27,6 @@ SET(DIRS pygments ) -find_package(${PythonQt}) - qt_wrap_cpp(GEN_MOC ${HEADERS}) add_executable(NicePyConsole ${SOURCES} ${GEN_MOC}) diff --git a/extensions/PythonQt_QtAll/CMakeLists.txt b/extensions/PythonQt_QtAll/CMakeLists.txt index 236b5bf..e601815 100644 --- a/extensions/PythonQt_QtAll/CMakeLists.txt +++ b/extensions/PythonQt_QtAll/CMakeLists.txt @@ -12,14 +12,16 @@ SET(SOURCES #------------------------------------------------------------------- # Generated stuff SET(GEN ../../generated_cpp${generated_cpp_suffix}) +SET(GEN_HEADERS) +SET(GEN_SOURCES) foreach(MODULE core gui network opengl sql svg uitools webkit xml) SET(MODULE_TROLL com_trolltech_qt_${MODULE}) SET(MODULE_BASE ${GEN}/${MODULE_TROLL}/${MODULE_TROLL}) FILE(GLOB HFILES ${MODULE_BASE}*.h) FILE(GLOB CFILES ${MODULE_BASE}*.cpp) - LIST(APPEND HEADERS ${HFILES}) - LIST(APPEND SOURCES ${CFILES}) + LIST(APPEND GEN_HEADERS ${HFILES}) + LIST(APPEND GEN_SOURCES ${CFILES}) endforeach() ## Core @@ -136,13 +138,11 @@ endforeach() #------------------------------------------------------------------- # Build -set(PythonQt_QtAll ${PythonQt_LibraryName}_QtAll${PythonQt_LibrarySuffix} CACHE INTERNAL "") - -find_package(${PythonQt}) +set(PythonQt_QtAll ${PythonQt}_QtAll CACHE INTERNAL "") include_directories(../../src) add_definitions(-DPYTHONQT_QTALL_EXPORTS) -qt_wrap_cpp(GEN_MOC ${HEADERS}) +qt_wrap_cpp(GEN_MOC ${GEN_HEADERS}) SET(QT Core Gui Network OpenGL Sql Svg UiTools WebKit Xml) if(PythonQt_Qt5) @@ -150,15 +150,18 @@ if(PythonQt_Qt5) endif() -add_library(${PythonQt_QtAll} SHARED ${SOURCES} ${GEN_MOC}) +add_library(${PythonQt_QtAll} SHARED ${SOURCES} ${HEADERS} ${GEN_SOURCES} ${GEN_MOC}) qt_use_modules(${PythonQt_QtAll} ${QT}) target_link_libraries(${PythonQt_QtAll} ${PythonQt} ${PYTHON_LIBRARIES}) +set_target_properties(${PythonQt_QtAll} PROPERTIES PUBLIC_HEADER "${HEADERS}") + install(TARGETS ${PythonQt_QtAll} EXPORT ${PythonQt_QtAll}Targets COMPONENT QtAll RUNTIME DESTINATION bin LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib) + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include/PythonQt) #----------------------------------------------------------------------------- # Export CMake Config @@ -176,7 +179,7 @@ export(PACKAGE ${PythonQt_QtAll}) set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}") configure_file(PythonQt_QtAllConfig.cmake.in "${PROJECT_BINARY_DIR}/${PythonQt_QtAll}Config.cmake" @ONLY) # install tree -set(INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include/PythonQt/QtAll") +set(INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include") configure_file(PythonQt_QtAllConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PythonQt_QtAll}Config.cmake" @ONLY) # both configure_file(PythonQt_QtAllConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/${PythonQt_QtAll}ConfigVersion.cmake" @ONLY) diff --git a/extensions/PythonQt_QtAll/PythonQt_QtAllConfig.cmake.in b/extensions/PythonQt_QtAll/PythonQt_QtAllConfig.cmake.in index 72c7dcb..227f76f 100644 --- a/extensions/PythonQt_QtAll/PythonQt_QtAllConfig.cmake.in +++ b/extensions/PythonQt_QtAll/PythonQt_QtAllConfig.cmake.in @@ -4,9 +4,12 @@ # PythonQt_QtAll - the PythonQt QtAll target # PythonQt_QtAll_INCLUDE_DIRS - include directories for PythonQt # PythonQt_QtAll_LIBRARIES - libraries to link against +# PythonQt_QtAll_QT - linked Qt modules -set(PythonQt @PythonQt@) set(PythonQt_QtAll @PythonQt_QtAll@) +set(PythonQt_QtAll_QT @QT@) + +find_package(@PythonQt@) # Compute paths get_filename_component(PYTHONQT_QTALL_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) @@ -18,4 +21,4 @@ if(NOT TARGET @PythonQt_QtAll@) endif() # These are IMPORTED targets created by @PythonQt_QtAll@Targets.cmake -set(PythonQt_QtAll_LIBRARIES @PythonQt_QtAll@) +set(PythonQt_QtAll_LIBRARIES @PythonQt_QtAll@ @PythonQt@) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 67b6375..9f4dd1e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -79,14 +79,12 @@ set(SOURCES_QRC ) #----------------------------------------------------------------------------- # Build the library -set(PythonQt ${PythonQt_LibraryName}${PythonQt_LibrarySuffix} CACHE INTERNAL "") - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) qt_wrap_cpp(GEN_MOC ${SOURCES_MOC}) qt_add_resources(GEN_QRC ${SOURCES_QRC}) -add_library(${PythonQt} SHARED ${SOURCES} ${GEN_MOC} ${GEN_QRC}) +add_library(${PythonQt} SHARED ${SOURCES} ${GEN_MOC} ${GEN_QRC} ${HEADERS}) if(PythonQt_Qt5) qt_use_modules(${PythonQt} Core Gui Widgets) else() @@ -127,7 +125,7 @@ export(PACKAGE ${PythonQt}) set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}") configure_file(PythonQtConfig.cmake.in "${PROJECT_BINARY_DIR}/${PythonQt}Config.cmake" @ONLY) # install tree -set(INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include/PythonQt") +set(INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include") configure_file(PythonQtConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PythonQt}Config.cmake" @ONLY) # both configure_file(PythonQtConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/${PythonQt}ConfigVersion.cmake" @ONLY)