From 5571c5d0e5a0da0b714d50aafad78e98e364b12b Mon Sep 17 00:00:00 2001 From: Henri Manson Date: Thu, 28 Feb 2019 13:03:28 +0100 Subject: [PATCH 1/3] working on windows, also in unix? --- cmake/PythonSupport.cmake | 2 +- python/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/PythonSupport.cmake b/cmake/PythonSupport.cmake index 37f32c2..01ed8d3 100644 --- a/cmake/PythonSupport.cmake +++ b/cmake/PythonSupport.cmake @@ -15,7 +15,7 @@ # is Windows. Here, we need it while building, regardless of target, # on a Windows host. if (CMAKE_HOST_SYSTEM MATCHES "Windows") - set (PYTHON_PATH_SEPARATOR ";") + set (PYTHON_PATH_SEPARATOR "\;") else() set (PYTHON_PATH_SEPARATOR ":") endif() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index fee9564..0f822cb 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -16,7 +16,7 @@ AppendToPythonPath (_ppath ${CMAKE_CURRENT_SOURCE_DIR}/sully2 ) add_custom_target(ppath_test - COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${_ppath} + COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$ ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ppathtest.py ) add_custom_target(ppath_notest From 202e5d1d678dde1c789d32692d3c0d4934e8661d Mon Sep 17 00:00:00 2001 From: Henri Manson Date: Mon, 4 Mar 2019 11:10:44 +0100 Subject: [PATCH 2/3] test with spaces in directories --- python/CMakeLists.txt | 6 +++--- python/{silly1 => silly 1}/donuts/__init__.py | 0 python/{sully2 => sully 2}/bagels/__init__.py | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename python/{silly1 => silly 1}/donuts/__init__.py (100%) rename python/{sully2 => sully 2}/bagels/__init__.py (100%) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 0f822cb..7e1822f 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -12,12 +12,12 @@ if (NOT NO_TESTING) endif() AppendToPythonPath (_ppath - ${CMAKE_CURRENT_SOURCE_DIR}/silly1 - ${CMAKE_CURRENT_SOURCE_DIR}/sully2 + "${CMAKE_CURRENT_SOURCE_DIR}/silly 1" + "${CMAKE_CURRENT_SOURCE_DIR}/sully 2" ) add_custom_target(ppath_test COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$ - ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ppathtest.py + $ $ ) add_custom_target(ppath_notest COMMAND ${CMAKE_COMMAND} -E env diff --git a/python/silly1/donuts/__init__.py b/python/silly 1/donuts/__init__.py similarity index 100% rename from python/silly1/donuts/__init__.py rename to python/silly 1/donuts/__init__.py diff --git a/python/sully2/bagels/__init__.py b/python/sully 2/bagels/__init__.py similarity index 100% rename from python/sully2/bagels/__init__.py rename to python/sully 2/bagels/__init__.py From 50f4853fdafe71dd79f1b91f94b29aca4df889a7 Mon Sep 17 00:00:00 2001 From: Henri Manson Date: Mon, 4 Mar 2019 17:48:07 +0100 Subject: [PATCH 3/3] correct use of $ and other generator expressions --- cmake/MacroASN1Module.cmake | 2 +- cmake/PythonSupport.cmake | 30 ------------------------------ python/CMakeLists.txt | 5 +++-- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/cmake/MacroASN1Module.cmake b/cmake/MacroASN1Module.cmake index 5570254..0fd5085 100644 --- a/cmake/MacroASN1Module.cmake +++ b/cmake/MacroASN1Module.cmake @@ -70,7 +70,7 @@ macro(add_asn1_module _modulename _groupname) # Generate the module file in # and python/testing/modulename.py # and install the header file to include/quick-der/modulename.h. - AppendToPythonPath (_ppath ${CMAKE_SOURCE_DIR}/python) + set (_ppath ${_ppath} ${CMAKE_SOURCE_DIR}/python) add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/quick-der/${_modulename}.h COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${_ppath} ${PYTHON_EXECUTABLE} ${_qd_asn2quickder} -l c ${asn1module_asn2quickder_options} ${CMAKE_CURRENT_SOURCE_DIR}/${_modulename}.asn1 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_modulename}.asn1 diff --git a/cmake/PythonSupport.cmake b/cmake/PythonSupport.cmake index 01ed8d3..cb5b879 100644 --- a/cmake/PythonSupport.cmake +++ b/cmake/PythonSupport.cmake @@ -11,36 +11,6 @@ # SPDX-License-Identifier: BSD-2-Clause.degroot # License-Filename: LICENSES/BSD-2-Clause.degroot -# Not using WIN32 here, because that's set when the **target** system -# is Windows. Here, we need it while building, regardless of target, -# on a Windows host. -if (CMAKE_HOST_SYSTEM MATCHES "Windows") - set (PYTHON_PATH_SEPARATOR "\;") -else() - set (PYTHON_PATH_SEPARATOR ":") -endif() - -# Sets @p VARNAME to the value of the environment-variable PYTHONPATH, -# with @p path appended to it with a suitable separator. If more than -# one value is passed in, they are all appended with suitable separators. -# -# This **could** be generalized, to use a different ENV variable. -function (AppendToPythonPath VARNAME path) - set (_ppath $ENV{PYTHONPATH}) - # Special-case if the existing environment variable is empty. - if (NOT _ppath) - set (_ppath ${path}) - else() - set (_ppath "${_ppath}${PYTHON_PATH_SEPARATOR}${path}") - endif() - # And append all the rest. - foreach (a ${ARGN}) - set (_ppath "${_ppath}${PYTHON_PATH_SEPARATOR}${a}") - endforeach() - - set (${VARNAME} "${_ppath}" PARENT_SCOPE) -endfunction() - # Find a Python3 interpreter. This is a flimsy wrapper around find_package, # and only sets PYTHON_FOUND and PYTHON_EXECUTABLE, as the old-fashioned way. macro (FindPythonInterpreter) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 7e1822f..a586072 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -11,12 +11,13 @@ if (NOT NO_TESTING) WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) endif() -AppendToPythonPath (_ppath +set (_ppath + ${_ppath} "${CMAKE_CURRENT_SOURCE_DIR}/silly 1" "${CMAKE_CURRENT_SOURCE_DIR}/sully 2" ) add_custom_target(ppath_test - COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=$ + COMMAND ${CMAKE_COMMAND} -E env "PYTHONPATH=$" $ $ ) add_custom_target(ppath_notest