-if(NOT ALICE_INSTALL)
- message(STATUS "AliRoot files will be installed in ${ALICE_ROOT}. You can specify a different location by setting ALICE_INSTALL environment variable")
- set(ALICE_INSTALL ${ALICE_ROOT})
-else()
- message(STATUS "AliRoot files will be installed in ${ALICE_INSTALL}")
-endif(NOT ALICE_INSTALL)
-if(${ALICE_INSTALL} STREQUAL ${CMAKE_BINARY_DIR})
- message(FATAL_ERROR "Install dir should be different from build dir")
+# If CMAKE_INSTALL_PREFIX was not set, then we set it to ALICE_INSTALL.
+# If ALICE_INSTALL was not defined, then it will default to the source directory
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ if(ALICE_INSTALL)
+ message(STATUS "AliRoot files will be installed in ${ALICE_INSTALL}")
+ else()
+ message(STATUS "AliRoot files will be installed in ${ALICE_ROOT}. You
+ can specify a different location by passing -DCMAKE_INSTALL_PREFIX or
+ by setting ALICE_INSTALL environment variable")
+ set(ALICE_INSTALL ${ALICE_ROOT})
+ if(${ALICE_INSTALL} STREQUAL ${CMAKE_BINARY_DIR})
+ message(FATAL_ERROR "The install directory must differ from the
+ build directory")
+ endif()
+ endif()
+ set(CMAKE_INSTALL_PREFIX ${ALICE_INSTALL} CACHE STRING "Install dir" FORCE)