1 PROJECT (TestSimpleInstall)
2 SET(CMAKE_VERBOSE_MAKEFILE 1)
3 #SET(EXECUTABLE_OUTPUT_PATH "${TestSimpleInstall_BINARY_DIR}/This is exec path")
4 SET(EXECUTABLE_OUTPUT_PATH "${TestSimpleInstall_BINARY_DIR}/ExecPath")
5 SET(LIBRARY_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}")
7 SET(CMAKE_DEBUG_POSTFIX "_test_debug_postfix")
9 SET(EXTRA_INSTALL_FLAGS)
10 MESSAGE("Extra install: ${EXTRA_INSTALL_FLAGS}")
13 SET(LIBPATHS "${CMAKE_INSTALL_PREFIX}/lib")
14 SET(t1NAMES test1 test1${CMAKE_DEBUG_POSTFIX})
15 SET(t2NAMES test2 test2${CMAKE_DEBUG_POSTFIX})
16 SET(t4NAMES test4 test4${CMAKE_DEBUG_POSTFIX})
19 SET(LIBPATHS ${LIBPATHS} "${CMAKE_INSTALL_PREFIX}/bin")
20 ENDIF(CYGWIN OR MINGW)
21 MESSAGE("Search for library in: ${LIBPATHS}")
22 FIND_LIBRARY(TEST1_LIBRARY
26 FIND_LIBRARY(TEST2_LIBRARY
30 FIND_LIBRARY(TEST4_LIBRARY
35 ADD_EXECUTABLE (SimpleInstallS2 inst.cxx foo.c foo.h)
36 TARGET_LINK_LIBRARIES(SimpleInstallS2 ${TEST1_LIBRARY} ${TEST2_LIBRARY} ${TEST4_LIBRARY})
37 SET(install_target SimpleInstallS2)
39 INSTALL_TARGETS(/bin SimpleInstallS2)
41 IF(CMAKE_GENERATOR MATCHES "Makefiles")
42 SUBDIRS(PREORDER TestSubDir)
43 ENDIF(CMAKE_GENERATOR MATCHES "Makefiles")
45 # this is stage 1, so create libraries and modules and install everything
46 ADD_LIBRARY(test1 STATIC lib1.cxx)
47 ADD_LIBRARY(test2 SHARED lib2.cxx)
48 ADD_LIBRARY(test3 MODULE lib3.cxx)
49 ADD_LIBRARY(test4 SHARED lib4.cxx)
51 ADD_EXECUTABLE (SimpleInstall inst.cxx foo.c foo.h)
52 TARGET_LINK_LIBRARIES(SimpleInstall test1 test2 test4)
53 SET(install_target SimpleInstall)
55 ADD_DEPENDENCIES(SimpleInstall test3)
56 ADD_DEPENDENCIES(test2 test3)
57 ADD_DEPENDENCIES(test4 test2)
59 INSTALL_TARGETS(/bin SimpleInstall)
60 INSTALL_TARGETS(/lib test1 test2 test3 test4)
61 INSTALL_TARGETS(/include lib1.h lib2.h lib3.h)
63 SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES PRE_INSTALL_SCRIPT
64 ${CMAKE_CURRENT_SOURCE_DIR}/PreInstall.cmake)
65 SET_TARGET_PROPERTIES(SimpleInstall PROPERTIES POST_INSTALL_SCRIPT
66 ${CMAKE_CURRENT_SOURCE_DIR}/PostInstall.cmake)
67 SET_TARGET_PROPERTIES(test4 PROPERTIES VERSION 1.2 SOVERSION 3)
71 TARGET ${install_target}
73 COMMAND ${CMAKE_CTEST_COMMAND}
77 --build-generator ${CMAKE_GENERATOR}
78 --build-project ${PROJECT_NAME}
79 --build-makeprogram ${CMAKE_MAKE_PROGRAM}
81 --build-target install
82 COMMENT "Install Project"