Skip to content

Generate PythonQtConfig.cmake #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 32 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ endif()
# Python libraries

find_package(PythonLibs REQUIRED)
include_directories("${PYTHON_INCLUDE_DIR}")
add_definitions(
-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK
-DPYTHONQT_SUPPORT_NAME_PROPERTY
)

#-----------------------------------------------------------------------------
# Build options
Expand All @@ -78,6 +73,10 @@ if(NOT DEFINED PythonQt_INSTALL_INCLUDE_DIR)
set(PythonQt_INSTALL_INCLUDE_DIR include/PythonQt)
endif()

if(NOT DEFINED PythonQt_INSTALL_CMAKE_DIR)
set(PythonQt_INSTALL_CMAKE_DIR ${PythonQt_INSTALL_LIBRARY_DIR}/cmake/PythonQt)
endif()

#-----------------------------------------------------------------------------
# Set qtlib_to_wraplib_* variables

Expand Down Expand Up @@ -248,6 +247,7 @@ set(headers
src/PythonQtUtils.h
src/PythonQtVariants.h
src/PythonQtPythonInclude.h
src/gui/PythonQtScriptingConsole.h
generated_cpp${generated_cpp_suffix}/PythonQt_QtBindings.h
)

Expand All @@ -273,8 +273,6 @@ foreach(qtlib ${qtlibs})

if (${PythonQt_Wrap_Qt${qt_wrapped_lib}})

ADD_DEFINITIONS(-DPYTHONQT_WRAP_Qt${qt_wrapped_lib})

set(file_prefix generated_cpp${generated_cpp_suffix}/com_trolltech_qt_${qt_wrapped_lib}/com_trolltech_qt_${qt_wrapped_lib})

foreach(index RANGE 0 12)
Expand Down Expand Up @@ -303,20 +301,35 @@ pythonqt_wrap_cpp(gen_moc_sources ${moc_sources})
#-----------------------------------------------------------------------------
# Build the library

include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src
)

add_library(PythonQt SHARED
${sources}
${gen_moc_sources}
)

target_include_directories(PythonQt PUBLIC
# Python
${PYTHON_INCLUDE_DIR}

# PythonQt
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${PythonQt_INSTALL_INCLUDE_DIR}>
)

set_target_properties(PythonQt PROPERTIES DEFINE_SYMBOL PYTHONQT_EXPORTS)

target_compile_options(PythonQt PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/bigobj>
-DPYTHONQT_USE_RELEASE_PYTHON_FALLBACK
-DPYTHONQT_SUPPORT_NAME_PROPERTY
)

foreach(qtlib ${qtlibs})
set(qt_wrapped_lib ${qtlib_to_wraplib_${qtlib}})
if (${PythonQt_Wrap_Qt${qt_wrapped_lib}})
target_compile_options(PythonQt PUBLIC -DPYTHONQT_WRAP_Qt${qt_wrapped_lib})
endif()
endforeach()

target_link_libraries(PythonQt
${PYTHON_LIBRARY}
${QT_LIBRARIES}
Expand All @@ -326,11 +339,19 @@ target_link_libraries(PythonQt
# Install library (on windows, put the dll in 'bin' and the archive in 'lib')

install(TARGETS PythonQt
EXPORT PythonQtTargets
RUNTIME DESTINATION ${PythonQt_INSTALL_RUNTIME_DIR}
LIBRARY DESTINATION ${PythonQt_INSTALL_LIBRARY_DIR}
ARCHIVE DESTINATION ${PythonQt_INSTALL_ARCHIVE_DIR})
install(EXPORT PythonQtTargets DESTINATION ${PythonQt_INSTALL_CMAKE_DIR})
install(FILES ${headers} DESTINATION ${PythonQt_INSTALL_INCLUDE_DIR})

configure_file(PythonQtConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/PythonQtConfig.cmake
@ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PythonQtConfig.cmake
DESTINATION ${PythonQt_INSTALL_CMAKE_DIR})

#-----------------------------------------------------------------------------
# Testing

Expand Down
5 changes: 5 additions & 0 deletions PythonQtConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
find_package(PythonLibs REQUIRED)
find_package(Qt5 @Qt5_VERSION@ EXACT COMPONENTS @qt_required_components@ REQUIRED)

get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/PythonQtTargets.cmake)