I have two projects: A and B. A depends on B but should set some settings for the proper compilation of B when included in A.<div><br></div><div>==== CMakeLists.txt ==== (project A)</div><div><br></div><div>set(PROJB_OPENCV_LINK NO)</div>
<div><br></div><div>add_subdirectory(vendor/projb)</div><div><br></div><div>==== vendor/projb/CMakeLists.txt === (project B)</div><div><div><br></div><div>option (PROJB_OPENCV_LINK "Set this to NO to link opencv alloc later." YES)</div>
</div><div><br></div><div>========</div><div><br></div><div>The local value "PROJB_OPENCV_LINK" is overwritten by the option on the first run. If you run cmake a second time, the cached value is seen and takes over so the option does not overwrite.</div>
<div><br></div><div>I do not see any reason why an "option" setting should overwrite a defined variable.</div><div><br></div><div>build > cmake .. ==> fail</div><div><br></div><div>build > cmake .. || cmake .. ==> works. This is absurd.</div>
<div><br></div><div>Gaspard</div><div><br></div><div><br></div><div>PS: I know there is a workaround by using IF(DEFINED...).</div>