changeset 828:03b0c817a1a3

added install target and possibility to pre- and suffix ldc's executable name to cmake scripts
author elrood
date Thu, 04 Dec 2008 22:09:24 +0100
parents 489f6f39ca09
children 0a31c60a6bc1
files CMakeLists.txt runtime/CMakeLists.txt
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Thu Dec 04 16:13:40 2008 +0100
+++ b/CMakeLists.txt	Thu Dec 04 22:09:24 2008 +0100
@@ -40,6 +40,8 @@
 )
 
 set(D_VERSION 1 CACHE STRING "D language version")
+set(PROGRAM_PREFIX CACHE STRING "prepended to ldc binary name")
+set(PROGRAM_SUFFIX CACHE STRING "appended to ldc binary name")
 option(USE_BOEHM_GC "use the Boehm garbage collector internally")
 option(GENERATE_OFFTI "generate complete ClassInfo.offTi arrays")
 
@@ -137,6 +139,7 @@
 
 if(UNIX)
 	add_definitions(-DPOSIX)
+	set(CONF_INST_DIR etc)
 endif(UNIX)
 
 if(USE_BOEHM_GC)
@@ -157,8 +160,11 @@
 
 add_executable(${LDC_EXE} ${LDC_SOURCE_FILES})
 
+set(LDC_EXE_NAME ${PROGRAM_PREFIX}${LDC_EXE}${PROGRAM_SUFFIX})
+
 set_target_properties(
 	${LDC_EXE} PROPERTIES
+	OUTPUT_NAME ${LDC_EXE_NAME}
 	RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin
 	COMPILE_FLAGS "${LLVM_CXXFLAGS} -Wno-deprecated -Wno-write-strings"
 )
@@ -167,6 +173,7 @@
 target_link_libraries(${LDC_EXE} "${LLVM_LDFLAGS} ${LLVM_LIBS}")
 if(WIN32)
 	target_link_libraries(${LDC_EXE} psapi)
+	set(CONF_INST_DIR bin)
 endif(WIN32)
 
 if(USE_BOEHM_GC)
@@ -175,7 +182,10 @@
 
 get_target_property(LDC_LOC ${LDC_EXE} LOCATION)
 
-# TODO: install target
 # TODO: testrun
 
-add_subdirectory(runtime EXCLUDE_FROM_ALL)
+install(TARGETS ${LDC_EXE} DESTINATION bin)
+
+install(FILES ${PROJECT_BINARY_DIR}/bin/${LDC_EXE_NAME}.conf DESTINATION ${CONF_INST_DIR})
+
+add_subdirectory(runtime)
--- a/runtime/CMakeLists.txt	Thu Dec 04 16:13:40 2008 +0100
+++ b/runtime/CMakeLists.txt	Thu Dec 04 22:09:24 2008 +0100
@@ -28,7 +28,6 @@
 set(RUNTIME_DIR ${PROJECT_PARENT_DIR}/${RUNTIME} CACHE PATH "runtime source dir" FORCE)
 
 if(D_VERSION EQUAL 1)
-	set(LDC_EXE ldc)
 	# copy imports to runtime dir
 	add_custom_command(
 		OUTPUT ldc-imports
@@ -48,7 +47,6 @@
 	file(GLOB CORE_D ${RUNTIME_DIR}/lib/common/tango/core/*.d)
 	file(GLOB CORE_C ${RUNTIME_DIR}/lib/common/tango/stdc/*.c)
 elseif(D_VERSION EQUAL 2)
-	set(LDC_EXE ldc2)
 	set(RUNTIME_CC druntime-core)
 	set(RUNTIME_GC druntime-gc-basic)
 	set(RUNTIME_DC druntime-rt-ldc)
@@ -73,9 +71,10 @@
 	if(NOT LDC_LOC)
 		message(SEND_ERROR "ldc not found")
 	endif(NOT LDC_LOC)
+	set(LDC_EXE_NAME ${LDC_EXE})
 endif(NOT LDC_LOC)
 
-configure_file(${PROJECT_PARENT_DIR}/${LDC_EXE}.conf.in ${PROJECT_BINARY_DIR}/../bin/${LDC_EXE}.conf)
+configure_file(${PROJECT_PARENT_DIR}/${LDC_EXE}.conf.in ${PROJECT_BINARY_DIR}/../bin/${LDC_EXE_NAME}.conf)
 
 # patch runtime source, uses LDC_EXE for ldc / ldc2
 find_program(PATCH_EXE patch DOC "path to patch tool")
@@ -178,3 +177,5 @@
 
 # BCLIBS is empty if BUILD_BC_LIBS is not selected
 add_custom_target(runtime DEPENDS ${LIBS} ${BCLIBS})
+
+install(DIRECTORY ${PROJECT_BINARY_DIR}/../lib DESTINATION .)
\ No newline at end of file