The following command works for me well:cmake ../ -DBoost_NO_BOOST_CMAKE=BOOL:ONi.e., cmake ignores system BoostConfig.cmake, which is what I need. But if I try to do the same via an environment variable:Boost_NO_BOOST_CMAKE=ON cmake ../cmake still reads BoostConfig.cmake and I got the following error:CMake Error at /usr/lib64/boost/BoostConfig.cmake:64 (get_target_property):I've tried also setting to TRUE, BOOL:ON, etc. as well. Using cmake version 3.3.1. Any hint?UPDATEAddingset(Boost_NO_BOOST_CMAKE TRUE)into CMakeList.txt works well, but the same line added into PreLoad.cmake does not. In the second case, running cmake with trace and debug options gives the following first few log lines:Configuring Debug su3-dense ...Running with debug output on.Running with trace output on./home/langr/projects/su3dense/PreLoad.cmake(1):set(Boost_NO_BOOST_CMAKE TRUE )/home/langr/projects/su3dense/CMakeLists.txt(1):cmake_minimum_required(VERSION 3.0.0 )...So, the PreLoad.cmake file is apparently processed and the variable Boost_NO_BOOST_CMAKE is set. Why is this setting then ignored?UPDATE 2I finally got it working by writing set(Boost_NO_BOOST_CMAKE TRUE CACHE BOOL "" FORCE)into PreLoad.cmake.
If I look at the FindBoost.cmake source code this check is not meant for environment variables, but for Boost_NO_BOOST_CMAKE CMake variable only. Can you please give a reference for why this should work with an environment variable? Your first -D call seems to be the valid solution.
Florian: In fact I cannot, I'm new to cmake and thought it considers environment variables for all internal variables automatically. My first -D call is a valid solution, but unfortunately it requires me to change some build script being a part of a Git project. Setting an environment variable in my .bashrc would be a much more elegant solution here.
Could one of the solutions I've posted in my answer here be feasible? You could e.g. extend your main CMakeLists.txt to transfer the content of the environment variable into a CMake cached variable. Or if you don't want to change your CMakeLists.txt you could put the code into PreLoad.cmake (for details see here).
Florian: I've tried the PreLoad.cmake solution but it does not work for me. Please, see the updated question.
You're welcome. And I appologize that I forgot to mention the scope of PreLoad.cmake. Since it's not included in your main CMakeLists.txt but rather loaded before your main CMakeLists.txt, all variables set in PreLoad.cmake have to be cached variables - if they should also be visible in your main CMakeLists.txt.