TestPackageConfig.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Create the build directory
  2. execute_process (
  3. COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR}
  4. RESULT_VARIABLE _DIRECTORY_CREATED_SUCCEEDED
  5. )
  6. if (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
  7. message (FATAL_ERROR "Failed to create build directory")
  8. endif (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
  9. if (GENERATOR_TOOLSET)
  10. list (APPEND _ADDITIONAL_ARGS -T ${GENERATOR_TOOLSET})
  11. endif (GENERATOR_TOOLSET)
  12. if (GENERATOR_PLATFORM)
  13. list (APPEND _ADDITIONAL_ARGS -A ${GENERATOR_PLATFORM})
  14. endif (GENERATOR_PLATFORM)
  15. # Run CMake
  16. execute_process (
  17. # Capture the PATH environment variable content set during project generation
  18. # stage. This is required because later during the build stage the PATH is
  19. # modified again (e.g., for MinGW AppVeyor CI builds) by adding back the
  20. # directory containing git.exe. Incidently, the Git installation directory
  21. # also contains sh.exe which causes MinGW Makefile generation to fail.
  22. COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH}
  23. ${CMAKE_COMMAND} -C ${INITIAL_CACHE}
  24. -G ${GENERATOR}
  25. ${_ADDITIONAL_ARGS}
  26. -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON
  27. -DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON
  28. -DCMAKE_PREFIX_PATH=${PACKAGE_DIR}
  29. ${SOURCE_DIR}
  30. WORKING_DIRECTORY ${TEST_BINARY_DIR}
  31. RESULT_VARIABLE _GENERATE_SUCCEEDED
  32. )
  33. if (NOT _GENERATE_SUCCEEDED EQUAL 0)
  34. message (FATAL_ERROR "Failed to generate project files using CMake")
  35. endif (NOT _GENERATE_SUCCEEDED EQUAL 0)