RunCMakeTest.cmake 1.1 KB

1234567891011121314151617181920212223242526
  1. include(RunCMake)
  2. function(run_single_config_test label config exclude_from_all_value expectation)
  3. set(case single-config)
  4. message("-- Starting ${case} test: ${label}")
  5. set(full_case_name "${case}-build-${config}")
  6. set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${full_case_name}/")
  7. run_cmake_with_options(${case}
  8. -DCMAKE_BUILD_TYPE=${config}
  9. -DTOOL_EXCLUDE_FROM_ALL=${exclude_from_all_value})
  10. set(RunCMake_TEST_NO_CLEAN 1)
  11. include(${RunCMake_TEST_BINARY_DIR}/target_files_${config}.cmake)
  12. run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config ${config})
  13. endfunction()
  14. run_single_config_test("explicitly not excluded" Debug 0 "should_exist")
  15. run_single_config_test("excluded" Debug 1 "should_not_exist")
  16. if(RunCMake_GENERATOR MATCHES "^(Xcode|Visual Studio)")
  17. run_cmake(error-on-mixed-config)
  18. else()
  19. run_single_config_test("explicitly not excluded with genex"
  20. Release $<CONFIG:Debug> "should_exist")
  21. run_single_config_test("excluded with genex"
  22. Debug $<CONFIG:Debug> "should_not_exist")
  23. endif()