Skip to content
Merged
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
59 changes: 11 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,48 +1,41 @@
cmake_minimum_required(VERSION 3.1)

#set project name and language
project(PythonScriptingInterface LANGUAGES CXX)

#Automoc and RCC ON. Needed in QT projects
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

#Set project Version
set(PythonScriptingInterface_VERSION_MAJOR "1")
set(PythonScriptingInterface_VERSION_MINOR "2")
set(PythonScriptingInterface_VERSION_PATCH "0")

set(PROJECT_VERSION "${PythonScriptingInterface_VERSION_MAJOR}.${PythonScriptingInterface_VERSION_MINOR}.${PythonScriptingInterface_VERSION_PATCH}")

#Adding cmake functions like feature_summary()
include(FeatureSummary)
include(GNUInstallDirs)

#Find dependecies
find_package(Qt5 COMPONENTS Core REQUIRED)
find_package(PythonLibs 3.8 REQUIRED)

set(QT_MAJOR_VER "5" CACHE STRING "Qt major version")
set(QTX "Qt${QT_MAJOR_VER}")

find_package(${QTX} COMPONENTS Core REQUIRED)
find_package(PythonLibs 3.8 REQUIRED)

#sum up project Files
file(GLOB SOURCES
${PROJECT_SOURCE_DIR}/src/*.cpp
)

src/*.cpp
)

file(GLOB HEADER
${PROJECT_SOURCE_DIR}/src/*.h
)
src/*.h
)

file(GLOB RESOURCES
${PROJECT_SOURCE_DIR}/*.qrc
*.qrc
)

include_directories(
${PYTHON_INCLUDE_DIRS}
)
)

#create executable
add_library(PythonScriptingInterface SHARED
${SOURCES}
${HEADER}
Expand All @@ -51,33 +44,23 @@ add_library(PythonScriptingInterface SHARED
)


#link dependencies
target_link_libraries(PythonScriptingInterface
PRIVATE
Qt5::Core
${QTX}::Core
${PYTHON_LIBRARIES}
)





#set target Version
set_target_properties(PythonScriptingInterface PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(PythonScriptingInterface PROPERTIES SOVERSION ${PythonScriptingInterface_VERSION_MAJOR})


#generate export header
include(GenerateExportHeader)
generate_export_header(PythonScriptingInterface)

#install export header
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/pythonscriptinginterface_export.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/PythonScriptingInterface
)

# announce headers - target perspective
target_include_directories(PythonScriptingInterface
PUBLIC
$<INSTALL_INTERFACE:include/PythonScriptingInterface>
Expand All @@ -86,54 +69,34 @@ target_include_directories(PythonScriptingInterface
${CMAKE_CURRENT_SOURCE_DIR}
)

# install library
install(TARGETS PythonScriptingInterface
EXPORT PythonScriptingInterfaceExport
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

# configure *ConfigVersion.cmake
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
PythonScriptingInterfaceConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
)

# configure *Config.cmake
configure_file(PythonScriptingInterfaceConfig.cmake.in PythonScriptingInterfaceConfig.cmake @ONLY)



# install *Config(Version).cmake
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/PythonScriptingInterfaceConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/PythonScriptingInterfaceConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PythonScriptingInterface
)

# install targets cmake-files
install(EXPORT PythonScriptingInterfaceExport
FILE PythonScriptingInterfaceTargets.cmake
NAMESPACE VeinMeta::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PythonScriptingInterface
)

# install public headers
install(
FILES ${HEADER}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/PythonScriptingInterface
)



# spawn out some info on configuration
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)



#





11 changes: 7 additions & 4 deletions PythonScriptingInterfaceConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
include(CMakeFindDependencyMacro)
# dependencies
find_dependency(Qt5 COMPONENTS Core REQUIRED)

if("${QT_MAJOR_VER}" STREQUAL "6")
find_dependency(Qt6 COMPONENTS Core REQUIRED)
else()
find_dependency(Qt5 COMPONENTS Core REQUIRED)
endif()

find_dependency(PythonLibs REQUIRED)

# targets file
include("${CMAKE_CURRENT_LIST_DIR}/PythonScriptingInterfaceTargets.cmake")

4 changes: 2 additions & 2 deletions src/PythonBinding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ PyObject* PythonBinding::callFunction(QString p_name,QList<PyObject*> p_args)
else {
if (PyErr_Occurred())
PyErr_Print();
qout << "Cannot find function" << p_name << endl;
qout << "Cannot find function" << p_name << Qt::endl;
}
Py_XDECREF(m_pFunc);
}else{
qout << "Module not available" << endl;
qout << "Module not available" << Qt::endl;
}


Expand Down
4 changes: 2 additions & 2 deletions src/pythonobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ PyObject* PythonObject::callFunction(const QString &p_name, QList<PyObject *> p_
else {
if (PyErr_Occurred())
PyErr_Print();
qout << "Cannot find function" << p_name << endl;
qout << "Cannot find function" << p_name << Qt::endl;
}
Py_XDECREF(m_pFunc);
Py_DECREF(m_pClass);
}else{
qout << "Module not available" << endl;
qout << "Module not available" << Qt::endl;
}


Expand Down