From f29a78d4263c9edfc8f14fa2e2b6f7c0adbc1e79 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 28 Aug 2018 18:30:41 +0200 Subject: [PATCH] [cmake] Use tcl/tk provided by Python 3.7 on MacOS --- cmake/external_projects/tcltk.cmake | 36 ++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/cmake/external_projects/tcltk.cmake b/cmake/external_projects/tcltk.cmake index 3ef3c6b5..06852df1 100644 --- a/cmake/external_projects/tcltk.cmake +++ b/cmake/external_projects/tcltk.cmake @@ -1,6 +1,40 @@ if(APPLE) # use system tcl/tk - find_package(TCL 8.5 REQUIRED) + if(${PYTHON_VERSION_STRING} STREQUAL "3.7") + # fetch tcl/tk sources to match the one used in Python 3.7 + ExternalProject_Add(project_tcl + URL "https://prdownloads.sourceforge.net/tcl/tcl8.6.8-src.tar.gz" + URL_MD5 81656d3367af032e0ae6157eff134f89 + DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies + UPDATE_COMMAND "" # Disable update + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) + ExternalProject_Add(project_tk + URL "https://prdownloads.sourceforge.net/tcl/tk8.6.8-src.tar.gz" + URL_MD5 5e0faecba458ee1386078fb228d008ba + DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies + UPDATE_COMMAND "" # Disable update + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + ) + + get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARY} DIRECTORY) + find_library(TCL_LIBRARY libtcl8.6.dylib PATHS ${PYTHON_LIB_DIR} NO_DEFAULT_PATH) + find_library(TK_LIBRARY libtk8.6.dylib PATHS ${PYTHON_LIB_DIR} NO_DEFAULT_PATH) + + set(TCL_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_tcl) + set(TK_DIR ${CMAKE_CURRENT_BINARY_DIR}/dependencies/src/project_tk) + set(TCL_INCLUDE_PATH ${TCL_DIR}/generic;${TCL_DIR}/macosx) + set(TK_INCLUDE_PATH ${TK_DIR}/generic;${TK_DIR}/macosx;${TK_DIR}/xlib) + find_package(TCL 8.6 REQUIRED) + list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk) + + else() + find_package(TCL 8.5 REQUIRED) + endif() # set(HOME $ENV{HOME}) # set(tcl_prefix ${CMAKE_INSTALL_PREFIX}/../../) # ExternalProject_Add(project_tcl