OutputDirectory.cmake 1.5 KB

123456789101112131415161718192021222324252627282930
  1. #
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. #
  8. # Set output directories
  9. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib CACHE PATH "Build directory for static libraries and import libraries")
  10. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build directory for shared libraries")
  11. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Build directory for executables")
  12. # We install outside of the binary dir because our install support muliple platforms to
  13. # be installed together. We also have an exclusion rule in the AP that filters out the
  14. # "install" folder to avoid the AP picking it up
  15. unset(define_with_force)
  16. if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
  17. set(define_with_force FORCE)
  18. endif()
  19. set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install CACHE PATH "Install directory" ${define_with_force})
  20. cmake_path(ABSOLUTE_PATH CMAKE_BINARY_DIR NORMALIZE OUTPUT_VARIABLE cmake_binary_dir_normalized)
  21. cmake_path(ABSOLUTE_PATH CMAKE_INSTALL_PREFIX NORMALIZE OUTPUT_VARIABLE cmake_install_prefix_normalized)
  22. cmake_path(COMPARE ${cmake_binary_dir_normalized} EQUAL ${cmake_install_prefix_normalized} are_paths_equal)
  23. if(are_paths_equal)
  24. message(FATAL_ERROR "Binary dir is the same path as install prefix, indicate a different install prefix with "
  25. "CMAKE_INSTALL_PREFIX or a different binary dir with -B <binary dir>")
  26. endif()