OTB_WRAP_PYTHON=OFF and OTB_WRAP_PYTHON3=ON leads to chaotic behavior of OTB cmake configuration

Description

With options OTB_WRAP_PYTHON=OFF and OTB_WRAP_PYTHON3=ON (with all Python interpreters and libs installed on my system), I need to configure otb twice to complete the configuration process. The first iteration triggers an error in otb-module-init.cmake from SWIG module. If you run the cmake command again the configuration complete without error.

The issue seems related to the call to macros swap_cache_variables and swap_variables which are called to swap varaibles from Python2 to Python 3:

https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/blob/develop/Modules/Wrappers/SWIG/otb-module-init.cmake#L77

OTB cmake: a great example of a chaotic system :)

Steps to reproduce

cmake -DOTB_WRAP_PYTHON=OFF -DOTB_WRAP_PYTHON3=ON $src_dir

The output of the first configuration is:

CMake Error at Modules/Wrappers/SWIG/otb-module-init.cmake:60 (set): set given invalid arguments for CACHE mode. Call Stack (most recent call first): Modules/Wrappers/SWIG/otb-module-init.cmake:80 (swap_cache_variable) CMake/OTBModuleEnablement.cmake:394 (include) CMakeLists.txt:342 (include)

Run the configuration again (without any other modification): cmake .

CMake 3.5.1 successfully configured OTB using Unix Makefiles generator

======================= End of OTB cmake summary =======================
-- Configuring done

Configuration information

Ubuntu 14.04