title: cMake find_package Python
body: <p>I try to create multiple cMake targets using different versions of Python. In my cMakeLists I define the <code>Python_ROOT</code> variable and use <code>find_package(Python REQUIRED COMPONENTS Interpreter Development)</code> to get the python library path, version and linking options.</p>
  <p>Is it possible to undo the find_package and call <code>find_package(..)</code> a second time? Something like the code snipped bellow. Right now, I get to times the same python version.
  In the final version, the user should define a list of python paths when calling cMake.</p>
  <pre><code>cmake_minimum_required (VERSION 3.10)
  
  cmake_policy(SET CMP0048 NEW)   # set version string with project() command
  cmake_policy(SET CMP0094 NEW)   # use LOCATION for Python lookup strategy
  cmake_policy(SET CMP0074 NEW)
  
  # Project 
  project(Test
      VERSION 1.0.0 
  )
  
  set(Python_FIND_STRATEGY LOCATION)
  
  # Python 3.5
  set(Python_ROOT &quot;&lt;PATH to 3.5&gt;&quot; CACHE PATH &quot;...&quot; FORCE)
  
  message(&quot;*****************************************&quot;)
  message(&quot;Python_ROOT &quot; ${Python_ROOT})
  find_package(Python REQUIRED COMPONENTS Interpreter Development)
  
  message(&quot;Python_FOUND &quot; ${Python_FOUND})
  message(&quot;Python_Interpreter_FOUND &quot; ${Python_Interpreter_FOUND})
  message(&quot;Python_Development_FOUND &quot; ${Python_Development_FOUND})
     
  message(&quot;Python_LIBRARIES &quot; ${Python_LIBRARIES})
  message(&quot;Python_LIBRARY_DIRS &quot; ${Python_LIBRARY_DIRS})
  message(&quot;Python_INCLUDE_DIRS &quot; ${Python_INCLUDE_DIRS})
  message(&quot;Python_LINK_OPTIONS &quot; ${Python_LINK_OPTIONS})
  message(&quot;Python_EXECUTABLE &quot; ${Python_EXECUTABLE})
  message(&quot;Python_INTERPRETER_ID &quot; ${Python_INTERPRETER_ID})
    
  message(&quot;Python_VERSION &quot; ${Python_VERSION})
  message(&quot;Python_VERSION_MAJOR &quot; ${Python_VERSION_MAJOR})
  message(&quot;Python_VERSION_MINOR &quot; ${Python_VERSION_MINOR})
  message(&quot;*****************************************&quot;)
  
  # target A definition
  
  # Python 2.7
  set(Python_ROOT &quot;&lt;PATH to 2.7&gt;&quot; CACHE PATH &quot;...&quot; FORCE)
  
  message(&quot;*****************************************&quot;)
  message(&quot;Python_ROOT &quot; ${Python_ROOT})
  find_package(Python REQUIRED COMPONENTS Interpreter Development)
  
  message(&quot;Python_FOUND &quot; ${Python_FOUND})
  message(&quot;Python_Interpreter_FOUND &quot; ${Python_Interpreter_FOUND})
  message(&quot;Python_Development_FOUND &quot; ${Python_Development_FOUND})
     
  message(&quot;Python_LIBRARIES &quot; ${Python_LIBRARIES})
  message(&quot;Python_LIBRARY_DIRS &quot; ${Python_LIBRARY_DIRS})
  message(&quot;Python_INCLUDE_DIRS &quot; ${Python_INCLUDE_DIRS})
  message(&quot;Python_LINK_OPTIONS &quot; ${Python_LINK_OPTIONS})
  message(&quot;Python_EXECUTABLE &quot; ${Python_EXECUTABLE})
  message(&quot;Python_INTERPRETER_ID &quot; ${Python_INTERPRETER_ID})
    
  message(&quot;Python_VERSION &quot; ${Python_VERSION})
  message(&quot;Python_VERSION_MAJOR &quot; ${Python_VERSION_MAJOR})
  message(&quot;Python_VERSION_MINOR &quot; ${Python_VERSION_MINOR})
  message(&quot;*****************************************&quot;)
  
  # target B definition
  </code></pre>
  <p><strong>Edit:</strong>
  The output of the script above is:</p>
  <pre><code>-- Building for: Visual Studio 16 2019
  -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19042.
  -- The C compiler identification is MSVC 19.28.29910.0
  -- The CXX compiler identification is MSVC 19.28.29910.0
  -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe
  -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe
  -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  *****************************************
  Python_ROOT C:/Users/schnudi/.edm/envs/py35
  -- Found Python: C:/Users/schnudi/.edm/envs/py35/python.exe (found version &quot;3.5.2&quot;) found components: Interpreter Development
  Python_FOUND TRUE
  Python_Interpreter_FOUND TRUE
  Python_Development_FOUND TRUE
  Python_LIBRARIES C:/Users/schnudi/.edm/envs/py35/libs/python35.lib
  Python_LIBRARY_DIRS C:/Users/schnudi/.edm/envs/py35/libs
  Python_INCLUDE_DIRS C:/Users/schnudi/.edm/envs/py35/include
  Python_LINK_OPTIONS
  Python_EXECUTABLE C:/Users/schnudi/.edm/envs/py35/python.exe
  Python_INTERPRETER_ID Canopy
  Python_VERSION 3.5.2
  Python_VERSION_MAJOR 3
  Python_VERSION_MINOR 5
  *****************************************
  *****************************************
  Python_ROOT C:/Users/schnudi/.edm/envs/py27
  CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
    Could NOT find Python (missing: Interpreter Development) (found version
    &quot;3.5&quot;)
  Call Stack (most recent call first):
    C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
    C:/Program Files/CMake/share/cmake-3.16/Modules/FindPython.cmake:347 (find_package_handle_standard_args)
    CMakeLists.txt:44 (find_package)
  
  
  -- Configuring incomplete, errors occurred!
  See also &quot;C:/Users/schnudi/Desktop/temp/allinone/build/CMakeFiles/CMakeOutput.log&quot;.
  </code></pre>