Hi all, I am experiencing problems during the CMake configure step when using the function variable_watch. Consider the following minimal CMakeLists file:
cmake_minimum_required(VERSION 3.4) project(test CXX) function(myhook _variable _access _value _current_list_file _stack) if("${_value}" STREQUAL "") # Do nothing endif() endfunction() variable_watch(CMAKE_CURRENT_LIST_DIR myhook) find_package(PythonInterp REQUIRED) When configuring on Windows using CMake 3.4.1 with the Visual Studio generator (I tried both VS2012 and VS2015), the process fails with an error message (notice the strange symbols at the beginning of the line mentioning FindPackageMessage.cmake): -- Detecting CXX compile features - done CMake Error at C:/Tools/CMake_3.4.1/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:142 (include): include could not find load file: L☺/Tools/CMake_3.4.1/share/cmake-3.4/Modules/FindPackageMessage.cmake Call Stack (most recent call first): C:/Tools/CMake_3.4.1/share/cmake-3.4/Modules/FindPythonInterp.cmake:161 (include) CMakeLists.txt:12 (find_package) CMake Error at C:/Tools/CMake_3.4.1/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:379 (FIND_PACKAGE_MESSAGE): Unknown CMake command "FIND_PACKAGE_MESSAGE". Call Stack (most recent call first): C:/Tools/CMake_3.4.1/share/cmake-3.4/Modules/FindPythonInterp.cmake:162 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:12 (find_package) I did some more testing, and the configuration step is successful when: - using CMake 2.8.12 or 3.4.0 - using 3.4.1 (or older versions) on osx (I did not try linux) - removing the 'CXX' in the project call or removing the project call entirely - removing the check for _value inside the function It seems that for some reason adding the watch (which actually only does read-only access), the contents of the CMAKE_CURRENT_LIST_DIR variable is messed up somehow. Could I have run into some corner case behavior here? Maybe it is also useful to mention how I ended up in this situation. My requirement was to run some custom code as the very last step of the configure process. The solution I found was based on using variable_watch (see http://stackoverflow.com/questions/15760580/execute-command-or-macro-in-cmake-as-last-step-before-configure-step-finishes#15824843), but apparently this is not a very robust solution. Are there possibly better ways of accomplishing the same thing? Thanks! Regards, Yves -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake