I really enjoy having my top-level project, driving compilation of my sub-projects. I currently have a tree such as:
gdcm -- cmake_minimum_required(VERSION 3.8.2 FATAL_ERROR)
├── Utilities
│ ├── gdcmcharls -- cmake_minimum_required(VERSION 2.8.7)
I'd like to keep this as close as possible to each different upstream projects I have a convienent copy of. However when I'd like to test a new feature of CMake, I cannot simply change the top-level CMakeList.txt file and hope that new policies will be transmitted to individual sub-project (by definition of the nested command cmake_minimum_required
).
Is there an idiom to say something like:
if(TOPLEVEL PROJECT)
cmake_minimum_required(VERSION 2.8.7)
else()
cmake_minimum_required(VERSION ${INHERITED_VERSION})
endif()
Something like this should work:
if(NOT DEFINED CMAKE_MINIMUM_REQUIRED_VERSION)
cmake_minimum_required(VERSION 2.8.7)
endif()
I would not call cmake_minimum_required
if it's already defined, since this will overwrite the policies that you manually set in your main project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With