On 22/07/14 13:44, Stephen Kelly wrote: >> Does this mean that if I set the <PACKAGE>_DIR environment variable to >> the CMAKE_BINARY_DIR of my package, CMake will look into these folders >> as well? > > No, I don't think so. You would have to set it to the exact dir afaik.
Actually I tested it, and CMake actually finds the package both if the package is using export(PACKAGE) or if the user sets the <PACKAGE>_DIR or the CMAKE_PREFIX_PATH environment variables, but it does not work when passing the <PACKAGE>_DIR cmake variable (i.e. cmake -D<PACKAGE>_DIR=<path>), that needs to be the correct path to the config files... Unfortunately that's part of the workflow commonly used here to test different builds, and I don't think that I'll be allowed to change the workflow of a quite large team in this way... It is more likely that I'll have to live with "old-style" config files in the main CMAKE_BINARY_DIR, with different relative paths compared to the one installed (or with absolute paths). Also until now I always had the impression that the config file for the build tree should be in the CMAKE_BINARY_DIR folder, see for example http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file where it creates the config file for the build tree in this way: configure_file(FooBarConfig.cmake.in "${PROJECT_BINARY_DIR}/FooBarConfig.cmake" @ONLY) The ultimate solution that I can think about is to have a config file and a version file in CMAKE_BINARY_DIR that just include the real config and version files, but that sounds a little bit weird to me, even though I tested it and it works as expected... So I could have a config file (either configured, or static) in the correct relative folder, and generate the fake ones in this way: file(WRITE "${CMAKE_BINARY_DIR}/FOOConfig.cmake" "include(\${CMAKE_CURRENT_LIST_DIR}/<path>/FOOConfig.cmake)\n") file(WRITE "${CMAKE_BINARY_DIR}/FOOConfigVersion.cmake" "include(${CMAKE_CURRENT_LIST_DIR}/<path>/FOOConfigVersion.cmake)\n") What do you think, would this be an acceptable solution in a "modern CMake" style? Cheers, Daniele -- 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-developers