mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-21 16:38:06 -06:00
Fix cmake warnings while searching for python
There is a new find module since cmake 3.12. Cmake 3.27 will start emitting warnings if the old modules are still in use. Current implementation supports both. As soon as we can bump our minimal cmake version to 3.12, the old support code can be dropped as well.
This commit is contained in:
parent
3aa6e60f95
commit
29b7a9099d
@ -497,19 +497,29 @@ endif()
|
|||||||
|
|
||||||
if (WITH_PYTHON)
|
if (WITH_PYTHON)
|
||||||
set (PYTHON_MIN_VERSION 3.6.0)
|
set (PYTHON_MIN_VERSION 3.6.0)
|
||||||
find_package(PythonInterp ${PYTHON_MIN_VERSION})
|
if (CMAKE_VERSION GREATER_EQUAL 3.12.0)
|
||||||
if (NOT PYTHONINTERP_FOUND)
|
find_package (Python3 ${PYTHON_MIN_VERSION} COMPONENTS Interpreter Development)
|
||||||
message(SEND_ERROR "Python support enabled, but Python interpreter not found.")
|
if (NOT Python3_FOUND)
|
||||||
endif()
|
message(SEND_ERROR "Python support enabled, but Python3 interpreter and/or libaries not found.")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
find_package(PythonInterp ${PYTHON_MIN_VERSION})
|
||||||
|
if (NOT PYTHONINTERP_FOUND)
|
||||||
|
message(SEND_ERROR "Python support enabled, but Python interpreter not found.")
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(PythonLibs ${PYTHON_MIN_VERSION})
|
find_package(PythonLibs ${PYTHON_MIN_VERSION})
|
||||||
if (NOT PYTHONLIBS_FOUND)
|
if (NOT PYTHONLIBS_FOUND)
|
||||||
message(SEND_ERROR "Python support enabled, but Python libraries not found.")
|
message(SEND_ERROR "Python support enabled, but Python libraries not found.")
|
||||||
|
endif()
|
||||||
|
set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||||
|
set(Python3_LIBRARIES ${PYTHON_LIBRARIES})
|
||||||
|
set(Python3_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Determine where to install the python libraries.
|
# Determine where to install the python libraries.
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${PYTHON_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}', plat_specific=True))"
|
COMMAND ${Python3_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(prefix='${CMAKE_INSTALL_PREFIX}', plat_specific=True))"
|
||||||
RESULT_VARIABLE PYTHON_SYSCONFIG_RESULT
|
RESULT_VARIABLE PYTHON_SYSCONFIG_RESULT
|
||||||
OUTPUT_VARIABLE PYTHON_SYSCONFIG_OUTPUT
|
OUTPUT_VARIABLE PYTHON_SYSCONFIG_OUTPUT
|
||||||
ERROR_VARIABLE PYTHON_SYSCONFIG_ERROR
|
ERROR_VARIABLE PYTHON_SYSCONFIG_ERROR
|
||||||
|
@ -73,13 +73,13 @@ if(WITH_PYTHON)
|
|||||||
${CMAKE_SOURCE_DIR}/libgnucash/app-utils
|
${CMAKE_SOURCE_DIR}/libgnucash/app-utils
|
||||||
${CMAKE_SOURCE_DIR}/gnucash/gnome
|
${CMAKE_SOURCE_DIR}/gnucash/gnome
|
||||||
${CMAKE_SOURCE_DIR}/libgnucash/core-utils
|
${CMAKE_SOURCE_DIR}/libgnucash/core-utils
|
||||||
${PYTHON_INCLUDE_DIRS}
|
${Python3_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(gnucash_core_c MODULE ${SWIG_GNUCASH_CORE_C})
|
add_library(gnucash_core_c MODULE ${SWIG_GNUCASH_CORE_C})
|
||||||
target_include_directories(gnucash_core_c PRIVATE ${gnucash_core_c_INCLUDE_DIRS})
|
target_include_directories(gnucash_core_c PRIVATE ${gnucash_core_c_INCLUDE_DIRS})
|
||||||
|
|
||||||
target_link_libraries(gnucash_core_c gnc-app-utils gnc-engine ${PYTHON_LIBRARIES})
|
target_link_libraries(gnucash_core_c gnc-app-utils gnc-engine ${Python3_LIBRARIES})
|
||||||
set_target_properties(gnucash_core_c PROPERTIES PREFIX "_")
|
set_target_properties(gnucash_core_c PROPERTIES PREFIX "_")
|
||||||
target_compile_options(gnucash_core_c PRIVATE -Wno-implicit -Wno-missing-prototypes -Wno-declaration-after-statement -Wno-missing-declarations)
|
target_compile_options(gnucash_core_c PRIVATE -Wno-implicit -Wno-missing-prototypes -Wno-declaration-after-statement -Wno-missing-declarations)
|
||||||
if (HAVE_STRINGOP_TRUNCATION)
|
if (HAVE_STRINGOP_TRUNCATION)
|
||||||
@ -87,7 +87,7 @@ if(WITH_PYTHON)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(sqlite3test EXCLUDE_FROM_ALL sqlite3test.c ${SWIG_GNUCASH_CORE_C})
|
add_executable(sqlite3test EXCLUDE_FROM_ALL sqlite3test.c ${SWIG_GNUCASH_CORE_C})
|
||||||
target_link_libraries(sqlite3test gnc-app-utils gnc-engine ${PYTHON_LIBRARIES})
|
target_link_libraries(sqlite3test gnc-app-utils gnc-engine ${Python3_LIBRARIES})
|
||||||
target_include_directories(sqlite3test PRIVATE ${gnucash_core_c_INCLUDE_DIRS})
|
target_include_directories(sqlite3test PRIVATE ${gnucash_core_c_INCLUDE_DIRS})
|
||||||
target_compile_options(sqlite3test PRIVATE -Wno-implicit -Wno-missing-prototypes -Wno-declaration-after-statement -Wno-missing-declarations)
|
target_compile_options(sqlite3test PRIVATE -Wno-implicit -Wno-missing-prototypes -Wno-declaration-after-statement -Wno-missing-declarations)
|
||||||
if (HAVE_STRINGOP_TRUNCATION)
|
if (HAVE_STRINGOP_TRUNCATION)
|
||||||
@ -122,7 +122,7 @@ if(WITH_PYTHON)
|
|||||||
|
|
||||||
add_library (sw_core_utils MODULE ${SWIG_CORE_UTILS_PYTHON_C})
|
add_library (sw_core_utils MODULE ${SWIG_CORE_UTILS_PYTHON_C})
|
||||||
|
|
||||||
target_link_libraries(sw_core_utils gnc-core-utils ${PYTHON_LIBRARIES})
|
target_link_libraries(sw_core_utils gnc-core-utils ${Python3_LIBRARIES})
|
||||||
set_target_properties(sw_core_utils PROPERTIES PREFIX "_")
|
set_target_properties(sw_core_utils PROPERTIES PREFIX "_")
|
||||||
|
|
||||||
if (HAVE_STRINGOP_TRUNCATION)
|
if (HAVE_STRINGOP_TRUNCATION)
|
||||||
@ -131,7 +131,7 @@ if(WITH_PYTHON)
|
|||||||
|
|
||||||
target_include_directories (sw_core_utils
|
target_include_directories (sw_core_utils
|
||||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
PRIVATE ${PYTHON_INCLUDE_DIRS}
|
PRIVATE ${Python3_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
target_compile_definitions (sw_core_utils PRIVATE -DG_LOG_DOMAIN=\"gnc.core-utils\")
|
target_compile_definitions (sw_core_utils PRIVATE -DG_LOG_DOMAIN=\"gnc.core-utils\")
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ if(WITH_PYTHON)
|
|||||||
set(PYEXEC_FILES sw_app_utils.py)
|
set(PYEXEC_FILES sw_app_utils.py)
|
||||||
add_library (sw_app_utils MODULE ${SWIG_APP_UTILS_PYTHON_C})
|
add_library (sw_app_utils MODULE ${SWIG_APP_UTILS_PYTHON_C})
|
||||||
|
|
||||||
target_link_libraries(sw_app_utils gnc-app-utils ${app_utils_ALL_LIBRARIES} ${PYTHON_LIBRARIES})
|
target_link_libraries(sw_app_utils gnc-app-utils ${app_utils_ALL_LIBRARIES} ${Python3_LIBRARIES})
|
||||||
set_target_properties(sw_app_utils PROPERTIES PREFIX "_")
|
set_target_properties(sw_app_utils PROPERTIES PREFIX "_")
|
||||||
if (HAVE_STRINGOP_TRUNCATION)
|
if (HAVE_STRINGOP_TRUNCATION)
|
||||||
target_compile_options(sw_app_utils PRIVATE -Wno-error=stringop-truncation)
|
target_compile_options(sw_app_utils PRIVATE -Wno-error=stringop-truncation)
|
||||||
@ -168,7 +168,7 @@ if(WITH_PYTHON)
|
|||||||
|
|
||||||
target_include_directories (sw_app_utils
|
target_include_directories (sw_app_utils
|
||||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
PRIVATE ${app_utils_ALL_INCLUDES} ${PYTHON_INCLUDE_DIRS}
|
PRIVATE ${app_utils_ALL_INCLUDES} ${Python3_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
target_compile_definitions (sw_app_utils PRIVATE -DG_LOG_DOMAIN=\"gnc.app-utils\")
|
target_compile_definitions (sw_app_utils PRIVATE -DG_LOG_DOMAIN=\"gnc.app-utils\")
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ if (WITH_PYTHON)
|
|||||||
endif()
|
endif()
|
||||||
add_custom_target(test-python-bindings ALL DEPENDS unittest_support gnucash-core-c-build gnucash-core-c-py sw-core-utils-build sw-core-utils-py sw-app-utils-build sw-app-utils-py)
|
add_custom_target(test-python-bindings ALL DEPENDS unittest_support gnucash-core-c-build gnucash-core-c-py sw-core-utils-build sw-core-utils-py sw-app-utils-build sw-app-utils-py)
|
||||||
add_dependencies(check test-python-bindings)
|
add_dependencies(check test-python-bindings)
|
||||||
add_test(python-bindings ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/runTests.py.in)
|
add_test(python-bindings ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/runTests.py.in)
|
||||||
set_property(TEST python-bindings PROPERTY ENVIRONMENT
|
set_property(TEST python-bindings PROPERTY ENVIRONMENT
|
||||||
GNC_BUILDDIR=${CMAKE_BINARY_DIR}
|
GNC_BUILDDIR=${CMAKE_BINARY_DIR}
|
||||||
PYTHONPATH=${PYTHON_SYSCONFIG_BUILD}:${LIBDIR_BUILD}/gnucash:${test_core_dir}
|
PYTHONPATH=${PYTHON_SYSCONFIG_BUILD}:${LIBDIR_BUILD}/gnucash:${test_core_dir}
|
||||||
|
@ -45,8 +45,8 @@ add_dependencies (test-core-guile swig-unittest-support-guile-c )
|
|||||||
|
|
||||||
if (WITH_PYTHON)
|
if (WITH_PYTHON)
|
||||||
add_library(unittest_support MODULE ${SWIG_UNITTEST_SUPPORT_PYTHON_C})
|
add_library(unittest_support MODULE ${SWIG_UNITTEST_SUPPORT_PYTHON_C})
|
||||||
target_link_libraries(unittest_support test-core ${PYTHON_LIBRARIES})
|
target_link_libraries(unittest_support test-core ${Python3_LIBRARIES})
|
||||||
target_include_directories(unittest_support PRIVATE ${PYTHON_INCLUDE_DIRS})
|
target_include_directories(unittest_support PRIVATE ${Python3_INCLUDE_DIRS})
|
||||||
set_target_properties(unittest_support PROPERTIES PREFIX "_")
|
set_target_properties(unittest_support PROPERTIES PREFIX "_")
|
||||||
if (HAVE_STRINGOP_TRUNCATION)
|
if (HAVE_STRINGOP_TRUNCATION)
|
||||||
target_compile_options(unittest_support PRIVATE -Wno-error=stringop-truncation)
|
target_compile_options(unittest_support PRIVATE -Wno-error=stringop-truncation)
|
||||||
|
@ -15,7 +15,7 @@ if (WITH_PYTHON)
|
|||||||
add_library(gncmod-python ${gncmod_python_SOURCES})
|
add_library(gncmod-python ${gncmod_python_SOURCES})
|
||||||
# target_link_libraries(gncmod-python gnc-module gnc-core-utils-python gnc-app-utils-python
|
# target_link_libraries(gncmod-python gnc-module gnc-core-utils-python gnc-app-utils-python
|
||||||
target_link_libraries(gncmod-python gnc-module gnc-core-utils
|
target_link_libraries(gncmod-python gnc-module gnc-core-utils
|
||||||
${PYTHON_LIBRARIES}) # ${PYTHON_EXTRA_LIBS}
|
${Python3_LIBRARIES}) # ${PYTHON_EXTRA_LIBS}
|
||||||
target_include_directories(gncmod-python
|
target_include_directories(gncmod-python
|
||||||
PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/libgnucash/core-utils ${CMAKE_SOURCE_DIR}/gnc-module ${PYTHON_INCLUDE_DIR})
|
PRIVATE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/libgnucash/core-utils ${CMAKE_SOURCE_DIR}/gnc-module ${PYTHON_INCLUDE_DIR})
|
||||||
target_compile_options(gncmod-python PRIVATE -DG_LOG_DOMAIN=\"gnc.python\")
|
target_compile_options(gncmod-python PRIVATE -DG_LOG_DOMAIN=\"gnc.python\")
|
||||||
|
Loading…
Reference in New Issue
Block a user