NoScanningVariable.cmake 730 B

123456789101112131415161718192021
  1. # Enable scanning by default for targets that explicitly use C++ 20.
  2. cmake_policy(SET CMP0155 NEW)
  3. enable_language(CXX)
  4. # Hide any real scanning rule that may be available.
  5. unset(CMAKE_CXX_SCANDEP_SOURCE)
  6. # Explicitly enable C++20 for all targets.
  7. set(CMAKE_CXX_STANDARD 20)
  8. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  9. # Explicitly suppress scanning so that support is not required.
  10. set(CMAKE_CXX_SCAN_FOR_MODULES OFF)
  11. add_executable(noscanning-variable main-no-use.cxx)
  12. # Verify that CMAKE_CXX_SCAN_FOR_MODULES is propagated into the check.
  13. # FIXME: Unset CMAKE_CXX_SCANDEP_SOURCE inside try_compile so this
  14. # test can verify behavior on newer compilers too.
  15. try_compile(result SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main-no-use.cxx)