changeset 43:bfc76a437a62

CMake: autodetection of CMAKE_INSTALL_PREFIX. By default, command install will copy data to compiler directory.
author SokoL_SD
date Sun, 17 May 2009 16:41:44 +0000
parents eb3b5bbffc8f
children 3cb15c92ac28
files CMakeLists.txt
diffstat 1 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Sun May 17 15:53:27 2009 +0000
+++ b/CMakeLists.txt	Sun May 17 16:41:44 2009 +0000
@@ -53,12 +53,23 @@
     message(FATAL_ERROR "D compliler not founded")
 endif (DC)
 
-# find_program(DC_TMP ${DC})
-# mark_as_advanced(DC_TMP)
-# string(REGEX MATCH "([A-Za-z\\.0-9/_\\ ]+)(/bin)/[A-Za-z\\.0-9/_\\ ]+" "\\1" dc_path "${DC_PATH}")
-# if(NOT "${DC_TMP}" STREQUAL "${dc_path}")
-#     set(CMAKE_INSTALL_PREFIX ${dc_path})
-# endif(NOT "${DC_TMP}" STREQUAL "${dc_path}")
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
+    get_filename_component(dc_path ${DC} PATH)
+    if("${dc_path}" STREQUAL "")
+	find_program(dc_path_tmp ${DC})
+	get_filename_component(dc_path ${dc_path_tmp} PATH)
+	mark_as_advanced(dc_path_tmp)
+    endif("${dc_path}" STREQUAL "")
+    get_filename_component(dc_parent_dir ${dc_path} NAME)
+    if("${dc_parent_dir}" STREQUAL "bin")    	
+	get_filename_component(dc_path ${dc_path} PATH)
+	messagE(${dc_path})
+    endif("${dc_parent_dir}" STREQUAL "bin")
+    set(CMAKE_INSTALL_PREFIX
+	${dc_path} CACHE PATH "QtD install prefix" FORCE
+    )
+endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT OR "${CMAKE_INSTALL_PREFIX}" STREQUAL "")
+
 
 if(D_IS_MARS)
     option(SINGLE_D_OBJECT "Build all d sources to one object file" "ON")